X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=runtime%2Forg.argeo.slc.support.simple%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fcore%2Fexecution%2FExecutionParameterPostProcessor.java;h=e39e9fab78aec4798477daf7e707400111f6dc74;hb=7fdc9af3e710f0b5e63974aeb4e71e6631fcd1ff;hp=a95670b10a3fc93ccf1f52f0bf9f381fdd49c6da;hpb=743ecb28b3c0236bc91a5d0993f70477236d96fd;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/ExecutionParameterPostProcessor.java b/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/ExecutionParameterPostProcessor.java index a95670b10..e39e9fab7 100644 --- a/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/ExecutionParameterPostProcessor.java +++ b/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/ExecutionParameterPostProcessor.java @@ -8,6 +8,7 @@ import java.util.Properties; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.argeo.slc.SlcException; +import org.argeo.slc.execution.ExecutionContext; import org.springframework.beans.BeansException; import org.springframework.beans.PropertyValue; import org.springframework.beans.PropertyValues; @@ -17,9 +18,36 @@ import org.springframework.beans.factory.config.TypedStringValue; public class ExecutionParameterPostProcessor extends InstantiationAwareBeanPostProcessorAdapter { + private final static Log log = LogFactory .getLog(ExecutionParameterPostProcessor.class); + private ExecutionContext executionContext; + + private ExecutionScope executionScope; + + private InstantiationManager instantiationManager; + + public InstantiationManager getInstantiationManager() { + return instantiationManager; + } + + public void setInstantiationManager(InstantiationManager instantiationManager) { + this.instantiationManager = instantiationManager; + } + + public void setExecutionScope(ExecutionScope executionScope) { + this.executionScope = executionScope; + } + + public ExecutionContext getExecutionContext() { + return executionContext; + } + + public void setExecutionContext(ExecutionContext executionContext) { + this.executionContext = executionContext; + } + private String placeholderPrefix = "@{"; private String placeholderSuffix = "}"; private String nullValue; @@ -28,13 +56,17 @@ public class ExecutionParameterPostProcessor extends public PropertyValues postProcessPropertyValues(PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) throws BeansException { - if (!ExecutionContext.isExecuting()){ - //&& !DefaultExecutionSpec.isInFlowInitialization()) { - //log.info("Skip parameter conversion for bean " + beanName); - return pvs; - } else { - //log.info("Execute parameter conversion for bean " + beanName); - } + + +// boolean inFlowInitialization = DefaultExecutionSpec.isInFlowInitialization(); + +// if (((executionScope == null) || (!executionScope.hasExecutionContext())) +// && !inFlowInitialization) { +// //log.info("Skip parameter conversion for bean " + beanName); +// return pvs; +// } else { +// //log.info("Execute parameter conversion for bean " + beanName); +// } Properties props = new Properties(); CustomPpc ppc = new CustomPpc(props); @@ -96,15 +128,27 @@ public class ExecutionParameterPostProcessor extends @Override protected String resolvePlaceholder(String placeholder, Properties props) { - //log.info("Try convert placeholder " + placeholder); - if (ExecutionContext.isExecuting()) - return ExecutionContext.getVariable(placeholder).toString(); - else if (DefaultExecutionSpec.isInFlowInitialization()) - return DefaultExecutionSpec.getInitializingFlowParameter( - placeholder).toString(); - else - return super.resolvePlaceholder(placeholder, props); + if ((executionScope != null) && (executionScope.hasExecutionContext())) { + // if we have an execution context, look there for the placeholder + return executionContext.getVariable(placeholder).toString(); + } + else { + // TODO: check scope of the bean + // throw exception if trying to resolve placeholder on bean of scope singleton + + if (instantiationManager.isInFlowInitialization()) { + String resolved = instantiationManager.getInitializingFlowParameter( + placeholder).toString(); +// log.info("Initialization placeholder resolution " + placeholder +// + ">>" + resolved); + return resolved; + } + else { + // return super.resolvePlaceholder(placeholder, props); + throw new SlcException("Placeholder '" + placeholder + + "' can not be resolved outside of Flow Initialization or Flow Execution."); + } + } } - } }