package org.argeo.slc.runtime;
+import java.lang.System.Logger.Level;
import java.util.Stack;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.execution.ExecutionFlow;
-import org.argeo.slc.execution.ExecutionSpecAttribute;
-import org.argeo.slc.execution.RefSpecAttribute;
-import org.argeo.slc.primitive.PrimitiveSpecAttribute;
-import org.argeo.slc.primitive.PrimitiveUtils;
+import org.argeo.api.slc.SlcException;
+import org.argeo.api.slc.execution.ExecutionFlow;
+import org.argeo.api.slc.execution.ExecutionSpecAttribute;
+import org.argeo.api.slc.execution.RefSpecAttribute;
+import org.argeo.api.slc.primitive.PrimitiveSpecAttribute;
+import org.argeo.api.slc.primitive.PrimitiveUtils;
/** Manage parameters that need to be set during the instantiation of a flow */
public class InstantiationManager {
- private final static Log log = LogFactory
- .getLog(InstantiationManager.class);
+ private final static System.Logger logger = System.getLogger(InstantiationManager.class.getName());
private ThreadLocal<Stack<ExecutionFlow>> flowStack = new ThreadLocal<Stack<ExecutionFlow>>();
public Object createRef(String name) {
if ((flowStack.get() == null) || flowStack.get().empty()) {
- throw new SlcException("No flow is currently initializing."
- + " Declare ParameterRef as inner beans or prototypes.");
+ throw new SlcException(
+ "No flow is currently initializing." + " Declare ParameterRef as inner beans or prototypes.");
}
return getInitializingFlowParameter(name);
((DefaultExecutionFlow) flow).setName(flowName);
}
- if (log.isTraceEnabled())
- log.trace("Start initialization of " + flow.hashCode() + " ("
- + flow + " - " + flow.getClass() + ")");
+ logger.log(Level.TRACE,
+ () -> "Start initialization of " + flow.hashCode() + " (" + flow + " - " + flow.getClass() + ")");
// log.info("# flowInitializationStarted " + flowName);
// create a stack for this thread if there is none
}
public void flowInitializationFinished(ExecutionFlow flow, String flowName) {
- if (log.isTraceEnabled())
- log.trace("Finish initialization of " + flow.hashCode() + " ("
- + flow + " - " + flow.getClass() + ")");
+ logger.log(Level.TRACE,
+ () -> "Finish initialization of " + flow.hashCode() + " (" + flow + " - " + flow.getClass() + ")");
if (flowStack.get() != null) {
ExecutionFlow registeredFlow = flowStack.get().pop();
}
} else {
// happens for flows imported as services
- log.warn("flowInitializationFinished - Flow Stack is null");
+ logger.log(Level.WARNING, "flowInitializationFinished - Flow Stack is null");
}
}
return flowStack.get().elementAt(i);
}
}
- throw new SlcException("Key " + key + " is not set as parameter in "
- + flowStack.get().firstElement().toString() + " (stack size="
- + flowStack.get().size() + ")");
+ throw new SlcException("Key " + key + " is not set as parameter in " + flowStack.get().firstElement().toString()
+ + " (stack size=" + flowStack.get().size() + ")");
}
}
public Class<?> getInitializingFlowParameterClass(String key) {
- ExecutionSpecAttribute attr = findInitializingFlowWithParameter(key)
- .getExecutionSpec().getAttributes().get(key);
+ ExecutionSpecAttribute attr = findInitializingFlowWithParameter(key).getExecutionSpec().getAttributes()
+ .get(key);
if (attr instanceof RefSpecAttribute)
return ((RefSpecAttribute) attr).getTargetClass();
else if (attr instanceof PrimitiveSpecAttribute) {
String type = ((PrimitiveSpecAttribute) attr).getType();
Class<?> clss = PrimitiveUtils.typeAsClass(type);
if (clss == null)
- throw new SlcException("Cannot convert type " + type
- + " to class.");
+ throw new SlcException("Cannot convert type " + type + " to class.");
return clss;
} else
return null;