public Object getVariable(String key);\r
\r
public void setVariable(String key, Object value);\r
+ \r
+ public void beforeFlow(ExecutionFlow executionFlow);\r
+ \r
+ public void afterFlow(ExecutionFlow executionFlow);\r
}\r
/**
* If there is one and only one runnable wrapped return it, throw an
- * exeception otherwise.
+ * exception otherwise.
*/
public Runnable getRunnable();
* interpreted by UIs as a hierarchy;
*/
public String getName();
-
- /**
- * @deprecated will be removed in SLC 2.0, the path should be the part of
- * the name with '/'
- */
- public String getPath();
}
*/
package org.argeo.slc.execution;
-/** Deal with nested level of executions using different vartiables. */
+/** Deal with nested level of executions using different variables. */
public interface ExecutionStack {
/**
* @param name
import org.apache.commons.logging.Log;\r
import org.apache.commons.logging.LogFactory;\r
import org.argeo.slc.core.test.SimpleTestResult;\r
+import org.argeo.slc.execution.ExecutionContext;\r
import org.argeo.slc.execution.ExecutionFlow;\r
import org.argeo.slc.test.TestResultPart;\r
import org.argeo.slc.test.TestStatus;\r
protected void configureAndExecuteSlcFlow(String applicationContextSuffix,\r
String beanName) {\r
ConfigurableApplicationContext applicationContext = createApplicationContext(applicationContextSuffix);\r
+ ExecutionContext executionContext = (ExecutionContext) applicationContext\r
+ .getBean("executionContext");\r
ExecutionFlow executionFlow = (ExecutionFlow) applicationContext\r
.getBean(beanName);\r
- executionFlow.run();\r
+ if (executionFlow instanceof DefaultExecutionFlow)\r
+ ((DefaultExecutionFlow) executionFlow)\r
+ .setExecutionContext(executionContext);\r
+ try {\r
+ executionContext.beforeFlow(executionFlow);\r
+ executionFlow.run();\r
+ } finally {\r
+ executionContext.afterFlow(executionFlow);\r
+ }\r
applicationContext.close();\r
}\r
\r
</parent>
<artifactId>org.argeo.slc.core</artifactId>
<name>SLC Runtime</name>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>true</skipTests>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
<dependencies>
<!-- Commons -->
<dependency>
<artifactId>org.argeo.slc.api</artifactId>
<version>2.1.1-SNAPSHOT</version>
</dependency>
-
</dependencies>
</project>
\ No newline at end of file
private final static Log log = LogFactory
.getLog(AbstractExecutionModulesManager.class);
-// private List<FilteredNotifier> filteredNotifiers = Collections
-// .synchronizedList(new ArrayList<FilteredNotifier>());
+ // private List<FilteredNotifier> filteredNotifiers = Collections
+ // .synchronizedList(new ArrayList<FilteredNotifier>());
protected abstract ExecutionFlow findExecutionFlow(String moduleName,
String moduleVersion, String flowName);
//
// Actually runs the flow, IN THIS THREAD
//
- flow.run();
+ executionContext.beforeFlow(flow);
+ try {
+ flow.run();
+ } finally {
+ executionContext.afterFlow(flow);
+ }
//
//
//
}
-// public void dispatchUpdateStatus(ExecutionProcess process,
-// String oldStatus, String newStatus) {
-// // filtered notifiers
-// for (Iterator<FilteredNotifier> it = filteredNotifiers.iterator(); it
-// .hasNext();) {
-// FilteredNotifier filteredNotifier = it.next();
-// if (filteredNotifier.receiveFrom(process))
-// filteredNotifier.getNotifier().updateStatus(process, oldStatus,
-// newStatus);
-// }
-//
-// }
-
-// public void dispatchAddSteps(ExecutionProcess process,
-// List<ExecutionStep> steps) {
-// process.addSteps(steps);
-// for (Iterator<FilteredNotifier> it = filteredNotifiers.iterator(); it
-// .hasNext();) {
-// FilteredNotifier filteredNotifier = it.next();
-// if (filteredNotifier.receiveFrom(process))
-// filteredNotifier.getNotifier().addSteps(process, steps);
-// }
-// }
-
-// public void registerProcessNotifier(ExecutionProcessNotifier notifier,
-// Map<String, String> properties) {
-// filteredNotifiers.add(new FilteredNotifier(notifier, properties));
-// }
-//
-// public void unregisterProcessNotifier(ExecutionProcessNotifier notifier,
-// Map<String, String> properties) {
-// filteredNotifiers.remove(notifier);
-// }
-
-// protected class FilteredNotifier {
-// private final ExecutionProcessNotifier notifier;
-// private final String processId;
-//
-// public FilteredNotifier(ExecutionProcessNotifier notifier,
-// Map<String, String> properties) {
-// super();
-// this.notifier = notifier;
-// if (properties == null)
-// properties = new HashMap<String, String>();
-// if (properties.containsKey(SLC_PROCESS_ID))
-// processId = properties.get(SLC_PROCESS_ID);
-// else
-// processId = null;
-// }
-//
-// /**
-// * Whether event from this process should be received by this listener.
-// */
-// public Boolean receiveFrom(ExecutionProcess process) {
-// if (processId != null)
-// if (process.getUuid().equals(processId))
-// return true;
-// else
-// return false;
-// return true;
-// }
-//
-// @Override
-// public int hashCode() {
-// return notifier.hashCode();
-// }
-//
-// @Override
-// public boolean equals(Object obj) {
-// if (obj instanceof FilteredNotifier) {
-// FilteredNotifier fn = (FilteredNotifier) obj;
-// return notifier.equals(fn.notifier);
-// } else if (obj instanceof ExecutionProcessNotifier) {
-// ExecutionProcessNotifier epn = (ExecutionProcessNotifier) obj;
-// return notifier.equals(epn);
-// } else
-// return false;
-// }
-//
-// public ExecutionProcessNotifier getNotifier() {
-// return notifier;
-// }
-//
-// }
+ // public void dispatchUpdateStatus(ExecutionProcess process,
+ // String oldStatus, String newStatus) {
+ // // filtered notifiers
+ // for (Iterator<FilteredNotifier> it = filteredNotifiers.iterator(); it
+ // .hasNext();) {
+ // FilteredNotifier filteredNotifier = it.next();
+ // if (filteredNotifier.receiveFrom(process))
+ // filteredNotifier.getNotifier().updateStatus(process, oldStatus,
+ // newStatus);
+ // }
+ //
+ // }
+
+ // public void dispatchAddSteps(ExecutionProcess process,
+ // List<ExecutionStep> steps) {
+ // process.addSteps(steps);
+ // for (Iterator<FilteredNotifier> it = filteredNotifiers.iterator(); it
+ // .hasNext();) {
+ // FilteredNotifier filteredNotifier = it.next();
+ // if (filteredNotifier.receiveFrom(process))
+ // filteredNotifier.getNotifier().addSteps(process, steps);
+ // }
+ // }
+
+ // public void registerProcessNotifier(ExecutionProcessNotifier notifier,
+ // Map<String, String> properties) {
+ // filteredNotifiers.add(new FilteredNotifier(notifier, properties));
+ // }
+ //
+ // public void unregisterProcessNotifier(ExecutionProcessNotifier notifier,
+ // Map<String, String> properties) {
+ // filteredNotifiers.remove(notifier);
+ // }
+
+ // protected class FilteredNotifier {
+ // private final ExecutionProcessNotifier notifier;
+ // private final String processId;
+ //
+ // public FilteredNotifier(ExecutionProcessNotifier notifier,
+ // Map<String, String> properties) {
+ // super();
+ // this.notifier = notifier;
+ // if (properties == null)
+ // properties = new HashMap<String, String>();
+ // if (properties.containsKey(SLC_PROCESS_ID))
+ // processId = properties.get(SLC_PROCESS_ID);
+ // else
+ // processId = null;
+ // }
+ //
+ // /**
+ // * Whether event from this process should be received by this listener.
+ // */
+ // public Boolean receiveFrom(ExecutionProcess process) {
+ // if (processId != null)
+ // if (process.getUuid().equals(processId))
+ // return true;
+ // else
+ // return false;
+ // return true;
+ // }
+ //
+ // @Override
+ // public int hashCode() {
+ // return notifier.hashCode();
+ // }
+ //
+ // @Override
+ // public boolean equals(Object obj) {
+ // if (obj instanceof FilteredNotifier) {
+ // FilteredNotifier fn = (FilteredNotifier) obj;
+ // return notifier.equals(fn.notifier);
+ // } else if (obj instanceof ExecutionProcessNotifier) {
+ // ExecutionProcessNotifier epn = (ExecutionProcessNotifier) obj;
+ // return notifier.equals(epn);
+ // } else
+ // return false;
+ // }
+ //
+ // public ExecutionProcessNotifier getNotifier() {
+ // return notifier;
+ // }
+ //
+ // }
}
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.argeo.slc.execution.ExecutionFlow;
import org.argeo.slc.execution.ExecutionSpec;
import org.argeo.slc.execution.ExecutionSpecAttribute;
private Boolean failOnError = true;
+ // Only needed if stacked execution flows are used
+ private ExecutionContext executionContext = null;
+
public DefaultExecutionFlow() {
this.executionSpec = new DefaultExecutionSpec();
}
}
public void doExecuteRunnable(Runnable runnable) {
- runnable.run();
+ try {
+ if (executionContext != null)
+ if (runnable instanceof ExecutionFlow)
+ executionContext.beforeFlow((ExecutionFlow) runnable);
+ runnable.run();
+ } finally {
+ if (executionContext != null)
+ if (runnable instanceof ExecutionFlow)
+ executionContext.afterFlow((ExecutionFlow) runnable);
+ }
}
public void afterPropertiesSet() throws Exception {
this.failOnError = failOnError;
}
+ public void setExecutionContext(ExecutionContext executionContext) {
+ this.executionContext = executionContext;
+ }
+
}
md.getExecutionFlows().addAll(set);
}
- @SuppressWarnings("deprecation")
public ExecutionFlowDescriptor getExecutionFlowDescriptor(
ExecutionFlow executionFlow) {
if (executionFlow.getName() == null)
ExecutionFlowDescriptor efd = new ExecutionFlowDescriptor(name, null,
values, executionSpec);
- if (executionFlow.getPath() != null)
- efd.setPath(executionFlow.getPath());
- else
- efd.setPath("");
-
// Takes description from spring
BeanFactory bf = getBeanFactory();
if (bf != null) {
import org.argeo.slc.SlcException;
import org.argeo.slc.execution.ExecutionContext;
+import org.argeo.slc.execution.ExecutionFlow;
+import org.argeo.slc.execution.ExecutionStack;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
import org.springframework.beans.BeansException;
private final String uuid;
private ApplicationContext applicationContext;
+ private ExecutionStack executionStack;
public MapExecutionContext() {
uuid = UUID.randomUUID().toString();
// try system property in last resort
if (value == null)
value = System.getProperty(key);
+
+ // if the variable was not found, look in the stack starting at the
+ // upper flows
+ if (value == null) {
+ value = executionStack.findLocalVariable(key);
+ }
return value;
}
return uuid;
}
+ @Override
+ public void beforeFlow(ExecutionFlow executionFlow) {
+ // getUuid();
+ executionStack.enterFlow(executionFlow);
+ setVariable(ExecutionContext.VAR_FLOW_ID,
+ executionStack.getCurrentStackLevelUuid());
+ setVariable(ExecutionContext.VAR_FLOW_NAME, executionFlow.getName());
+ }
+
+ @Override
+ public void afterFlow(ExecutionFlow executionFlow) {
+ executionStack.leaveFlow(executionFlow);
+ }
+
@Override
public boolean equals(Object obj) {
if (obj instanceof ExecutionContext)
this.applicationContext = applicationContext;
}
+ public void setExecutionStack(ExecutionStack executionStack) {
+ this.executionStack = executionStack;
+ }
+
}
<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Copyright (C) 2007-2012 Argeo GmbH
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
+<!-- Copyright (C) 2007-2012 Argeo GmbH Licensed under the Apache License,
+ Version 2.0 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software distributed
+ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
+ OR CONDITIONS OF ANY KIND, either express or implied. See the License for
+ the specific language governing permissions and limitations under the License. -->
<!-- Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org> Licensed under
the Apache License, Version 2.0 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of the License
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
<description>Bare minimal runtime configuration. In general you will
- want to use simple.xml instead.</description>
+ want to use simple.xml instead.
+ </description>
<bean class="org.springframework.beans.factory.config.CustomScopeConfigurer">
<property name="scopes">
<property name="instantiationManager" ref="instantiationManager" />
</bean>
- <bean class="org.argeo.slc.core.execution.ExecutionAspect">
- <property name="executionStack" ref="executionStack" />
- <property name="executionContext" ref="executionContext" />
- </bean>
+ <!-- <bean class="org.argeo.slc.core.execution.ExecutionAspect"> -->
+ <!-- <property name="executionStack" ref="executionStack" /> -->
+ <!-- <property name="executionContext" ref="executionContext" /> -->
+ <!-- </bean> -->
<aop:aspectj-autoproxy />
<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Copyright (C) 2007-2012 Argeo GmbH
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
+<!-- Copyright (C) 2007-2012 Argeo GmbH Licensed under the Apache License,
+ Version 2.0 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software distributed
+ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
+ OR CONDITIONS OF ANY KIND, either express or implied. See the License for
+ the specific language governing permissions and limitations under the License. -->
<!-- Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org> Licensed under
the Apache License, Version 2.0 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of the License
<bean id="executionContext" class="org.argeo.slc.core.execution.MapExecutionContext"
scope="execution">
<aop:scoped-proxy proxy-target-class="false" />
+ <property name="executionStack" ref="executionStack" />
</bean>
<bean id="executionFlowDescriptorConverter"
}
}
- @SuppressWarnings("deprecation")
protected ObjectName flowMBeanName(Module module,
ExecutionFlow executionFlow) {
String executionModulesPrefix = "SLCExecutionModules";
- String path = executionFlow.getPath();
+ // String path = executionFlow.getPath();
String name = executionFlow.getName();
- if (path == null && name.indexOf('/') >= 0) {
- path = name.substring(0, name.lastIndexOf('/'));
- name = name.substring(name.lastIndexOf('/'));
- }
+ // if (path == null && name.indexOf('/') >= 0) {
+ // path = name.substring(0, name.lastIndexOf('/'));
+ // name = name.substring(name.lastIndexOf('/'));
+ // }
StringBuffer buf = new StringBuffer(executionModulesPrefix + ":"
+ "module=" + module.getName() + " [" + module.getVersion()
+ "],");
- if (path != null && !path.equals("")) {
- int depth = 0;
- for (String token : path.split("/")) {
- if (!token.equals("")) {
- buf.append("path").append(depth).append('=');
- // in order to have directories first
- buf.append('/');
- buf.append(token).append(',');
- depth++;
- }
- }
- }
+ // if (path != null && !path.equals("")) {
+ // int depth = 0;
+ // for (String token : path.split("/")) {
+ // if (!token.equals("")) {
+ // buf.append("path").append(depth).append('=');
+ // // in order to have directories first
+ // buf.append('/');
+ // buf.append(token).append(',');
+ // depth++;
+ // }
+ // }
+ // }
buf.append("name=").append(name);
try {
return new ObjectName(buf.toString());