X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=sandbox%2Fargeo.slc.executionflow%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fexecutionflow%2FExecutionTargetSource.java;h=b2e0f971b03b9605ee2dae485d155af13bd1e7bf;hb=f3797d5a7f833ecb183ce8d4a31a7897fbca4035;hp=51bdf250f484631da340b29a88a4c7f1a7a62559;hpb=fd419cbd85435070ee575b4cf71f74be011d4282;p=gpl%2Fargeo-slc.git diff --git a/sandbox/argeo.slc.executionflow/src/main/java/org/argeo/slc/executionflow/ExecutionTargetSource.java b/sandbox/argeo.slc.executionflow/src/main/java/org/argeo/slc/executionflow/ExecutionTargetSource.java index 51bdf250f..b2e0f971b 100644 --- a/sandbox/argeo.slc.executionflow/src/main/java/org/argeo/slc/executionflow/ExecutionTargetSource.java +++ b/sandbox/argeo.slc.executionflow/src/main/java/org/argeo/slc/executionflow/ExecutionTargetSource.java @@ -1,22 +1,35 @@ package org.argeo.slc.executionflow; +import java.util.Map; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.argeo.slc.SlcException; import org.springframework.aop.TargetSource; public class ExecutionTargetSource implements TargetSource { private final static Log log = LogFactory .getLog(ExecutionTargetSource.class); - private String name; - private Class targetClass; + private final String name; + private final Class targetClass; + private final ExecutionFlow executionFlow; + + public ExecutionTargetSource(ExecutionFlow executionFlow, + Class targetClass, String name) { + this.executionFlow = executionFlow; + this.targetClass = targetClass; + this.name = name; + } public Object getTarget() throws Exception { if (log.isTraceEnabled()) log.trace("Getting object " + name); - ExecutionFlow executionFlow = SimpleExecutionFlow - .getCurrentExecutionFlow(); - Object obj = executionFlow.getAttributes().get(name); + Map attributes = executionFlow.getAttributes(); + if (!attributes.containsKey(name)) + throw new SlcException("Key " + name + " is not registered in " + + executionFlow); + Object obj = attributes.get(name); if (log.isTraceEnabled()) log.trace("Target object " + obj); return obj; @@ -35,12 +48,4 @@ public class ExecutionTargetSource implements TargetSource { } - public void setName(String name) { - this.name = name; - } - - public void setTargetClass(Class targetClass) { - this.targetClass = targetClass; - } - }