--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
<projects>
</projects>
<buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
</buildSpec>
<natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
</natures>
</projectDescription>
</bean>
</property>
</bean>
+
+ <!-- SLC Execution Listener -->
+ <bean id="slcExecutionListener" class="org.argeo.slc.jms.JmsSlcExecutionNotifier">
+ <property name="updateStatusDestination" ref="slcJms.destination.slcExecution.updateStatus" />
+ <property name="jmsTemplate">
+ <bean class="org.springframework.jms.core.JmsTemplate">
+ <property name="messageConverter" ref="slcDefault.jms.castorMessageConverter" />
+ <property name="connectionFactory" ref="jmsConnectionFactory" />
+ </bean>
+ </property>
+ </bean>
</beans>
\ No newline at end of file
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
\r
<service ref="resultListener" interface="org.argeo.slc.test.TestResultListener" />\r
+ <service ref="slcExecutionListener" interface="org.argeo.slc.process.SlcExecutionNotifier" />\r
\r
<reference id="modulesManager"\r
interface="org.argeo.slc.execution.ExecutionModulesManager" />\r
<beans:bean class="org.argeo.slc.core.test.tree.TreeTestResultLogger" />\r
</service>\r
\r
+ <list id="slcExecutionListeners" interface="org.argeo.slc.process.SlcExecutionNotifier" cardinality="0..N"/>\r
</beans:beans>
\ No newline at end of file
\r
<bean id="modulesManager" class="org.argeo.slc.core.execution.DefaultModulesManager">\r
<property name="executionModules" ref="executionModules" />\r
+ <property name="slcExecutionNotifiers" ref="slcExecutionListeners" />\r
</bean>\r
</beans>
\ No newline at end of file
<module>org.argeo.slc.demo.deploy</module>
<module>org.argeo.slc.demo.log4j</module>
</modules>
+ <dependencies>
+ <!--
+ <dependency>
+ <groupId>org.argeo.slc.demo</groupId>
+ <artifactId>org.argeo.slc.demo.basic</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ -->
+ </dependencies>
</project>
--- /dev/null
+package org.argeo.slc.services.impl.process;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.dao.process.SlcExecutionDao;
+import org.argeo.slc.msg.process.SlcExecutionRequest;
+import org.argeo.slc.msg.process.SlcExecutionStatusRequest;
+import org.argeo.slc.process.SlcExecution;
+import org.argeo.slc.services.process.SlcExecutionService;
+
+public class SlcExecutionServiceImpl implements SlcExecutionService {
+ private final Log log = LogFactory.getLog(getClass());
+
+ private final SlcExecutionDao slcExecutionDao;
+
+ public SlcExecutionServiceImpl(SlcExecutionDao slcExecutionDao) {
+ this.slcExecutionDao = slcExecutionDao;
+ }
+
+ public void newExecution(SlcExecution slcExecutionMsg) {
+ SlcExecution slcExecutionPersisted = slcExecutionDao
+ .getSlcExecution(slcExecutionMsg.getUuid());
+ if (slcExecutionPersisted == null) {
+ if (log.isTraceEnabled())
+ log.trace("Creating SLC execution #"
+ + slcExecutionMsg.getUuid());
+
+ slcExecutionDao.create(slcExecutionMsg);
+ } else {
+ if (log.isTraceEnabled())
+ log.trace("Updating SLC execution #"
+ + slcExecutionMsg.getUuid());
+
+ slcExecutionDao.merge(slcExecutionMsg);
+ }
+ }
+
+ public void updateStatus(SlcExecutionStatusRequest msg) {
+ SlcExecution slcExecution = slcExecutionDao.getSlcExecution(msg
+ .getSlcExecutionUuid());
+ if (slcExecution == null)
+ throw new SlcException("Could not find SLC execution #"
+ + msg.getSlcExecutionUuid());
+
+ slcExecution.setStatus(msg.getNewStatus());
+
+ if (log.isTraceEnabled())
+ log.trace("Updating status for SLC execution #"
+ + slcExecution.getUuid());
+
+ slcExecutionDao.update(slcExecution);
+ }
+}
--- /dev/null
+package org.argeo.slc.services.process;
+
+import org.argeo.slc.msg.process.SlcExecutionStatusRequest;
+import org.argeo.slc.process.SlcExecution;
+
+public interface SlcExecutionService {
+ public void newExecution(SlcExecution slcExecutionMsg);
+ public void updateStatus(SlcExecutionStatusRequest msg);
+}
--- /dev/null
+package org.argeo.slc.jms;
+
+import java.util.List;
+
+import javax.jms.Destination;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.UnsupportedException;
+import org.argeo.slc.msg.process.SlcExecutionStatusRequest;
+import org.argeo.slc.process.SlcExecution;
+import org.argeo.slc.process.SlcExecutionNotifier;
+import org.argeo.slc.process.SlcExecutionStep;
+import org.springframework.jms.core.JmsTemplate;
+
+public class JmsSlcExecutionNotifier implements SlcExecutionNotifier {
+
+ private JmsTemplate jmsTemplate;
+
+ private Destination updateStatusDestination;
+
+ public void updateStatus(SlcExecution slcExecution, String oldStatus,
+ String newStatus) {
+ SlcExecutionStatusRequest req = new SlcExecutionStatusRequest(
+ slcExecution.getUuid(), newStatus);
+ jmsTemplate.convertAndSend(updateStatusDestination, req);
+ }
+
+ public void addSteps(SlcExecution slcExecution,
+ List<SlcExecutionStep> additionalSteps) {
+ throw new UnsupportedException();
+ }
+
+ public void newExecution(SlcExecution slcExecution) {
+ throw new UnsupportedException();
+ }
+
+ public void updateExecution(SlcExecution slcExecution) {
+ throw new UnsupportedException();
+ }
+
+ public void setJmsTemplate(JmsTemplate jmsTemplate) {
+ this.jmsTemplate = jmsTemplate;
+ }
+
+ public void setUpdateStatusDestination(Destination updateStatusDestination) {
+ this.updateStatusDestination = updateStatusDestination;
+ }
+
+}
default-lazy-init="false">
<!-- Destinations -->
+
+ <!-- Agent service -->
<bean id="slcJms.destination.agent.register" p:physicalName="agent.register"
parent="slcJms.amTopic" />
<bean id="slcJms.destination.agent.unregister" p:physicalName="agent.unregister"
<bean id="slcJms.destination.agent.newExecution" p:physicalName="agent.newExecution"
parent="slcJms.amTopic" />
+ <!-- Test result service -->
<bean id="slcJms.destination.test.create" p:physicalName="test.create"
parent="slcJms.amTopic" />
<bean id="slcJms.destination.test.addResultPart" p:physicalName="test.addResultPart"
<bean id="slcJms.destination.test.close" p:physicalName="test.close"
parent="slcJms.amTopic" />
+ <!-- TSLC Execution service -->
+ <bean id="slcJms.destination.slcExecution.updateStatus"
+ p:physicalName="slcExecution.updateStatus" parent="slcJms.amTopic" />
+
<!-- Templates -->
<bean id="slcJms.amQueue" class="org.apache.activemq.command.ActiveMQQueue"
abstract="true" />
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
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.ExecutionFlowDescriptor;
import org.argeo.slc.execution.ExecutionModule;
import org.argeo.slc.execution.ExecutionModuleDescriptor;
import org.argeo.slc.execution.ExecutionModulesManager;
import org.argeo.slc.process.RealizedFlow;
import org.argeo.slc.process.SlcExecution;
+import org.argeo.slc.process.SlcExecutionNotifier;
+import org.dbunit.operation.UpdateOperation;
import org.springframework.util.Assert;
public class DefaultModulesManager implements ExecutionModulesManager {
.getLog(DefaultModulesManager.class);
private List<ExecutionModule> executionModules = new ArrayList<ExecutionModule>();
-
- protected ExecutionModule getExecutionModule(String moduleName, String version) {
+ private List<SlcExecutionNotifier> slcExecutionNotifiers = new ArrayList<SlcExecutionNotifier>();
+
+ protected ExecutionModule getExecutionModule(String moduleName,
+ String version) {
for (ExecutionModule moduleT : executionModules) {
if (moduleT.getName().equals(moduleName)) {
- if(moduleT.getVersion().equals(version)) {
+ if (moduleT.getVersion().equals(version)) {
return moduleT;
}
}
}
return null;
}
-
+
public ExecutionModuleDescriptor getExecutionModuleDescriptor(
String moduleName, String version) {
ExecutionModule module = getExecutionModule(moduleName, version);
-
+
Assert.notNull(module);
return module.getDescriptor();
this.executionModules = executionModules;
}
- protected Map<String, Object> convertValues(ExecutionFlowDescriptor executionFlowDescriptor) {
+ protected Map<String, Object> convertValues(
+ ExecutionFlowDescriptor executionFlowDescriptor) {
// convert the values of flow.getFlowDescriptor()
Map<String, Object> values = executionFlowDescriptor.getValues();
-
+
Map<String, Object> convertedValues = new HashMap<String, Object>();
-
- for(String key : values.keySet()) {
+
+ for (String key : values.keySet()) {
Object value = values.get(key);
- if(value instanceof PrimitiveValue) {
+ if (value instanceof PrimitiveValue) {
PrimitiveValue primitiveValue = (PrimitiveValue) value;
- // TODO: check that the class of the the primitiveValue.value matches
+ // TODO: check that the class of the the primitiveValue.value
+ // matches
// the primitiveValue.type
convertedValues.put(key, primitiveValue.getValue());
- }
- else if(value instanceof RefValue) {
+ } else if (value instanceof RefValue) {
RefValue refValue = (RefValue) value;
convertedValues.put(key, refValue.getLabel());
}
- }
+ }
return convertedValues;
}
-
+
public void process(SlcExecution slcExecution) {
- log.info("##\n## Process SLC Execution " + slcExecution+"\n##");
+ log.info("\n##\n## Process SLC Execution " + slcExecution + "\n##\n");
- for(RealizedFlow flow : slcExecution.getRealizedFlows()) {
+ for (RealizedFlow flow : slcExecution.getRealizedFlows()) {
ExecutionModule module = getExecutionModule(flow.getModuleName(),
flow.getModuleVersion());
- if(module != null) {
- ExecutionThread thread = new ExecutionThread(flow.getFlowDescriptor(), module);
+ if (module != null) {
+ ExecutionThread thread = new ExecutionThread(flow
+ .getFlowDescriptor(), module);
thread.start();
- }
- else {
- throw new SlcException("ExecutionModule " + flow.getModuleName() + ", version "
+ } else {
+ throw new SlcException("ExecutionModule "
+ + flow.getModuleName() + ", version "
+ flow.getModuleVersion() + " not found.");
}
}
+
+ slcExecution.setStatus(SlcExecution.STATUS_RUNNING);
+ dispatchUpdateStatus(slcExecution, SlcExecution.STATUS_SCHEDULED,
+ SlcExecution.STATUS_RUNNING);
+ }
+
+ protected void dispatchUpdateStatus(SlcExecution slcExecution,
+ String oldStatus, String newStatus) {
+ for (Iterator<SlcExecutionNotifier> it = slcExecutionNotifiers
+ .iterator(); it.hasNext();) {
+ it.next().updateStatus(slcExecution, oldStatus, newStatus);
+ }
+ }
+
+ public void setSlcExecutionNotifiers(
+ List<SlcExecutionNotifier> slcExecutionNotifiers) {
+ this.slcExecutionNotifiers = slcExecutionNotifiers;
}
private class ExecutionThread extends Thread {
public ExecutionThread(ExecutionFlowDescriptor executionFlowDescriptor,
ExecutionModule executionModule) {
- super("SLC Execution #" /*+ executionContext.getUuid()*/);
+ super("SLC Execution #" /* + executionContext.getUuid() */);
this.executionFlowDescriptor = executionFlowDescriptor;
this.executionModule = executionModule;
}
public void run() {
- ExecutionContext executionContext = executionModule.getExecutionContext();
- executionContext.addVariables(convertValues(executionFlowDescriptor));
+ ExecutionContext executionContext = executionModule
+ .getExecutionContext();
+ executionContext
+ .addVariables(convertValues(executionFlowDescriptor));
try {
executionModule.execute(executionFlowDescriptor);
} catch (Exception e) {
- //TODO: re-throw exception ?
+ // TODO: re-throw exception ?
log.error("Execution " + executionContext.getUuid()
+ " failed.", e);
}
}
- }
+ }
}
log4j.logger.org.argeo.slc.execution.ExecutionParameterPostProcessor=TRACE
log4j.logger.org.argeo.slc.execution.ExecutionContext=DEBUG
log4j.logger.org.argeo.slc.execution.SimpleExecutionSpec=DEBUG
-log4j.logger.org.argeo.slc.services.impl=DEBUG
+log4j.logger.org.argeo.slc.services.impl=TRACE
log4j.logger.org.springframework=WARN
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
- xsi:schemaLocation="http://www.springframework.org/schema/osgi \r
- http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
- http://www.springframework.org/schema/beans \r
- http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
-\r
- <service interface="org.argeo.slc.dao.test.tree.TreeTestResultDao"\r
- ref="testResultDao" />\r
- <service interface="org.argeo.slc.dao.test.tree.TreeTestResultCollectionDao"\r
- ref="testResultCollectionDao" />\r
- <service interface="org.argeo.slc.dao.test.TestRunDescriptorDao"\r
- ref="testRunDescriptorDao" />\r
- <service interface="org.argeo.slc.dao.process.SlcExecutionDao"\r
- ref="slcExecutionDao" />\r
- <service interface="org.argeo.slc.dao.runtime.SlcAgentDescriptorDao"\r
- ref="slcAgentDescriptorDao" />\r
- <service ref="transactionManager"\r
- interface="org.springframework.transaction.PlatformTransactionManager" />\r
-\r
- <reference id="sessionFactory" interface="org.hibernate.SessionFactory" />\r
-\r
-\r
+<?xml version="1.0" encoding="UTF-8"?>
+<beans:beans xmlns="http://www.springframework.org/schema/osgi"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
+ xsi:schemaLocation="http://www.springframework.org/schema/osgi
+ http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+
+ <service ref="transactionManager"
+ interface="org.springframework.transaction.PlatformTransactionManager" />
+
+
</beans:beans>
\ No newline at end of file
<reference id="agentService" interface="org.argeo.slc.services.runtime.AgentService" />
<reference id="testManagerService"
interface="org.argeo.slc.services.test.TestManagerService" />
+ <reference id="slcExecutionService"
+ interface="org.argeo.slc.services.process.SlcExecutionService" />
<reference id="jmsConnectionFactory" interface="javax.jms.ConnectionFactory" />
</property>
</bean>
+ <!-- SLC Execution Service -->
+ <bean parent="listenerContainer">
+ <property name="destination" ref="slcJms.destination.agent.newExecution" />
+ <property name="messageListener">
+ <bean parent="listenerAdapterCastor">
+ <constructor-arg ref="slcExecutionService" />
+ <property name="defaultListenerMethod" value="newExecution" />
+ </bean>
+ </property>
+ </bean>
+
+ <bean parent="listenerContainer">
+ <property name="destination" ref="slcJms.destination.slcExecution.updateStatus" />
+ <property name="messageListener">
+ <bean parent="listenerAdapterCastor">
+ <constructor-arg ref="slcExecutionService" />
+ <property name="defaultListenerMethod" value="updateStatus" />
+ </bean>
+ </property>
+ </bean>
+
<!-- Templates -->
<bean id="listenerContainer"
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
- xsi:schemaLocation="http://www.springframework.org/schema/osgi \r
- http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
- http://www.springframework.org/schema/beans \r
- http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
-\r
- <service ref="testManagerService" interface="org.argeo.slc.services.test.TestManagerService" />\r
- <service ref="agentService" interface="org.argeo.slc.services.runtime.AgentService" />\r
-\r
- <reference interface="org.argeo.slc.dao.test.tree.TreeTestResultDao"\r
- id="testResultDao" />\r
- <reference interface="org.argeo.slc.dao.test.tree.TreeTestResultCollectionDao"\r
- id="testResultCollectionDao" />\r
- <reference interface="org.argeo.slc.dao.test.TestRunDescriptorDao"\r
- id="testRunDescriptorDao" />\r
- <reference interface="org.argeo.slc.dao.process.SlcExecutionDao"\r
- id="slcExecutionDao" />\r
- <reference interface="org.argeo.slc.dao.runtime.SlcAgentDescriptorDao"\r
- id="slcAgentDescriptorDao" />\r
-\r
- <reference id="transactionManager"\r
- interface="org.springframework.transaction.PlatformTransactionManager" />\r
-\r
+<?xml version="1.0" encoding="UTF-8"?>
+<beans:beans xmlns="http://www.springframework.org/schema/osgi"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
+ xsi:schemaLocation="http://www.springframework.org/schema/osgi
+ http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+ <service ref="testManagerService" interface="org.argeo.slc.services.test.TestManagerService" />
+ <service ref="agentService" interface="org.argeo.slc.services.runtime.AgentService" />
+ <service ref="slcExecutionService"
+ interface="org.argeo.slc.services.process.SlcExecutionService" />
+
+ <reference interface="org.argeo.slc.dao.test.tree.TreeTestResultDao"
+ id="testResultDao" />
+ <reference interface="org.argeo.slc.dao.test.tree.TreeTestResultCollectionDao"
+ id="testResultCollectionDao" />
+ <reference interface="org.argeo.slc.dao.test.TestRunDescriptorDao"
+ id="testRunDescriptorDao" />
+ <reference interface="org.argeo.slc.dao.process.SlcExecutionDao"
+ id="slcExecutionDao" />
+ <reference interface="org.argeo.slc.dao.runtime.SlcAgentDescriptorDao"
+ id="slcAgentDescriptorDao" />
+
+ <reference id="transactionManager"
+ interface="org.springframework.transaction.PlatformTransactionManager" />
+
</beans:beans>
\ No newline at end of file
<constructor-arg ref="slcAgentDescriptorDao" />
</bean>
+ <bean id="slcExecutionService" class="org.argeo.slc.services.impl.process.SlcExecutionServiceImpl">
+ <constructor-arg ref="slcExecutionDao" />
+ </bean>
+
<!-- Services transactions -->
<aop:config>
<aop:pointcut id="serviceMethods"