From 237c2da124703a91c64cf0106d293f77821010e1 Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Wed, 25 Feb 2009 10:56:34 +0000 Subject: [PATCH] ActiveMQ and Castor integration git-svn-id: https://svn.argeo.org/slc/trunk@2172 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- demo/org.argeo.slc.demo.basic/pom.xml | 25 ++-- .../{conf => }/BasicExecutionFlow.groovy | 0 .../src/main/resources/META-INF/MANIFEST.MF | 20 --- .../src/main/resources/conf/basic.xml | 2 +- .../src/main/resources/conf/imports.xml | 9 ++ .../src/main/resources/conf/main.xml | 38 +----- .../src/main/resources/conf/osgi.xml | 11 ++ .../main/resources/{conf => }/slc.properties | 0 .../src/main/resources/{conf => }/test.xml | 0 demo/org.argeo.slc.demo.manager/.classpath | 1 + demo/org.argeo.slc.demo.manager/.project | 2 +- demo/org.argeo.slc.demo.manager/.springBeans | 2 + demo/org.argeo.slc.demo.manager/pom.xml | 70 ++++++++-- .../src/main/resources/META-INF/MANIFEST.MF | 20 --- .../resources/conf/BasicExecutionFlow.groovy | 12 -- .../src/main/resources/conf/basic.xml | 85 ------------ .../src/main/resources/conf/common.xml | 19 --- .../src/main/resources/conf/jms.xml | 48 +++++++ .../src/main/resources/conf/main.xml | 75 ----------- .../src/main/resources/conf/manager-osgi.xml | 10 ++ .../src/main/resources/conf/manager.xml | 38 ++++++ .../src/main/resources/conf/slc.properties | 16 --- .../src/main/resources/conf/test.xml | 105 --------------- .../resources/conf/testCases/basic-001.xml | 35 ----- .../resources/conf/testCases/basic-002.xml | 25 ---- .../argeo/slc/demo/manager/JmsTesting.java | 57 ++++++++ org.argeo.slc/pom.xml | 16 ++- runtime/org.argeo.slc.execution/.classpath | 1 + runtime/org.argeo.slc.execution/pom.xml | 9 ++ ...ava => AbstractSpringExecutionModule.java} | 15 +-- .../execution/ExecutionCommandProvider.java | 46 +++++++ .../argeo/slc/execution/ExecutionContext.java | 4 +- .../argeo/slc/execution/ExecutionModule.java | 13 ++ .../execution/ExecutionModuleDescriptor.java | 18 +++ .../argeo/slc/execution/ModulesManager.java | 31 +++++ .../slc/execution/OsgiExecutionModule.java | 23 ++++ .../argeo/slc/execution/RefSpecAttribute.java | 9 +- .../slc/execution/SimpleExecutionFlow.java | 1 + .../main/resources/META-INF/spring/osgi.xml | 16 +++ .../org/argeo/slc/execution/spring.xml | 30 +++++ .../jms/ServiceMessageListenerAdapter.java | 125 ++++++++++++++++++ .../org/argeo/slc/activemq/spring.xml | 7 +- runtime/org.argeo.slc.support.castor/pom.xml | 19 ++- .../org/argeo/slc/castor/execution.xml | 92 +++++++++++++ .../resources/org/argeo/slc/castor/spring.xml | 3 + 45 files changed, 715 insertions(+), 488 deletions(-) rename demo/org.argeo.slc.demo.basic/src/main/resources/{conf => }/BasicExecutionFlow.groovy (100%) delete mode 100644 demo/org.argeo.slc.demo.basic/src/main/resources/META-INF/MANIFEST.MF create mode 100644 demo/org.argeo.slc.demo.basic/src/main/resources/conf/imports.xml create mode 100644 demo/org.argeo.slc.demo.basic/src/main/resources/conf/osgi.xml rename demo/org.argeo.slc.demo.basic/src/main/resources/{conf => }/slc.properties (100%) rename demo/org.argeo.slc.demo.basic/src/main/resources/{conf => }/test.xml (100%) delete mode 100644 demo/org.argeo.slc.demo.manager/src/main/resources/META-INF/MANIFEST.MF delete mode 100644 demo/org.argeo.slc.demo.manager/src/main/resources/conf/BasicExecutionFlow.groovy delete mode 100644 demo/org.argeo.slc.demo.manager/src/main/resources/conf/basic.xml delete mode 100644 demo/org.argeo.slc.demo.manager/src/main/resources/conf/common.xml create mode 100644 demo/org.argeo.slc.demo.manager/src/main/resources/conf/jms.xml delete mode 100644 demo/org.argeo.slc.demo.manager/src/main/resources/conf/main.xml create mode 100644 demo/org.argeo.slc.demo.manager/src/main/resources/conf/manager-osgi.xml create mode 100644 demo/org.argeo.slc.demo.manager/src/main/resources/conf/manager.xml delete mode 100644 demo/org.argeo.slc.demo.manager/src/main/resources/conf/slc.properties delete mode 100644 demo/org.argeo.slc.demo.manager/src/main/resources/conf/test.xml delete mode 100644 demo/org.argeo.slc.demo.manager/src/main/resources/conf/testCases/basic-001.xml delete mode 100644 demo/org.argeo.slc.demo.manager/src/main/resources/conf/testCases/basic-002.xml create mode 100644 demo/org.argeo.slc.demo.manager/src/test/java/org/argeo/slc/demo/manager/JmsTesting.java rename runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/{ExecutionRegister.java => AbstractSpringExecutionModule.java} (82%) create mode 100644 runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/ExecutionCommandProvider.java create mode 100644 runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/ExecutionModule.java create mode 100644 runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/ModulesManager.java create mode 100644 runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/OsgiExecutionModule.java create mode 100644 runtime/org.argeo.slc.execution/src/main/resources/META-INF/spring/osgi.xml create mode 100644 runtime/org.argeo.slc.execution/src/main/resources/org/argeo/slc/execution/spring.xml create mode 100644 runtime/org.argeo.slc.support.activemq/src/main/java/org/argeo/slc/jms/ServiceMessageListenerAdapter.java create mode 100644 runtime/org.argeo.slc.support.castor/src/main/resources/org/argeo/slc/castor/execution.xml diff --git a/demo/org.argeo.slc.demo.basic/pom.xml b/demo/org.argeo.slc.demo.basic/pom.xml index 33d29dd73..27ba7f0d3 100644 --- a/demo/org.argeo.slc.demo.basic/pom.xml +++ b/demo/org.argeo.slc.demo.basic/pom.xml @@ -25,9 +25,17 @@ org.apache.commons.logging,org.springframework.beans.factory.config org.argeo.slc.execution,org.argeo.slc.specs,org.argeo.slc.support.simple,org.springframework.aop,com.springsource.net.sf.cglib,com.springsource.org.aopalliance - conf/main.xml + conf/*,conf/testCases/* + + + + manifest + + resources + + @@ -41,20 +49,5 @@ org.argeo.slc.runtime org.argeo.slc.support.simple - - org.argeo.slc - org.argeo.slc.detached.launcher - ${project.version} - - - - org.eclipse.osgi - org.eclipse.osgi - - - - org.springframework.osgi - org.springframework.osgi.extender - diff --git a/demo/org.argeo.slc.demo.basic/src/main/resources/conf/BasicExecutionFlow.groovy b/demo/org.argeo.slc.demo.basic/src/main/resources/BasicExecutionFlow.groovy similarity index 100% rename from demo/org.argeo.slc.demo.basic/src/main/resources/conf/BasicExecutionFlow.groovy rename to demo/org.argeo.slc.demo.basic/src/main/resources/BasicExecutionFlow.groovy diff --git a/demo/org.argeo.slc.demo.basic/src/main/resources/META-INF/MANIFEST.MF b/demo/org.argeo.slc.demo.basic/src/main/resources/META-INF/MANIFEST.MF deleted file mode 100644 index d0c3f3df7..000000000 --- a/demo/org.argeo.slc.demo.basic/src/main/resources/META-INF/MANIFEST.MF +++ /dev/null @@ -1,20 +0,0 @@ -Manifest-Version: 1.0 -Private-Package: conf;version="0.11.3-SNAPSHOT",conf.testCases;version - ="0.11.3-SNAPSHOT" -Tool: Bnd-0.0.255 -Bundle-Name: SLC Sandbox Execution Flow -Created-By: 1.6.0_0 (Sun Microsystems Inc.) -Require-Bundle: org.argeo.slc.execution,org.argeo.slc.specs,org.argeo. - slc.support.simple,org.springframework.aop,com.springsource.net.sf.cg - lib,com.springsource.org.aopalliance -Bundle-Vendor: Argeo -Bundle-Version: 0.11.3.SNAPSHOT -Spring-Context: conf/main.xml -Bundle-ManifestVersion: 2 -Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt -Import-Package: org.apache.commons.logging;version="1.1",org.springfra - mework.beans.factory.config -Bundle-SymbolicName: org.argeo.slc.sandbox.executionflow -Bundle-DocURL: http://www.argeo.org -Originally-Created-By: 1.6.0_0 (Sun Microsystems Inc.) - diff --git a/demo/org.argeo.slc.demo.basic/src/main/resources/conf/basic.xml b/demo/org.argeo.slc.demo.basic/src/main/resources/conf/basic.xml index c2077f50f..1ec671cb4 100644 --- a/demo/org.argeo.slc.demo.basic/src/main/resources/conf/basic.xml +++ b/demo/org.argeo.slc.demo.basic/src/main/resources/conf/basic.xml @@ -11,7 +11,7 @@ - + diff --git a/demo/org.argeo.slc.demo.basic/src/main/resources/conf/imports.xml b/demo/org.argeo.slc.demo.basic/src/main/resources/conf/imports.xml new file mode 100644 index 000000000..2a7fc71b1 --- /dev/null +++ b/demo/org.argeo.slc.demo.basic/src/main/resources/conf/imports.xml @@ -0,0 +1,9 @@ + + + + + + \ No newline at end of file diff --git a/demo/org.argeo.slc.demo.basic/src/main/resources/conf/main.xml b/demo/org.argeo.slc.demo.basic/src/main/resources/conf/main.xml index aab3785e2..b57522999 100644 --- a/demo/org.argeo.slc.demo.basic/src/main/resources/conf/main.xml +++ b/demo/org.argeo.slc.demo.basic/src/main/resources/conf/main.xml @@ -1,21 +1,18 @@ - - - - - - + + + @@ -49,27 +46,4 @@ abstract="true"> - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/demo/org.argeo.slc.demo.basic/src/main/resources/conf/osgi.xml b/demo/org.argeo.slc.demo.basic/src/main/resources/conf/osgi.xml new file mode 100644 index 000000000..ebc3364ba --- /dev/null +++ b/demo/org.argeo.slc.demo.basic/src/main/resources/conf/osgi.xml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/demo/org.argeo.slc.demo.basic/src/main/resources/conf/slc.properties b/demo/org.argeo.slc.demo.basic/src/main/resources/slc.properties similarity index 100% rename from demo/org.argeo.slc.demo.basic/src/main/resources/conf/slc.properties rename to demo/org.argeo.slc.demo.basic/src/main/resources/slc.properties diff --git a/demo/org.argeo.slc.demo.basic/src/main/resources/conf/test.xml b/demo/org.argeo.slc.demo.basic/src/main/resources/test.xml similarity index 100% rename from demo/org.argeo.slc.demo.basic/src/main/resources/conf/test.xml rename to demo/org.argeo.slc.demo.basic/src/main/resources/test.xml diff --git a/demo/org.argeo.slc.demo.manager/.classpath b/demo/org.argeo.slc.demo.manager/.classpath index df54f154b..b5ef387af 100644 --- a/demo/org.argeo.slc.demo.manager/.classpath +++ b/demo/org.argeo.slc.demo.manager/.classpath @@ -1,6 +1,7 @@ + diff --git a/demo/org.argeo.slc.demo.manager/.project b/demo/org.argeo.slc.demo.manager/.project index 6a65410fd..ffa5f4ca3 100644 --- a/demo/org.argeo.slc.demo.manager/.project +++ b/demo/org.argeo.slc.demo.manager/.project @@ -1,6 +1,6 @@ - org.argeo.slc.demo.basic + org.argeo.slc.demo.manager diff --git a/demo/org.argeo.slc.demo.manager/.springBeans b/demo/org.argeo.slc.demo.manager/.springBeans index c11d81486..2732929fe 100644 --- a/demo/org.argeo.slc.demo.manager/.springBeans +++ b/demo/org.argeo.slc.demo.manager/.springBeans @@ -7,6 +7,8 @@ + src/main/resources/conf/manager-osgi.xml + src/main/resources/conf/manager.xml diff --git a/demo/org.argeo.slc.demo.manager/pom.xml b/demo/org.argeo.slc.demo.manager/pom.xml index 33d29dd73..d1b8d37d0 100644 --- a/demo/org.argeo.slc.demo.manager/pom.xml +++ b/demo/org.argeo.slc.demo.manager/pom.xml @@ -8,15 +8,12 @@ ../../org.argeo.slc org.argeo.slc.demo - org.argeo.slc.demo.basic - SLC Demo Basic Test Module - jar + org.argeo.slc.demo.manager + SLC Demo Manager + bundle - - maven-jar-plugin - org.apache.felix maven-bundle-plugin @@ -24,8 +21,27 @@ org.apache.commons.logging,org.springframework.beans.factory.config - org.argeo.slc.execution,org.argeo.slc.specs,org.argeo.slc.support.simple,org.springframework.aop,com.springsource.net.sf.cglib,com.springsource.org.aopalliance - conf/main.xml + org.springframework.jms,com.springsource.org.castor,com.springsource.org.apache.xbean.spring,com.springsource.org.apache.activemq,org.argeo.slc.execution,org.argeo.slc.support.activemq,org.argeo.slc.specs,org.argeo.slc.support.simple,org.springframework.aop,org.springframework.oxm,com.springsource.net.sf.cglib,com.springsource.org.aopalliance + conf/* + + @@ -39,8 +55,43 @@ org.argeo.slc.runtime - org.argeo.slc.support.simple + org.argeo.slc.support.activemq + + + org.argeo.slc.runtime + org.argeo.slc.support.castor + + + + org.codehaus.castor + com.springsource.org.castor + + + + javax.ejb + com.springsource.javax.ejb + 3.0.0 + + + javax.xml.rpc + com.springsource.javax.xml.rpc + 1.1.0 + + javax.xml.soap + com.springsource.javax.xml.soap + 1.3.0 + + + javax.activation + com.springsource.javax.activation + 1.1.1 + + + javax.servlet + com.springsource.javax.servlet + + org.argeo.slc org.argeo.slc.detached.launcher @@ -56,5 +107,6 @@ org.springframework.osgi org.springframework.osgi.extender + diff --git a/demo/org.argeo.slc.demo.manager/src/main/resources/META-INF/MANIFEST.MF b/demo/org.argeo.slc.demo.manager/src/main/resources/META-INF/MANIFEST.MF deleted file mode 100644 index d0c3f3df7..000000000 --- a/demo/org.argeo.slc.demo.manager/src/main/resources/META-INF/MANIFEST.MF +++ /dev/null @@ -1,20 +0,0 @@ -Manifest-Version: 1.0 -Private-Package: conf;version="0.11.3-SNAPSHOT",conf.testCases;version - ="0.11.3-SNAPSHOT" -Tool: Bnd-0.0.255 -Bundle-Name: SLC Sandbox Execution Flow -Created-By: 1.6.0_0 (Sun Microsystems Inc.) -Require-Bundle: org.argeo.slc.execution,org.argeo.slc.specs,org.argeo. - slc.support.simple,org.springframework.aop,com.springsource.net.sf.cg - lib,com.springsource.org.aopalliance -Bundle-Vendor: Argeo -Bundle-Version: 0.11.3.SNAPSHOT -Spring-Context: conf/main.xml -Bundle-ManifestVersion: 2 -Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt -Import-Package: org.apache.commons.logging;version="1.1",org.springfra - mework.beans.factory.config -Bundle-SymbolicName: org.argeo.slc.sandbox.executionflow -Bundle-DocURL: http://www.argeo.org -Originally-Created-By: 1.6.0_0 (Sun Microsystems Inc.) - diff --git a/demo/org.argeo.slc.demo.manager/src/main/resources/conf/BasicExecutionFlow.groovy b/demo/org.argeo.slc.demo.manager/src/main/resources/conf/BasicExecutionFlow.groovy deleted file mode 100644 index da3926ef8..000000000 --- a/demo/org.argeo.slc.demo.manager/src/main/resources/conf/BasicExecutionFlow.groovy +++ /dev/null @@ -1,12 +0,0 @@ -import org.argeo.slc.test.*; - -public class BasicExecutionFlow implements org.argeo.slc.executionflow.ExecutionFlow { - - ExecutableTestRun firstSubTest = null; - ExecutableTestRun secondSubTest = null; - - void execute(){ - firstSubTest?.execute(); - secondSubTest?.execute(); - } -} diff --git a/demo/org.argeo.slc.demo.manager/src/main/resources/conf/basic.xml b/demo/org.argeo.slc.demo.manager/src/main/resources/conf/basic.xml deleted file mode 100644 index c2077f50f..000000000 --- a/demo/org.argeo.slc.demo.manager/src/main/resources/conf/basic.xml +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/demo/org.argeo.slc.demo.manager/src/main/resources/conf/common.xml b/demo/org.argeo.slc.demo.manager/src/main/resources/conf/common.xml deleted file mode 100644 index 4495b2f83..000000000 --- a/demo/org.argeo.slc.demo.manager/src/main/resources/conf/common.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/demo/org.argeo.slc.demo.manager/src/main/resources/conf/jms.xml b/demo/org.argeo.slc.demo.manager/src/main/resources/conf/jms.xml new file mode 100644 index 000000000..b5a323d48 --- /dev/null +++ b/demo/org.argeo.slc.demo.manager/src/main/resources/conf/jms.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + tcp://localhost:61616 + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/demo/org.argeo.slc.demo.manager/src/main/resources/conf/main.xml b/demo/org.argeo.slc.demo.manager/src/main/resources/conf/main.xml deleted file mode 100644 index aab3785e2..000000000 --- a/demo/org.argeo.slc.demo.manager/src/main/resources/conf/main.xml +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/demo/org.argeo.slc.demo.manager/src/main/resources/conf/manager-osgi.xml b/demo/org.argeo.slc.demo.manager/src/main/resources/conf/manager-osgi.xml new file mode 100644 index 000000000..a37132e76 --- /dev/null +++ b/demo/org.argeo.slc.demo.manager/src/main/resources/conf/manager-osgi.xml @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file diff --git a/demo/org.argeo.slc.demo.manager/src/main/resources/conf/manager.xml b/demo/org.argeo.slc.demo.manager/src/main/resources/conf/manager.xml new file mode 100644 index 000000000..3c3a27838 --- /dev/null +++ b/demo/org.argeo.slc.demo.manager/src/main/resources/conf/manager.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + name + version + + + + + + + + + + + + + \ No newline at end of file diff --git a/demo/org.argeo.slc.demo.manager/src/main/resources/conf/slc.properties b/demo/org.argeo.slc.demo.manager/src/main/resources/conf/slc.properties deleted file mode 100644 index b18dce171..000000000 --- a/demo/org.argeo.slc.demo.manager/src/main/resources/conf/slc.properties +++ /dev/null @@ -1,16 +0,0 @@ -log4j.rootLogger=WARN, console - -## Levels -log4j.logger.org.argeo=DEBUG -log4j.logger.org.argeo.slc.executionflow.ExecutionParameterPostProcessor=TRACE -log4j.logger.org.argeo.slc.executionflow.ExecutionContext=TRACE - -## Appenders -# console is set to be a ConsoleAppender. -log4j.appender.console=org.apache.log4j.ConsoleAppender - -# console uses PatternLayout. -log4j.appender.console.layout=org.apache.log4j.PatternLayout -log4j.appender.console.layout.ConversionPattern= %-5p %d{ISO8601} %m - %c%n - -testCase=002 \ No newline at end of file diff --git a/demo/org.argeo.slc.demo.manager/src/main/resources/conf/test.xml b/demo/org.argeo.slc.demo.manager/src/main/resources/conf/test.xml deleted file mode 100644 index 6cc40e80e..000000000 --- a/demo/org.argeo.slc.demo.manager/src/main/resources/conf/test.xml +++ /dev/null @@ -1,105 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/demo/org.argeo.slc.demo.manager/src/main/resources/conf/testCases/basic-001.xml b/demo/org.argeo.slc.demo.manager/src/main/resources/conf/testCases/basic-001.xml deleted file mode 100644 index a5426649e..000000000 --- a/demo/org.argeo.slc.demo.manager/src/main/resources/conf/testCases/basic-001.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/demo/org.argeo.slc.demo.manager/src/main/resources/conf/testCases/basic-002.xml b/demo/org.argeo.slc.demo.manager/src/main/resources/conf/testCases/basic-002.xml deleted file mode 100644 index c2946fdfb..000000000 --- a/demo/org.argeo.slc.demo.manager/src/main/resources/conf/testCases/basic-002.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/demo/org.argeo.slc.demo.manager/src/test/java/org/argeo/slc/demo/manager/JmsTesting.java b/demo/org.argeo.slc.demo.manager/src/test/java/org/argeo/slc/demo/manager/JmsTesting.java new file mode 100644 index 000000000..50ea47e34 --- /dev/null +++ b/demo/org.argeo.slc.demo.manager/src/test/java/org/argeo/slc/demo/manager/JmsTesting.java @@ -0,0 +1,57 @@ +package org.argeo.slc.demo.manager; + +import javax.jms.ConnectionFactory; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.Session; +import javax.jms.TextMessage; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.xbean.spring.context.ClassPathXmlApplicationContext; +import org.springframework.beans.BeansException; +import org.springframework.jms.JmsException; +import org.springframework.jms.core.JmsTemplate; +import org.springframework.jms.core.MessageCreator; + +public class JmsTesting { + private final static Log log = LogFactory.getLog(JmsTesting.class); + + /** + * @param args + */ + public static void main(String[] args) { + ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext( + "conf/jms.xml"); + try { + + ConnectionFactory connectionFactory = (ConnectionFactory) applicationContext + .getBean("slcDefault.jms.connectionFactory"); + JmsTemplate jmsTemplate = new JmsTemplate(connectionFactory); + + jmsTemplate.send("modulesManager.request", new MessageCreator() { + + public Message createMessage(Session session) + throws JMSException { + TextMessage message = session.createTextMessage(); + message.setStringProperty("action", + "getExecutionModuleDescriptor"); + message.setStringProperty("name", + "org.argeo.slc.demo.basic"); + message.setStringProperty("version", "LATEST"); + return message; + } + }); + + TextMessage message = (TextMessage) jmsTemplate + .receive("modulesManager.response"); + log.info("Received message: " + message.getText() + "\n"); + + } catch (Exception e) { + e.printStackTrace(); + } finally { + applicationContext.close(); + } + } + +} diff --git a/org.argeo.slc/pom.xml b/org.argeo.slc/pom.xml index f6092a1ff..33b4d3afd 100644 --- a/org.argeo.slc/pom.xml +++ b/org.argeo.slc/pom.xml @@ -12,6 +12,7 @@ 2.5.6.A 1.5.5.A + 1.1.3.RELEASE 2.0.9 1.7.0 6.1.14 @@ -48,7 +49,7 @@ 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. ]]> - + @@ -469,7 +470,12 @@ limitations under the License. org.springframework.osgi org.springframework.osgi.extender - 1.1.2.B + ${version.spring-osgi} + + + org.springframework.osgi + org.springframework.osgi.core + ${version.spring-osgi} @@ -749,7 +755,8 @@ limitations under the License. com.springsource.repository.bundles.release SpringSource Enterprise Bundle Repository - SpringSource - Bundle Releases + Bundle + Releases http://repository.springsource.com/maven/bundles/release @@ -769,7 +776,8 @@ limitations under the License. com.springsource.repository.bundles.external SpringSource Enterprise Bundle Repository - External - Bundle Releases + Bundle + Releases http://repository.springsource.com/maven/bundles/external diff --git a/runtime/org.argeo.slc.execution/.classpath b/runtime/org.argeo.slc.execution/.classpath index 16f01e2ee..30baf1326 100644 --- a/runtime/org.argeo.slc.execution/.classpath +++ b/runtime/org.argeo.slc.execution/.classpath @@ -1,6 +1,7 @@ + diff --git a/runtime/org.argeo.slc.execution/pom.xml b/runtime/org.argeo.slc.execution/pom.xml index 4fc28d3f1..a56307711 100644 --- a/runtime/org.argeo.slc.execution/pom.xml +++ b/runtime/org.argeo.slc.execution/pom.xml @@ -39,6 +39,15 @@ org.argeo.slc.support.simple + + org.eclipse.osgi + org.eclipse.osgi + + + org.springframework.osgi + org.springframework.osgi.core + + org.aspectj com.springsource.org.aspectj.runtime diff --git a/runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/ExecutionRegister.java b/runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/AbstractSpringExecutionModule.java similarity index 82% rename from runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/ExecutionRegister.java rename to runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/AbstractSpringExecutionModule.java index 957addee1..c39343b96 100644 --- a/runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/ExecutionRegister.java +++ b/runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/AbstractSpringExecutionModule.java @@ -3,23 +3,21 @@ package org.argeo.slc.execution; import java.util.HashMap; import java.util.Map; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.argeo.slc.process.SlcExecution; import org.springframework.beans.BeansException; -import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.generic.GenericBeanFactoryAccessor; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.util.Assert; -public class ExecutionRegister implements InitializingBean, +public abstract class AbstractSpringExecutionModule implements ExecutionModule, ApplicationContextAware { - private final static Log log = LogFactory.getLog(ExecutionRegister.class); - private ApplicationContext applicationContext; public ExecutionModuleDescriptor getDescriptor() { ExecutionModuleDescriptor md = new ExecutionModuleDescriptor(); + md.setName(getName()); + md.setVersion(getVersion()); GenericBeanFactoryAccessor accessor = new GenericBeanFactoryAccessor( applicationContext); @@ -57,8 +55,9 @@ public class ExecutionRegister implements InitializingBean, return md; } - public void afterPropertiesSet() throws Exception { - log.debug("Execution Module Descriptor:\n" + getDescriptor()); + public void execute(SlcExecution slcExecution) { + applicationContext.publishEvent(new NewExecutionEvent(this, + slcExecution)); } public void setApplicationContext(ApplicationContext applicationContext) diff --git a/runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/ExecutionCommandProvider.java b/runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/ExecutionCommandProvider.java new file mode 100644 index 000000000..ad71a4d61 --- /dev/null +++ b/runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/ExecutionCommandProvider.java @@ -0,0 +1,46 @@ +package org.argeo.slc.execution; + +import java.util.List; + +import org.argeo.slc.process.SlcExecution; +import org.eclipse.osgi.framework.console.CommandInterpreter; +import org.eclipse.osgi.framework.console.CommandProvider; + +public class ExecutionCommandProvider implements CommandProvider { + private List executionModules; + + public Object _slc_execute(CommandInterpreter ci) { + String moduleName = ci.nextArgument(); + String executionName = ci.nextArgument(); + + SlcExecution slcExecution = new SlcExecution(); + slcExecution.getAttributes().put("slc.flows", executionName); + + ExecutionModule module = null; + for (ExecutionModule moduleT : executionModules) { + if(moduleT.getName().equals(moduleName)){ + // TODO: check version + module = moduleT; + break; + } + } + + if(module!=null) + module.execute(slcExecution); + + return null; + } + + public String getHelp() { + StringBuffer buf = new StringBuffer(); + buf.append("---SLC Execution Commands---\n"); + buf.append("\tslc_execute - Execute an execution flow\n"); + return buf.toString(); + + } + + public void setExecutionModules(List executionModules) { + this.executionModules = executionModules; + } + +} diff --git a/runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/ExecutionContext.java b/runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/ExecutionContext.java index cd2baa3da..c6d8e2c33 100644 --- a/runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/ExecutionContext.java +++ b/runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/ExecutionContext.java @@ -52,7 +52,7 @@ public class ExecutionContext { ExecutionFlowRuntime runtime = new ExecutionFlowRuntime(executionFlow); stack.push(runtime); - if (log.isTraceEnabled()) + if (log.isDebugEnabled()) log.debug(depthSpaces(stack.size()) + "=> " + executionFlow + " #" + getCurrentStackUuid() + ", depth=" + stack.size()); @@ -105,7 +105,7 @@ public class ExecutionContext { public static void leaveFlow(ExecutionFlow executionFlow) { Stack stack = executionContext.get().stack; - if (log.isTraceEnabled()) + if (log.isDebugEnabled()) log.debug(depthSpaces(stack.size()) + "<= " + executionFlow + " #" + getCurrentStackUuid() + ", depth=" + stack.size()); diff --git a/runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/ExecutionModule.java b/runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/ExecutionModule.java new file mode 100644 index 000000000..9be149475 --- /dev/null +++ b/runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/ExecutionModule.java @@ -0,0 +1,13 @@ +package org.argeo.slc.execution; + +import org.argeo.slc.process.SlcExecution; + +public interface ExecutionModule { + public String getName(); + + public String getVersion(); + + public ExecutionModuleDescriptor getDescriptor(); + + public void execute(SlcExecution slcExecution); +} diff --git a/runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/ExecutionModuleDescriptor.java b/runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/ExecutionModuleDescriptor.java index 548eb112c..e87a14e4a 100644 --- a/runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/ExecutionModuleDescriptor.java +++ b/runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/ExecutionModuleDescriptor.java @@ -4,6 +4,8 @@ import java.util.ArrayList; import java.util.List; public class ExecutionModuleDescriptor { + private String name; + private String version; private List executionSpecs = new ArrayList(); private List executionFlows = new ArrayList(); @@ -23,4 +25,20 @@ public class ExecutionModuleDescriptor { this.executionFlows = executionFlows; } + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + } diff --git a/runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/ModulesManager.java b/runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/ModulesManager.java new file mode 100644 index 000000000..4dd262301 --- /dev/null +++ b/runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/ModulesManager.java @@ -0,0 +1,31 @@ +package org.argeo.slc.execution; + +import java.util.ArrayList; +import java.util.List; + +import org.springframework.util.Assert; + +public class ModulesManager { + private List executionModules = new ArrayList(); + + public ExecutionModuleDescriptor getExecutionModuleDescriptor( + String moduleName, String version) { + ExecutionModule module = null; + for (ExecutionModule moduleT : executionModules) { + if(moduleT.getName().equals(moduleName)){ + // TODO: check version + module = moduleT; + break; + } + } + + Assert.notNull(module); + + return module.getDescriptor(); + } + + public void setExecutionModules(List executionModules) { + this.executionModules = executionModules; + } + +} diff --git a/runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/OsgiExecutionModule.java b/runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/OsgiExecutionModule.java new file mode 100644 index 000000000..570635ec6 --- /dev/null +++ b/runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/OsgiExecutionModule.java @@ -0,0 +1,23 @@ +package org.argeo.slc.execution; + +import org.osgi.framework.BundleContext; +import org.springframework.osgi.context.BundleContextAware; + +public class OsgiExecutionModule extends AbstractSpringExecutionModule implements + BundleContextAware { + private BundleContext bundleContext; + + public String getName() { + return bundleContext.getBundle().getSymbolicName(); + } + + public String getVersion() { + return bundleContext.getBundle().getHeaders().get("Bundle-Version") + .toString(); + } + + public void setBundleContext(BundleContext bundleContext) { + this.bundleContext = bundleContext; + } + +} diff --git a/runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/RefSpecAttribute.java b/runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/RefSpecAttribute.java index 9b0ea6d3c..e9ce3ef17 100644 --- a/runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/RefSpecAttribute.java +++ b/runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/RefSpecAttribute.java @@ -1,7 +1,9 @@ package org.argeo.slc.execution; -public class RefSpecAttribute extends AbstractSpecAttribute { +public class RefSpecAttribute extends AbstractSpecAttribute { private Class targetClass; + /** Read only. */ + private String targetClassName; private Object value = null; public Object getValue() { @@ -18,6 +20,11 @@ public class RefSpecAttribute extends AbstractSpecAttribute { public void setTargetClass(Class targetClass) { this.targetClass = targetClass; + this.targetClassName = targetClass.getName(); + } + + public String getTargetClassName() { + return targetClassName; } } diff --git a/runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/SimpleExecutionFlow.java b/runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/SimpleExecutionFlow.java index 53114291f..79f900d02 100644 --- a/runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/SimpleExecutionFlow.java +++ b/runtime/org.argeo.slc.execution/src/main/java/org/argeo/slc/execution/SimpleExecutionFlow.java @@ -55,6 +55,7 @@ public class SimpleExecutionFlow implements ExecutionFlow, InitializingBean, Object obj = parameters.get(key); if (executionSpecAttr instanceof RefSpecAttribute) { RefSpecAttribute rsa = (RefSpecAttribute) executionSpecAttr; + // TODO: make sure this will not cause pb with OSGi Class targetClass = rsa.getTargetClass(); if (!targetClass.isAssignableFrom(obj.getClass())) { errors.reject(key diff --git a/runtime/org.argeo.slc.execution/src/main/resources/META-INF/spring/osgi.xml b/runtime/org.argeo.slc.execution/src/main/resources/META-INF/spring/osgi.xml new file mode 100644 index 000000000..ef9d141b7 --- /dev/null +++ b/runtime/org.argeo.slc.execution/src/main/resources/META-INF/spring/osgi.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/runtime/org.argeo.slc.execution/src/main/resources/org/argeo/slc/execution/spring.xml b/runtime/org.argeo.slc.execution/src/main/resources/org/argeo/slc/execution/spring.xml new file mode 100644 index 000000000..81e177f22 --- /dev/null +++ b/runtime/org.argeo.slc.execution/src/main/resources/org/argeo/slc/execution/spring.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/runtime/org.argeo.slc.support.activemq/src/main/java/org/argeo/slc/jms/ServiceMessageListenerAdapter.java b/runtime/org.argeo.slc.support.activemq/src/main/java/org/argeo/slc/jms/ServiceMessageListenerAdapter.java new file mode 100644 index 000000000..01ca72127 --- /dev/null +++ b/runtime/org.argeo.slc.support.activemq/src/main/java/org/argeo/slc/jms/ServiceMessageListenerAdapter.java @@ -0,0 +1,125 @@ +package org.argeo.slc.jms; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.Session; + +import org.argeo.slc.SlcException; +import org.argeo.slc.msg.ExecutionAnswer; +import org.springframework.jms.listener.adapter.MessageListenerAdapter; + +public class ServiceMessageListenerAdapter extends MessageListenerAdapter { + public final static String DEFAULT_METHOD_NAME_PARAMETER = "action"; + public final static String BODY_ARGUMENT = "BODY"; + + private Map> methodArguments = new HashMap>(); + + private static String methodNameParameter = DEFAULT_METHOD_NAME_PARAMETER; + + @Override + protected Object extractMessage(Message message) throws JMSException { + return new ExtractedMessage(message); + } + + @Override + protected String getListenerMethodName(Message originalMessage, + Object extractedMessage) throws JMSException { + return ((ExtractedMessage) extractedMessage).methodName; + } + + @Override + protected Object[] buildListenerArguments(Object extractedMessage) { + return ((ExtractedMessage) extractedMessage).arguments; + } + + @Override + public void onMessage(Message message, Session session) throws JMSException { + try {// hacked and simplified from parent class + // Regular case: find a handler method reflectively. + Object convertedMessage = extractMessage(message); + String methodName = getListenerMethodName(message, convertedMessage); + + // Invoke the handler method with appropriate arguments. + Object[] listenerArguments = buildListenerArguments(convertedMessage); + Object result = invokeListenerMethod(methodName, listenerArguments); + if (result != null) { + handleResult(result, message, session); + } else { + ExecutionAnswer answer = ExecutionAnswer.ok("Execution of " + + methodName + " on " + getDelegate() + " succeeeded."); + Message okMessage = getMessageConverter().toMessage(answer, + session); + sendResponse(session, getResponseDestination(message, + okMessage, session), okMessage); + } + } catch (Exception e) { + if (session == null) + return; + + StringWriter writer = new StringWriter(); + e.printStackTrace(new PrintWriter(writer)); + ExecutionAnswer answer = ExecutionAnswer.error(writer.toString()); + Message errorMessage = getMessageConverter().toMessage(answer, + session); + sendResponse(session, getResponseDestination(message, errorMessage, + session), errorMessage); + } + } + + protected class ExtractedMessage { + private final String methodName; + private final Object[] arguments; + private final Message originalMessage; + + public ExtractedMessage(Message originalMessage) throws JMSException { + this.originalMessage = originalMessage; + + if (!originalMessage.propertyExists(methodNameParameter)) + throw new SlcException("No property " + methodNameParameter + + " in incoming message," + + " cannot determine service method"); + + methodName = originalMessage.getStringProperty(methodNameParameter); + + if (!methodArguments.containsKey(methodName)) {// no arg specified + arguments = new Object[0]; + } else { + List parameterNames = methodArguments.get(methodName); + List arguments = new ArrayList(); + int count = 0; + for (String name : parameterNames) { + if (name.equals(BODY_ARGUMENT)) { + Object body = getMessageConverter().fromMessage( + originalMessage); + arguments.add(body); + } else { + if (!originalMessage.propertyExists(name)) + throw new SlcException("No property " + name + + " in incoming message," + + " cannot determine argument #" + count); + arguments.add(originalMessage.getObjectProperty(name)); + } + count++; + } + this.arguments = arguments.toArray(); + } + } + } + + public void setMethodArguments(Map> methodArguments) { + this.methodArguments = methodArguments; + } + + public static void setMethodNameParameter(String methodNameParameter) { + ServiceMessageListenerAdapter.methodNameParameter = methodNameParameter; + } + + +} diff --git a/runtime/org.argeo.slc.support.activemq/src/main/resources/org/argeo/slc/activemq/spring.xml b/runtime/org.argeo.slc.support.activemq/src/main/resources/org/argeo/slc/activemq/spring.xml index 14dde19c4..f2a9848b2 100644 --- a/runtime/org.argeo.slc.support.activemq/src/main/resources/org/argeo/slc/activemq/spring.xml +++ b/runtime/org.argeo.slc.support.activemq/src/main/resources/org/argeo/slc/activemq/spring.xml @@ -2,7 +2,7 @@ @@ -36,6 +36,11 @@ + + + org.argeo.slc.* - *,javax.xml.parsers;resolution:=optional, + org.argeo.slc.*;resolution:=optional, + org.argeo.slc.core.structure;resolution:=optional, + org.argeo.slc.core.structure.tree;resolution:=optional, + org.argeo.slc.core.test;resolution:=optional, + org.argeo.slc.core.test.tree;resolution:=optional, + org.argeo.slc.runtime;resolution:=optional, + org.argeo.slc.execution;resolution:=optional, + org.argeo.slc.msg;resolution:=optional, + org.argeo.slc.msg.process;resolution:=optional, + org.argeo.slc.msg.test.tree;resolution:=optional + + com.springsource.org.castor + diff --git a/runtime/org.argeo.slc.support.castor/src/main/resources/org/argeo/slc/castor/execution.xml b/runtime/org.argeo.slc.support.castor/src/main/resources/org/argeo/slc/castor/execution.xml new file mode 100644 index 000000000..7e6499fd9 --- /dev/null +++ b/runtime/org.argeo.slc.support.castor/src/main/resources/org/argeo/slc/castor/execution.xml @@ -0,0 +1,92 @@ + + + + + + Execution objects XML mapping + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/runtime/org.argeo.slc.support.castor/src/main/resources/org/argeo/slc/castor/spring.xml b/runtime/org.argeo.slc.support.castor/src/main/resources/org/argeo/slc/castor/spring.xml index 46f0ad212..73a6b3f41 100644 --- a/runtime/org.argeo.slc.support.castor/src/main/resources/org/argeo/slc/castor/spring.xml +++ b/runtime/org.argeo.slc.support.castor/src/main/resources/org/argeo/slc/castor/spring.xml @@ -22,6 +22,9 @@ classpath:org/argeo/slc/castor/test.xml + + classpath:org/argeo/slc/castor/execution.xml + -- 2.39.2