]> git.argeo.org Git - gpl/argeo-slc.git/blob - sandbox/argeo.slc.executionflow/src/main/java/org/argeo/slc/executionflow/ExecutionTargetSource.java
b2e0f971b03b9605ee2dae485d155af13bd1e7bf
[gpl/argeo-slc.git] / sandbox / argeo.slc.executionflow / src / main / java / org / argeo / slc / executionflow / ExecutionTargetSource.java
1 package org.argeo.slc.executionflow;
2
3 import java.util.Map;
4
5 import org.apache.commons.logging.Log;
6 import org.apache.commons.logging.LogFactory;
7 import org.argeo.slc.SlcException;
8 import org.springframework.aop.TargetSource;
9
10 public class ExecutionTargetSource implements TargetSource {
11 private final static Log log = LogFactory
12 .getLog(ExecutionTargetSource.class);
13
14 private final String name;
15 private final Class<?> targetClass;
16 private final ExecutionFlow executionFlow;
17
18 public ExecutionTargetSource(ExecutionFlow executionFlow,
19 Class<?> targetClass, String name) {
20 this.executionFlow = executionFlow;
21 this.targetClass = targetClass;
22 this.name = name;
23 }
24
25 public Object getTarget() throws Exception {
26 if (log.isTraceEnabled())
27 log.trace("Getting object " + name);
28 Map<String, Object> attributes = executionFlow.getAttributes();
29 if (!attributes.containsKey(name))
30 throw new SlcException("Key " + name + " is not registered in "
31 + executionFlow);
32 Object obj = attributes.get(name);
33 if (log.isTraceEnabled())
34 log.trace("Target object " + obj);
35 return obj;
36 }
37
38 public Class getTargetClass() {
39 return targetClass;
40 }
41
42 public boolean isStatic() {
43 return false;
44 }
45
46 public void releaseTarget(Object target) throws Exception {
47 // TODO Auto-generated method stub
48
49 }
50
51 }