]> git.argeo.org Git - gpl/argeo-slc.git/commitdiff
Improve execution specs
authorMathieu Baudier <mbaudier@argeo.org>
Fri, 27 Feb 2009 20:44:02 +0000 (20:44 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Fri, 27 Feb 2009 20:44:02 +0000 (20:44 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@2200 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

37 files changed:
demo/org.argeo.slc.demo.basic/src/main/resources/conf/basic.xml
demo/org.argeo.slc.demo.basic/src/main/resources/conf/canonic.xml [new file with mode: 0644]
demo/org.argeo.slc.demo.basic/src/main/resources/conf/common.xml
demo/org.argeo.slc.demo.basic/src/main/resources/conf/imports.xml
demo/org.argeo.slc.demo.basic/src/main/resources/conf/main.xml
demo/org.argeo.slc.demo.basic/src/main/resources/conf/testCases/basic-001.xml
demo/org.argeo.slc.demo.basic/src/main/resources/conf/testCases/basic-002.xml
demo/org.argeo.slc.demo.basic/src/main/resources/conf/testCases/canonic-001.xml [new file with mode: 0644]
demo/org.argeo.slc.demo.basic/src/main/resources/conf/testCases/canonic-002.xml [new file with mode: 0644]
demo/org.argeo.slc.demo.basic/src/test/java/org/argeo/slc/demo/basic/BasicExecutionTest.java
demo/org.argeo.slc.demo.manager/src/main/resources/conf/manager-osgi.xml
demo/org.argeo.slc.demo.manager/src/test/java/org/argeo/slc/demo/manager/JmsTesting.java
org.argeo.slc.detached.launcher/src/main/java/org/argeo/slc/detached/launcher/Main.java
org.argeo.slc/pom.xml
runtime/org.argeo.slc.specs/pom.xml
runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/execution/ExecutionFlow.java
runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/execution/ExecutionSpecAttribute.java
runtime/org.argeo.slc.support.castor/src/main/java/org/argeo/slc/castor/execution/PrimitiveFieldHandler.java [new file with mode: 0644]
runtime/org.argeo.slc.support.castor/src/main/resources/org/argeo/slc/castor/execution.xml
runtime/org.argeo.slc.support.equinox/src/main/java/org/argeo/slc/execution/old/ExecutionFlowFactory.java
runtime/org.argeo.slc.support.simple/pom.xml
runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/AbstractSpecAttribute.java
runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/AbstractSpringExecutionModule.java
runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/DefaultExecutionFlow.java [new file with mode: 0644]
runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/DefaultExecutionSpec.java [new file with mode: 0644]
runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/ExecutionContext.java
runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/ExecutionParameterPostProcessor.java
runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/InstantiationPostProcessor.java
runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/PrimitiveSpecAttribute.java [new file with mode: 0644]
runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/PrimitiveValue.java [new file with mode: 0644]
runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/RefValue.java [new file with mode: 0644]
runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/SimpleExecutionFlow.java [deleted file]
runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/SimpleExecutionSpec.java [deleted file]
runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/SimpleSpecAttribute.java [deleted file]
runtime/org.argeo.slc.support.simple/src/main/resources/org/argeo/slc/core/execution/specs.xml [new file with mode: 0644]
runtime/org.argeo.slc.support.simple/src/main/resources/org/argeo/slc/core/execution/spring.xml
runtime/org.argeo.slc.support.simple/src/main/resources/org/argeo/slc/core/execution/tasks/core.xml [new file with mode: 0644]

index 168a56c9a55806f803f824587f75d3df1c352e28..a513e3f4fb77b4b579bc6fd37a8027e7c5309c06 100644 (file)
@@ -7,28 +7,31 @@
        http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
 \r
-       <bean id="basic.executionSpec" class="org.argeo.slc.core.execution.SimpleExecutionSpec">\r
+       <bean id="basic.spec" parent="slcTemplate.simpleSpec">\r
                <property name="attributes">\r
                        <map>\r
                                <entry key="testedComponentId">\r
-                                       <bean parent="specAttribute" p:value="100" p:isParameter="true"/>\r
+                                       <bean parent="specAttr.primitive" p:value="100" p:isParameter="true"\r
+                                               p:type="integer" />\r
                                </entry>\r
                                <entry key="testData1">\r
-                                       <bean parent="refAttribute" p:targetClass="org.argeo.slc.core.test.BasicTestData" />\r
+                                       <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.core.test.BasicTestData"\r
+                                               p:isParameter="true" p:isFrozen="true" />\r
                                </entry>\r
                                <entry key="testData2">\r
-                                       <bean parent="refAttribute" p:targetClass="org.argeo.slc.core.test.BasicTestData" />\r
+                                       <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.core.test.BasicTestData"\r
+                                               p:isParameter="true" p:isFrozen="true" />\r
                                </entry>\r
                        </map>\r
                </property>\r
        </bean>\r
 \r
-       <bean id="basic.ref" factory-bean="basic.executionSpec"\r
-               factory-method="createRef" abstract="true" />\r
+       <bean id="basic.ref" factory-bean="basic.spec" factory-method="createRef"\r
+               abstract="true" />\r
 \r
-       <bean id="basic.executionFlowTemplate" class="org.argeo.slc.core.execution.SimpleExecutionFlow"\r
+       <bean id="basic.flowTemplate" parent="slcTemplate.simpleFlow"\r
                abstract="true">\r
-               <property name="executionSpec" ref="basic.executionSpec" />\r
+               <property name="executionSpec" ref="basic.spec" />\r
                <property name="executables">\r
                        <list>\r
                                <ref bean="echo1" />\r
                <constructor-arg value="testData2" />\r
        </bean>\r
 \r
\r
-       <bean id="basic.testData" class="org.argeo.slc.core.test.BasicTestData"\r
-               >\r
+\r
+       <bean id="basic.testData" class="org.argeo.slc.core.test.BasicTestData">\r
                <aop:scoped-proxy />\r
                <property name="expected" value="tata" />\r
                <property name="reached" value="tata" />\r
        </bean>\r
\r
\r
-       <bean id="testDef" class="org.argeo.slc.core.test.BasicTestDefinition"\r
-               scope="prototype" />\r
-\r
-       <bean id="testResult" parent="slcDefault.test.basicSimpleTestResult" />\r
-\r
-       <bean id="testRun" class="org.argeo.slc.core.test.SimpleTestRun"\r
-               abstract="true">\r
-               <property name="testResult" ref="testResult" />\r
-       </bean>\r
-\r
-       <!--\r
-               <bean class="org.springframework.aop.framework.ProxyFactoryBean">\r
-               <property name="targetClass"\r
-               value="org.argeo.slc.core.test.BasicTestData" /> <property\r
-               name="targetSource"> <bean\r
-               class="org.argeo.slc.executionflow.ExecutionTargetSource"> <property\r
-               name="name" value="testData" /> <property name="targetClass"\r
-               value="org.argeo.slc.core.test.BasicTestData" /> </bean> </property>\r
-               <property name="proxyTargetClass" value="true" /> </bean>\r
-       -->\r
 \r
 </beans>
\ No newline at end of file
diff --git a/demo/org.argeo.slc.demo.basic/src/main/resources/conf/canonic.xml b/demo/org.argeo.slc.demo.basic/src/main/resources/conf/canonic.xml
new file mode 100644 (file)
index 0000000..ddc7aca
--- /dev/null
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+       xmlns:aop="http://www.springframework.org/schema/aop"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
+\r
+       <bean id="canonic.spec" parent="slcTemplate.simpleSpec">\r
+               <property name="attributes">\r
+                       <map>\r
+                               <entry key="parameterAtInstantiation">\r
+                                       <bean parent="specAttr.primitive" p:isParameter="true" p:type="integer" />\r
+                               </entry>\r
+                               <entry key="displayWithoutControl">\r
+                                       <bean parent="specAttr.primitive" p:value="100" p:isParameter="true"\r
+                                               p:isFrozen="true" p:type="integer" />\r
+                               </entry>\r
+                               <entry key="displayWithControl">\r
+                                       <bean parent="specAttr.primitive" p:value="200" p:isParameter="true"\r
+                                               p:isFrozen="false" p:type="integer" />\r
+                               </entry>\r
+                               <entry key="hide">\r
+                                       <bean parent="specAttr.primitive" p:value="300" p:isParameter="true"\r
+                                               p:isFrozen="false" p:isHidden="true" p:type="integer" />\r
+                               </entry>\r
+                       </map>\r
+               </property>\r
+       </bean>\r
+\r
+       <bean id="canonic.flowTemplate" parent="slcTemplate.simpleFlow"\r
+               abstract="true">\r
+               <property name="executionSpec" ref="canonic.spec" />\r
+               <property name="executables">\r
+                       <list>\r
+                               <bean parent="task.echo"\r
+                                       p:message="Canonical: displayWithControl=@{displayWithControl}, displayWithoutControl=@{displayWithoutControl}, hide=@{hide}"\r
+                                       scope="execution">\r
+                                       <aop:scoped-proxy />\r
+                               </bean>\r
+                       </list>\r
+               </property>\r
+       </bean>\r
+</beans>
\ No newline at end of file
index 4ed1362f732e651ee405ef568a56a57322af2b34..75f40055ca2e751ceed08c05521487674c84e567 100644 (file)
@@ -1,19 +1,17 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
-       xmlns:aop="http://www.springframework.org/schema/aop"\r
-       xsi:schemaLocation="\r
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
-       <import\r
-               resource="classpath:/org/argeo/slc/core/test/spring/applicationContext.xml" />\r
-\r
-       <bean id="specAttribute" class="org.argeo.slc.core.execution.SimpleSpecAttribute"\r
-               abstract="true" />\r
-\r
-       <bean id="refAttribute" class="org.argeo.slc.core.execution.RefSpecAttribute"\r
-               abstract="true" />\r
-\r
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+       <bean id="testDef" class="org.argeo.slc.core.test.BasicTestDefinition"
+               scope="prototype" />
+
+       <bean id="testResult" parent="slcDefault.test.basicSimpleTestResult" />
+
+       <bean id="testRun" class="org.argeo.slc.core.test.SimpleTestRun"
+               abstract="true">
+               <property name="testResult" ref="testResult" />
+       </bean>
+
 </beans>
\ No newline at end of file
index 68316a1b9519696df8620821a003792705f1a9b4..6bff52fb1dcdce99b64fdd9c869bd31b96d7b305 100644 (file)
@@ -6,4 +6,7 @@
 
        <import resource="classpath:org/argeo/slc/core/execution/spring.xml" />
 
+       <import
+               resource="classpath:/org/argeo/slc/core/test/spring/applicationContext.xml" />
+
 </beans>
\ No newline at end of file
index 6b943dc7fdbc1a75d21c2f099edf835b0585c09a..5d849311ebfef33a407dcbcdf10e631828abf6c0 100644 (file)
@@ -7,20 +7,15 @@
        http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
 \r
-<!-- \r
-       <bean id="testLaunch" class="org.argeo.slc.execution.old.TestLaunch"\r
-               p:flowName="main" init-method="launch" />\r
--->\r
-\r
        <bean id="executionModule" class="org.argeo.slc.osgi.OsgiExecutionModule" />\r
 \r
-       <bean id="main" class="org.argeo.slc.core.execution.SimpleExecutionFlow">\r
+       <bean id="main" parent="slcTemplate.simpleFlow">\r
                <property name="executionSpec">\r
-                       <bean class="org.argeo.slc.core.execution.SimpleExecutionSpec">\r
+                       <bean parent="slcTemplate.simpleSpec">\r
                                <property name="attributes">\r
                                        <map>\r
                                                <entry key="testKey">\r
-                                                       <bean parent="specAttribute" p:value="660" />\r
+                                                       <bean parent="specAttr.primitive" p:value="660" />\r
                                                </entry>\r
                                        </map>\r
                                </property>\r
                                <ref bean="basic.001" />\r
                                <ref bean="basic.001" />\r
                                <ref bean="basic.002" />\r
+                               <ref bean="canonic.001" />\r
+                               <ref bean="canonic.002" />\r
                        </list>\r
                </property>\r
        </bean>\r
 \r
-       <bean id="echo1" parent="echoTemplate" scope="execution">\r
+       <bean id="echo1" parent="task.echo" scope="execution">\r
                <property name="message"\r
                        value="From main! @{testKey}, slc.flows=@{slc.flows}" />\r
                <aop:scoped-proxy />\r
        </bean>\r
-\r
-       <bean id="echoTemplate" class="org.argeo.slc.core.execution.tasks.Echo"\r
-               abstract="true">\r
-       </bean>\r
-\r
 </beans>
\ No newline at end of file
index a5426649eb623b7d0185b708325a0547ce852f3b..7571fc9572781b3c98b0b5d00dc44db6988b4a5c 100644 (file)
@@ -7,7 +7,7 @@
        http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
 \r
-       <bean id="basic.001" parent="basic.executionFlowTemplate">\r
+       <bean id="basic.001" parent="basic.flowTemplate">\r
                <constructor-arg>\r
                        <map>\r
                                <entry key="testData1" value-ref="basic.001.testData" />\r
index c2946fdfb9ade6f51093ac812ddb3cea78f8cdfd..5720d9693db176d21b2df6778fc6ef56ff24e237 100644 (file)
@@ -4,7 +4,7 @@
 \r
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
 \r
-       <bean id="basic.002" parent="basic.executionFlowTemplate">\r
+       <bean id="basic.002" parent="basic.flowTemplate">\r
                <constructor-arg>\r
                        <map>\r
                                <entry key="testData1">\r
diff --git a/demo/org.argeo.slc.demo.basic/src/main/resources/conf/testCases/canonic-001.xml b/demo/org.argeo.slc.demo.basic/src/main/resources/conf/testCases/canonic-001.xml
new file mode 100644 (file)
index 0000000..77d4fee
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+       xmlns:aop="http://www.springframework.org/schema/aop"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
+\r
+       <bean id="canonic.001" parent="canonic.flowTemplate">\r
+               <constructor-arg>\r
+                       <map>\r
+                               <entry key="parameterAtInstantiation" value="1" />\r
+                       </map>\r
+               </constructor-arg>\r
+       </bean>\r
+</beans>\r
diff --git a/demo/org.argeo.slc.demo.basic/src/main/resources/conf/testCases/canonic-002.xml b/demo/org.argeo.slc.demo.basic/src/main/resources/conf/testCases/canonic-002.xml
new file mode 100644 (file)
index 0000000..5916c08
--- /dev/null
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+       xmlns:aop="http://www.springframework.org/schema/aop"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
+\r
+       <bean id="canonic.002" parent="canonic.flowTemplate">\r
+               <constructor-arg>\r
+                       <map>\r
+                               <entry key="parameterAtInstantiation" value="2" />\r
+                               <entry key="displayWithoutControl" value="102" />\r
+                               <entry key="displayWithControl" value="202" />\r
+                               <entry key="hide" value="202" />\r
+                       </map>\r
+               </constructor-arg>\r
+       </bean>\r
+</beans>\r
index fc914a16e54dfa04cdc2f795481664728d4e9d4c..0d703cdad424276b633b43106820cdf14d2722c1 100644 (file)
@@ -1,22 +1,29 @@
 package org.argeo.slc.demo.basic;
 
+import java.util.Map;
+
 import junit.framework.TestCase;
 
 import org.argeo.slc.core.execution.ExecutionContext;
-import org.argeo.slc.core.execution.NewExecutionEvent;
 import org.argeo.slc.execution.ExecutionFlow;
-import org.argeo.slc.process.SlcExecution;
+import org.springframework.beans.factory.generic.GenericBeanFactoryAccessor;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
 public class BasicExecutionTest extends TestCase {
        public void testExecution() throws Exception {
-               String[] files = { "conf/main.xml", "conf/imports.xml",
-                               "conf/common.xml", "conf/basic.xml",
-                               "conf/testCases/basic-001.xml", "conf/testCases/basic-002.xml" };
+               String[] files = { "conf/imports.xml", "conf/common.xml",
+                               "conf/basic.xml", "conf/canonic.xml",
+                               "conf/testCases/basic-001.xml", "conf/testCases/basic-002.xml",
+                               "conf/testCases/canonic-001.xml",
+                               "conf/testCases/canonic-002.xml", "conf/main.xml" };
                ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(
                                files);
                applicationContext.start();
 
+               // GenericBeanFactoryAccessor accessor = new
+               // GenericBeanFactoryAccessor(applicationContext);
+               // Map<String, Execut>
+
                String bean = "main";
                ExecutionContext.registerExecutionContext(new ExecutionContext());
                ExecutionContext.getVariables().put("slc.flows", bean);
@@ -24,12 +31,12 @@ public class BasicExecutionTest extends TestCase {
                                .getBean(bean);
                executionFlow.execute();
 
-//              SlcExecution slcExecution = new SlcExecution();
-//              slcExecution.getAttributes().put("slc.flows", "main");
-//              applicationContext.publishEvent(new NewExecutionEvent(this,
-//              slcExecution));
-//              
-//              Thread.sleep(5000);
+               // SlcExecution slcExecution = new SlcExecution();
+               // slcExecution.getAttributes().put("slc.flows", "main");
+               // applicationContext.publishEvent(new NewExecutionEvent(this,
+               // slcExecution));
+               //               
+               // Thread.sleep(5000);
 
                applicationContext.close();
        }
index a37132e761e1c524cf8518335fc97c1a00962000..bc9fa69040996d52cae72fbc4dc476b4b280a07f 100644 (file)
@@ -6,5 +6,6 @@
        http://www.springframework.org/schema/beans   \r
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
 \r
-       <list id="executionModules" interface="org.argeo.slc.execution.ExecutionModule" />\r
+       <list id="executionModules" interface="org.argeo.slc.execution.ExecutionModule"\r
+               cardinality="0..N" />\r
 </beans:beans>
\ No newline at end of file
index 21575fa0bb6da25b7371b713e198d70bfc3347fd..31122e213745af0abc901454eff4a6690cc5df6a 100644 (file)
@@ -1,16 +1,19 @@
 package org.argeo.slc.demo.manager;
 
+import java.net.URI;
+import java.net.URISyntaxException;
+
 import javax.jms.ConnectionFactory;
 import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.Session;
 import javax.jms.TextMessage;
 
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.broker.TransportConnector;
 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;
 
@@ -21,10 +24,29 @@ public class JmsTesting {
         * @param args
         */
        public static void main(String[] args) {
+//             BrokerService broker;
+//             try {
+//                     broker = new BrokerService();
+//                     broker.setPersistent(false);
+//                     TransportConnector transportConnector = new TransportConnector();
+//                     transportConnector.setUri(new URI("tcp://localhost:61616"));
+//                     broker.addConnector(transportConnector);
+//                     broker.start();
+//                     
+//                     Thread.sleep(5000);
+//             } catch (URISyntaxException e1) {
+//                     // TODO Auto-generated catch block
+//                     e1.printStackTrace();
+//             } catch (Exception e1) {
+//                     // TODO Auto-generated catch block
+//                     e1.printStackTrace();
+//             }
+
                ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(
                                "org/argeo/slc/activemq/spring.xml");
                try {
 
+
                        ConnectionFactory connectionFactory = (ConnectionFactory) applicationContext
                                        .getBean("slcDefault.jms.connectionFactory");
                        JmsTemplate jmsTemplate = new JmsTemplate(connectionFactory);
index d7da1e673910b880aca9da684317a3d50111f180..17b5f139e28473f54718b3f76e06c0e4a55fa8b0 100644 (file)
@@ -285,7 +285,7 @@ public class Main {
        }
 
        private static void info(Object obj) {
-               System.out.println("[INFO] " + obj);
+               //System.out.println("[INFO] " + obj);
        }
 
        private static void bundleInstallWarn(Object obj) {
index f90ea744d27403d230d80c154d358d8872daddf5..1416cfd53f58e72496cd7d07da9bc6e24038347a 100644 (file)
@@ -776,6 +776,11 @@ limitations under the License.
                                <artifactId>com.springsource.org.apache.activemq.web</artifactId>
                                <version>${version.activemq}</version>
                        </dependency>
+                       <dependency>
+                               <groupId>org.apache.activemq</groupId>
+                               <artifactId>com.springsource.org.apache.activemq.pool</artifactId>
+                               <version>${version.activemq}</version>
+                       </dependency>
                        <!--
                                <dependency> <groupId>org.apache.activemq</groupId>
                                <artifactId>activemq-pool</artifactId>
@@ -789,6 +794,11 @@ limitations under the License.
                                <artifactId>com.springsource.org.apache.xbean.spring</artifactId>
                                <version>3.3.0</version>
                        </dependency>
+                       <dependency>
+                               <groupId>org.apache.camel</groupId>
+                               <artifactId>com.springsource.org.apache.camel</artifactId>
+                               <version>1.3.0</version>
+                       </dependency>
 
                </dependencies>
        </dependencyManagement>
index 22dbb32b535d79e8c1962c4f260b8df6074d2515..68ee65f4b0530a4a8ffb3f0cd8c061b9d805eb15 100644 (file)
@@ -32,6 +32,9 @@
                                                <Export-Package>
                                                        org.argeo.slc.*
                                                </Export-Package>
+                                               <Import-Package>*,
+                                                       org.hibernate.proxy;resolution:="optional"
+                                               </Import-Package>
                                        </instructions>
                                </configuration>
                        </plugin>
index ede2bf15343a4e4a1f2fdf247221571f010fddcc..ce6a805831352f316d6b8cb8aaaa52a684241412 100644 (file)
@@ -2,8 +2,12 @@ package org.argeo.slc.execution;
 
 import org.argeo.slc.process.Executable;
 
-public interface ExecutionFlow extends Executable{
-       public Object getParameter(String name);
+public interface ExecutionFlow extends Executable {
+       public Object getParameter(String key);
+
+       public Boolean isSetAsParameter(String key);
+
        public ExecutionSpec getExecutionSpec();
+
        public String getName();
 }
index 582cef99c76b07ccaf79118e6c83ce3965ef7eab..c5335e59d51fa46aaef848a60abc46c81a6fbd77 100644 (file)
@@ -2,5 +2,11 @@ package org.argeo.slc.execution;
 
 public interface ExecutionSpecAttribute {
        public Object getValue();
+
        public Boolean getIsParameter();
+
+       public Boolean getIsFrozen();
+
+       public Boolean getIsHidden();
+
 }
diff --git a/runtime/org.argeo.slc.support.castor/src/main/java/org/argeo/slc/castor/execution/PrimitiveFieldHandler.java b/runtime/org.argeo.slc.support.castor/src/main/java/org/argeo/slc/castor/execution/PrimitiveFieldHandler.java
new file mode 100644 (file)
index 0000000..e27a3af
--- /dev/null
@@ -0,0 +1,80 @@
+package org.argeo.slc.castor.execution;
+
+import org.argeo.slc.core.execution.PrimitiveSpecAttribute;
+import org.argeo.slc.core.execution.PrimitiveValue;
+import org.exolab.castor.mapping.AbstractFieldHandler;
+
+public class PrimitiveFieldHandler extends AbstractFieldHandler {
+
+       @Override
+       public Object getValue(Object object) throws IllegalStateException {
+               if (object == null)
+                       return null;
+
+               Object value = null;
+               if (object instanceof PrimitiveSpecAttribute)
+                       value = ((PrimitiveSpecAttribute) object).getValue();
+               else if (object instanceof PrimitiveValue)
+                       value = ((PrimitiveValue) object).getValue();
+               else
+                       throw new IllegalStateException("Unkown type " + object.getClass());
+
+               return value != null ? value.toString() : null;
+       }
+
+       @Override
+       public Object newInstance(Object parent, Object[] args)
+                       throws IllegalStateException {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       @Override
+       public Object newInstance(Object parent) throws IllegalStateException {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       @Override
+       public void resetValue(Object object) throws IllegalStateException,
+                       IllegalArgumentException {
+               // TODO Auto-generated method stub
+
+       }
+
+       @Override
+       public void setValue(Object object, Object value)
+                       throws IllegalStateException, IllegalArgumentException {
+               // TODO: could probably be more generic
+
+               PrimitiveSpecAttribute attr = (PrimitiveSpecAttribute) object;
+               String type = attr.getType();
+               String str = value.toString();
+
+               // FIXME: generalize
+               if (object instanceof PrimitiveSpecAttribute)
+                       ((PrimitiveSpecAttribute) object).setValue(convert(type, str));
+               else if (object instanceof PrimitiveValue)
+                       ((PrimitiveValue) object).setValue(convert(type, str));
+               else
+                       throw new IllegalStateException("Unkown type " + object.getClass());
+       }
+
+       protected Object convert(String type, String str) {
+               if (PrimitiveSpecAttribute.TYPE_STRING.equals(type)) {
+                       return str;
+               } else if (PrimitiveSpecAttribute.TYPE_INTEGER.equals(type)) {
+                       return (Integer.parseInt(str));
+               } else if (PrimitiveSpecAttribute.TYPE_LONG.equals(type)) {
+                       return (Long.parseLong(str));
+               } else if (PrimitiveSpecAttribute.TYPE_FLOAT.equals(type)) {
+                       return (Float.parseFloat(str));
+               } else if (PrimitiveSpecAttribute.TYPE_DOUBLE.equals(type)) {
+                       return (Double.parseDouble(str));
+               } else if (PrimitiveSpecAttribute.TYPE_BOOLEAN.equals(type)) {
+                       return (Boolean.parseBoolean(str));
+               } else {
+                       return str;
+               }
+       }
+}
index 1cce65d945688fbb72662e325020ac0fa50036b1..4c9a256cc7d2151a081590c0a9df30cc9c106aa5 100644 (file)
                                        <field name="key" type="string">\r
                                                <bind-xml name="key" node="attribute" />\r
                                        </field>\r
-                                       <field name="value" type="string">\r
-                                               <bind-xml node="text" />\r
+                                       <field name="value">\r
+                                               <bind-xml auto-naming="deriveByClass" />\r
                                        </field>\r
                                </class>\r
                        </bind-xml>\r
                </field>\r
        </class>\r
 \r
-       <class name="org.argeo.slc.core.execution.SimpleExecutionSpec">\r
+       <!-- Specs -->\r
+       <class name="org.argeo.slc.core.execution.DefaultExecutionSpec">\r
                <map-to ns-uri="http://argeo.org/projects/slc/schemas"\r
                        ns-prefix="slc" />\r
                <field name="name" identity="true">\r
                <field name="isParameter">\r
                        <bind-xml name="isParameter" node="attribute" />\r
                </field>\r
+               <field name="isFrozen">\r
+                       <bind-xml name="isFrozen" node="attribute" />\r
+               </field>\r
+               <field name="isHidden">\r
+                       <bind-xml name="isHidden" node="attribute" />\r
+               </field>\r
        </class>\r
 \r
-       <class name="org.argeo.slc.core.execution.SimpleSpecAttribute"\r
-               extends="org.argeo.slc.execution.AbstractSpecAttribute">\r
+       <class name="org.argeo.slc.core.execution.PrimitiveSpecAttribute"\r
+               extends="org.argeo.slc.core.execution.AbstractSpecAttribute">\r
                <map-to ns-uri="http://argeo.org/projects/slc/schemas"\r
                        ns-prefix="slc" />\r
-               <field name="value" />\r
+               <field name="type">\r
+                       <bind-xml name="type" node="attribute" />\r
+               </field>\r
+               <field name="value" type="string"\r
+                       handler="org.argeo.slc.castor.execution.PrimitiveFieldHandler" />\r
        </class>\r
 \r
-       <class name="org.argeo.slc.core.execution.RefSpecAttribute" extends="org.argeo.slc.execution.AbstractSpecAttribute">\r
+       <class name="org.argeo.slc.core.execution.RefSpecAttribute"\r
+               extends="org.argeo.slc.core.execution.AbstractSpecAttribute">\r
                <map-to ns-uri="http://argeo.org/projects/slc/schemas"\r
                        ns-prefix="slc" />\r
                <field name="targetClassName">\r
                        <bind-xml name="targetClassName" node="attribute" />\r
                </field>\r
        </class>\r
+\r
+       <!-- Values -->\r
+       <class name="org.argeo.slc.core.execution.PrimitiveValue">\r
+               <map-to ns-uri="http://argeo.org/projects/slc/schemas"\r
+                       ns-prefix="slc" />\r
+               <field name="type">\r
+                       <bind-xml name="type" node="attribute" />\r
+               </field>\r
+               <field name="value" type="string"\r
+                       handler="org.argeo.slc.castor.execution.PrimitiveFieldHandler" />\r
+       </class>\r
+\r
+       <class name="org.argeo.slc.core.execution.RefValue">\r
+               <map-to ns-uri="http://argeo.org/projects/slc/schemas"\r
+                       ns-prefix="slc" />\r
+               <field name="label" />\r
+       </class>\r
 </mapping>
\ No newline at end of file
index c8da41a9096f33328d7192760843d7ef5ee2f379..c38d866d7f09fc2d58a40b4ea176aaa2afaa3469 100644 (file)
@@ -4,7 +4,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
-import org.argeo.slc.core.execution.SimpleExecutionFlow;
+import org.argeo.slc.core.execution.DefaultExecutionFlow;
 import org.argeo.slc.execution.ExecutionFlow;
 import org.argeo.slc.process.Executable;
 
@@ -13,7 +13,7 @@ public class ExecutionFlowFactory {
 
        
        public ExecutionFlow createExecutionFlow(Map<String, Object> attributes){
-               SimpleExecutionFlow executionFlow = new SimpleExecutionFlow();
+               DefaultExecutionFlow executionFlow = new DefaultExecutionFlow();
                executionFlow.setExecutables(executables);
                return executionFlow;
        }
index 2e7c091f5eb79b6f01edc14a38157e5d1de893d5..3753cb57603533fd6bead6c9f1e6214b478015b5 100644 (file)
@@ -38,6 +38,7 @@
                                                        org.argeo.slc.*,org.argeo.slc.core.test.spring
                                                </Export-Package>
                                                <Import-Package>*,org.apache.commons.logging;version="1.1",
+                                                       org.hibernate.proxy;resolution:="optional",
                                                        org.dbunit;resolution:="optional",
                                                        org.dbunit.database;resolution:="optional",
                                                        org.dbunit.dataset;resolution:="optional",
index b8a599bdbcf8b2219eb2c4dc08a122c7d4b3e650..52f1adae5488844e8c4ffd8f23d7d5af3387f38b 100644 (file)
@@ -3,8 +3,11 @@ package org.argeo.slc.core.execution;
 import org.argeo.slc.execution.ExecutionSpecAttribute;
 
 public abstract class AbstractSpecAttribute implements ExecutionSpecAttribute {
-       private Boolean isParameter = true;
+       private Boolean isParameter = false;
+       private Boolean isFrozen = false;
+       private Boolean isHidden = false;
 
+       /** Has to be set at instantiation */
        public Boolean getIsParameter() {
                return isParameter;
        }
@@ -13,4 +16,22 @@ public abstract class AbstractSpecAttribute implements ExecutionSpecAttribute {
                this.isParameter = isParameter;
        }
 
+       /** Cannot be overridden at runtime */
+       public Boolean getIsFrozen() {
+               return isFrozen;
+       }
+
+       public void setIsFrozen(Boolean isFinal) {
+               this.isFrozen = isFinal;
+       }
+
+       /** Should not be shown to the end user */
+       public Boolean getIsHidden() {
+               return isHidden;
+       }
+
+       public void setIsHidden(Boolean isHidden) {
+               this.isHidden = isHidden;
+       }
+
 }
index fa42917fdb3e5ca43e43efdb79d1b6aa04939fdb..4e0842e37dd142d9c05ed6c9724060021059dad6 100644 (file)
@@ -2,7 +2,9 @@ package org.argeo.slc.core.execution;
 
 import java.util.HashMap;
 import java.util.Map;
+import java.util.TreeMap;
 
+import org.argeo.slc.SlcException;
 import org.argeo.slc.execution.ExecutionFlow;
 import org.argeo.slc.execution.ExecutionFlowDescriptor;
 import org.argeo.slc.execution.ExecutionModule;
@@ -10,6 +12,7 @@ import org.argeo.slc.execution.ExecutionModuleDescriptor;
 import org.argeo.slc.execution.ExecutionSpec;
 import org.argeo.slc.execution.ExecutionSpecAttribute;
 import org.argeo.slc.process.SlcExecution;
+import org.springframework.aop.scope.ScopedObject;
 import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.generic.GenericBeanFactoryAccessor;
 import org.springframework.context.ApplicationContext;
@@ -40,21 +43,46 @@ public abstract class AbstractSpringExecutionModule implements ExecutionModule,
                        Assert.notNull(executionSpec);
                        Assert.notNull(executionSpec.getName());
 
-                       Map<String, Object> values = new HashMap<String, Object>();
+                       Map<String, Object> values = new TreeMap<String, Object>();
                        for (String key : executionSpec.getAttributes().keySet()) {
                                ExecutionSpecAttribute attribute = executionSpec
                                                .getAttributes().get(key);
-                               if (attribute instanceof SimpleExecutionSpec
-                                               && attribute.getIsParameter()) {
-                                       values.put(key, executionFlow.getParameter(key));
+
+                               if (executionFlow.isSetAsParameter(key)) {
+                                       Object value = executionFlow.getParameter(key);
+                                       if (attribute instanceof PrimitiveSpecAttribute) {
+                                               PrimitiveValue primitiveValue = new PrimitiveValue();
+                                               primitiveValue
+                                                               .setType(((PrimitiveSpecAttribute) attribute)
+                                                                               .getType());
+                                               primitiveValue.setValue(value);
+                                               values.put(key, primitiveValue);
+                                       } else if (attribute instanceof RefSpecAttribute) {
+                                               RefValue refValue = new RefValue();
+                                               if (value instanceof ScopedObject) {
+                                                       refValue.setLabel("RUNTIME "
+                                                                       + value.getClass().getName());
+                                               } else {
+                                                       refValue.setLabel("STATIC "
+                                                                       + value.getClass().getName());
+                                               }
+                                               values.put(key, refValue);
+                                       } else {
+                                               throw new SlcException("Unkown spec attribute type "
+                                                               + attribute.getClass());
+                                       }
                                }
+
                        }
 
                        ExecutionFlowDescriptor efd = new ExecutionFlowDescriptor(name,
                                        values, executionSpec);
 
+                       // Add execution spec if necessary
                        if (!md.getExecutionSpecs().contains(executionSpec))
                                md.getExecutionSpecs().add(executionSpec);
+                       
+                       // Add execution flow
                        md.getExecutionFlows().add(efd);
                }
 
diff --git a/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/DefaultExecutionFlow.java b/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/DefaultExecutionFlow.java
new file mode 100644 (file)
index 0000000..e2c343d
--- /dev/null
@@ -0,0 +1,143 @@
+package org.argeo.slc.core.execution;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.commons.lang.math.RandomUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.execution.ExecutionFlow;
+import org.argeo.slc.execution.ExecutionSpec;
+import org.argeo.slc.execution.ExecutionSpecAttribute;
+import org.argeo.slc.process.Executable;
+import org.argeo.slc.test.ExecutableTestRun;
+import org.springframework.beans.factory.BeanNameAware;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.validation.MapBindingResult;
+
+public class DefaultExecutionFlow implements ExecutionFlow, InitializingBean,
+               BeanNameAware {
+       private ExecutionSpec executionSpec = new DefaultExecutionSpec();
+       private String name = null;
+       private Map<String, Object> parameters = new HashMap<String, Object>();
+       private List<Executable> executables = new ArrayList<Executable>();
+
+       public DefaultExecutionFlow() {
+
+       }
+
+       public DefaultExecutionFlow(Map<String, Object> parameters) {
+               this.parameters.putAll(parameters);
+       }
+
+       public void execute() {
+               for (Executable executable : executables) {
+                       executable.execute();
+               }
+       }
+
+       public void afterPropertiesSet() throws Exception {
+               // Validate execution specs
+               if (executionSpec == null)
+                       return;
+
+               MapBindingResult errors = new MapBindingResult(parameters, "execution#"
+                               + getName());
+               for (String key : executionSpec.getAttributes().keySet()) {
+                       ExecutionSpecAttribute attr = executionSpec.getAttributes()
+                                       .get(key);
+
+                       if (attr.getIsParameter() && !isSetAsParameter(key)) {
+                               errors.rejectValue(key, "Parameter not set");
+                               break;
+                       }
+
+                       if (attr.getIsFrozen() && !isSetAsParameter(key)) {
+                               errors.rejectValue(key, "Frozen but not set as parameter");
+                               break;
+                       }
+
+                       if (attr.getIsHidden() && !isSetAsParameter(key)) {
+                               errors.rejectValue(key, "Hidden but not set as parameter");
+                               break;
+                       }
+
+                       /*
+                        * if (!parameters.containsKey(key)) { Object defaultValue =
+                        * attr.getValue(); if (defaultValue == null)
+                        * errors.rejectValue(key, "Not set and no default value"); else
+                        * parameters.put(key, defaultValue); } else {// contains key Object
+                        * obj = parameters.get(key); if (attr instanceof RefSpecAttribute)
+                        * { RefSpecAttribute rsa = (RefSpecAttribute) attr; // TODO: make
+                        * sure this will not cause pb with OSGi Class targetClass =
+                        * rsa.getTargetClass(); if
+                        * (!targetClass.isAssignableFrom(obj.getClass())) {
+                        * errors.reject(key + " not compatible with target class " +
+                        * targetClass); } } }
+                        */
+               }
+
+               if (errors.hasErrors())
+                       throw new SlcException("Could not prepare execution flow: "
+                                       + errors.toString());
+       }
+
+       public void setBeanName(String name) {
+               this.name = name;
+       }
+
+       public void setExecutables(List<Executable> executables) {
+               this.executables = executables;
+       }
+
+       public void setExecutionSpec(ExecutionSpec executionSpec) {
+               this.executionSpec = executionSpec;
+       }
+
+       public void setParameters(Map<String, Object> attributes) {
+               this.parameters = attributes;
+       }
+
+       public String getName() {
+               return name;
+       }
+
+       public ExecutionSpec getExecutionSpec() {
+               return executionSpec;
+       }
+
+       public Object getParameter(String name) {
+               if (parameters.containsKey(name)) {
+                       return parameters.get(name);
+               } else {
+                       if (executionSpec.getAttributes().containsKey(name)) {
+                               ExecutionSpecAttribute esa = executionSpec.getAttributes().get(
+                                               name);
+                               if (esa.getValue() != null)
+                                       return esa.getValue();
+                       } else {
+                               throw new SlcException("Key " + name
+                                               + " is not defined in the specifications of "
+                                               + toString());
+                       }
+               }
+               throw new SlcException("Key " + name + " is not set as parameter in "
+                               + toString());
+       }
+
+       public Boolean isSetAsParameter(String key) {
+               return parameters.containsKey(key)
+                               || (executionSpec.getAttributes().containsKey(key) && executionSpec
+                                               .getAttributes().get(key).getValue() != null);
+       }
+
+       public String toString() {
+               return new StringBuffer("Flow ").append(name).toString();
+       }
+
+       public boolean equals(Object obj) {
+               return ((ExecutionFlow) obj).getName().equals(name);
+       }
+}
diff --git a/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/DefaultExecutionSpec.java b/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/DefaultExecutionSpec.java
new file mode 100644 (file)
index 0000000..6711f65
--- /dev/null
@@ -0,0 +1,93 @@
+package org.argeo.slc.core.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.SlcException;
+import org.argeo.slc.execution.ExecutionFlow;
+import org.argeo.slc.execution.ExecutionSpec;
+import org.argeo.slc.execution.ExecutionSpecAttribute;
+import org.springframework.beans.factory.BeanNameAware;
+
+public class DefaultExecutionSpec implements ExecutionSpec, BeanNameAware {
+       private final static Log log = LogFactory.getLog(DefaultExecutionSpec.class);
+
+       private final static ThreadLocal<ExecutionFlow> initializingFlow = new ThreadLocal<ExecutionFlow>();
+
+       private Map<String, ExecutionSpecAttribute> attributes = new HashMap<String, ExecutionSpecAttribute>();
+
+       private String name = null;
+
+       public Map<String, ExecutionSpecAttribute> getAttributes() {
+               return attributes;
+       }
+
+       public void setAttributes(Map<String, ExecutionSpecAttribute> attributes) {
+               this.attributes = attributes;
+       }
+
+       public Object createRef(String name) {
+               ExecutionFlow flow = initializingFlow.get();
+               if (flow == null)
+                       throw new SlcException("No flow is currently initializing."
+                                       + " Declare flow refs as inner beans or prototypes.");
+               /*
+                * RefSpecAttribute refSpecAttribute = (RefSpecAttribute) attributes
+                * .get(name); Class<?> targetClass = refSpecAttribute.getTargetClass();
+                * ExecutionTargetSource targetSource = new ExecutionTargetSource(flow,
+                * targetClass, name); ProxyFactory proxyFactory = new ProxyFactory();
+                * proxyFactory.setTargetClass(targetClass);
+                * proxyFactory.setProxyTargetClass(true);
+                * proxyFactory.setTargetSource(targetSource);
+                * 
+                * return proxyFactory.getProxy();
+                */
+               return flow.getParameter(name);
+       }
+
+       public void setBeanName(String name) {
+               this.name = name;
+       }
+
+       public String getName() {
+               return name;
+       }
+
+       // FLOWS INITIALIZATION SUPPORT
+
+       public static void flowInitializationStarted(ExecutionFlow flow) {
+               if (log.isTraceEnabled())
+                       log.trace("Start initialization of " + flow.hashCode() + " ("
+                                       + flow + " - " + flow.getClass() + ")");
+               initializingFlow.set(flow);
+       }
+
+       public static void flowInitializationFinished(ExecutionFlow flow) {
+               if (log.isTraceEnabled())
+                       log.trace("Finish initialization of " + flow.hashCode() + " ("
+                                       + flow + " - " + flow.getClass() + ")");
+               ExecutionFlow registeredFlow = initializingFlow.get();
+               if (registeredFlow != null) {
+                       if (!flow.getName().equals(registeredFlow.getName()))
+                               throw new SlcException("Current flow is " + flow);
+                       initializingFlow.set(null);
+               }
+       }
+
+       public static Object getInitializingFlowParameter(String key) {
+               if (initializingFlow.get() == null)
+                       throw new SlcException("No initializing flow available.");
+               return initializingFlow.get().getParameter(key);
+       }
+
+       public static Boolean isInFlowInitialization() {
+               return initializingFlow.get() != null;
+       }
+
+       public boolean equals(Object obj) {
+               return ((ExecutionSpec) obj).getName().equals(name);
+       }
+
+}
index 97f7268b67cf91320158cd885902faa060f42450..732dd819e3d71425b1fe5c09b5417a97e9e3268a 100644 (file)
@@ -61,8 +61,8 @@ public class ExecutionContext {
                Map<String, ExecutionSpecAttribute> specAttrs = executionFlow
                                .getExecutionSpec().getAttributes();
                for (String key : specAttrs.keySet()) {
-                       ExecutionSpecAttribute esa = specAttrs.get(key);
-                       if (esa.getIsParameter()) {
+                       //ExecutionSpecAttribute esa = specAttrs.get(key);
+                       if (executionFlow.isSetAsParameter(key)) {
                                runtime.getLocalVariables().put(key,
                                                executionFlow.getParameter(key));
                                if (log.isTraceEnabled())
index d393d774f84c96de38737d93f6458e019fc64f96..a95670b10a3fc93ccf1f52f0bf9f381fdd49c6da 100644 (file)
@@ -28,48 +28,37 @@ public class ExecutionParameterPostProcessor extends
        public PropertyValues postProcessPropertyValues(PropertyValues pvs,
                        PropertyDescriptor[] pds, Object bean, String beanName)
                        throws BeansException {
-               if (!ExecutionContext.isExecuting())
+               if (!ExecutionContext.isExecuting()){
+                               //&& !DefaultExecutionSpec.isInFlowInitialization()) {
+                       //log.info("Skip parameter conversion for bean " + beanName);
                        return pvs;
-
-//             ExecutionFlow currentFlow = ExecutionContext.getCurrentFlow();
-//
-//             Properties props = new Properties();
-//             Map<String, Object> attributes = currentFlow.getAttributes();
-//             Map<String, ExecutionSpecAttribute> specAttributes = currentFlow
-//                             .getExecutionSpec().getAttributes();
-//
-//             for (String key : specAttributes.keySet()) {
-//                     ExecutionSpecAttribute obj = specAttributes.get(key);
-//                     if (!(obj instanceof RefSpecAttribute)) {
-//                             if (!attributes.containsKey(key))
-//                                     throw new SlcException("Specified attribute " + key
-//                                                     + " is not set in " + currentFlow);
-//
-//                             props.setProperty(key, attributes.get(key).toString());
-//                             // if (log.isTraceEnabled())
-//                             // log.trace("Use attribute " + key);
-//                     }
-//             }
+               } else {
+                       //log.info("Execute parameter conversion for bean " + beanName);
+               }
 
                Properties props = new Properties();
                CustomPpc ppc = new CustomPpc(props);
 
                for (PropertyValue pv : pvs.getPropertyValues()) {
+//                     log.info("   PropertyValue pv " + pv.getValue() + " - "
+//                                     + pv.getValue().getClass());
+                       String originalValue = null;
+                       String convertedValue = null;
                        if (pv.getValue() instanceof TypedStringValue) {
                                TypedStringValue tsv = (TypedStringValue) pv.getValue();
-                               String originalValue = tsv.getValue();
-                               String convertedValue = ppc.process(originalValue);
+                               originalValue = tsv.getValue();
+                               convertedValue = ppc.process(originalValue);
                                tsv.setValue(convertedValue);
-                               if (log.isTraceEnabled()) {
-                                       if (!originalValue.equals(convertedValue))
-                                               log.trace("Converted field '" + pv.getName() + "': '"
-                                                               + originalValue + "' to '" + convertedValue
-                                                               + "' in bean " + beanName);
-                               }
-                       } else {
-                               // if (log.isTraceEnabled())
-                               // log.trace(beanName + "[" + pv.getName() + "]: "
-                               // + pv.getValue().getClass());
+                       } else if (pv.getValue() instanceof String) {
+                               originalValue = pv.getValue().toString();
+                               convertedValue = ppc.process(originalValue);
+                               pv.setConvertedValue(convertedValue);
+                       }
+                       if (convertedValue != null && log.isTraceEnabled()) {
+                               if (!originalValue.equals(convertedValue))
+                                       log.trace("Converted field '" + pv.getName() + "': '"
+                                                       + originalValue + "' to '" + convertedValue
+                                                       + "' in bean " + beanName);
                        }
                }
 
@@ -107,10 +96,11 @@ 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 (SimpleExecutionSpec.isInFlowInitialization())
-                               return SimpleExecutionSpec.getInitializingFlowParameter(
+                       else if (DefaultExecutionSpec.isInFlowInitialization())
+                               return DefaultExecutionSpec.getInitializingFlowParameter(
                                                placeholder).toString();
                        else
                                return super.resolvePlaceholder(placeholder, props);
index d9ff3d5217b8010b7ae7bda39e9241efa0dc4627..785043958fa71b402cc38fa5678d78269506a132 100644 (file)
@@ -15,16 +15,24 @@ public class InstantiationPostProcessor extends
        public boolean postProcessAfterInstantiation(Object bean, String beanName)
                        throws BeansException {
                if (bean instanceof ExecutionFlow)
-                       SimpleExecutionSpec.flowInitializationStarted((ExecutionFlow) bean);
+                       DefaultExecutionSpec
+                                       .flowInitializationStarted((ExecutionFlow) bean);
                return true;
        }
 
        @Override
        public Object postProcessBeforeInitialization(Object bean, String beanName)
                        throws BeansException {
+               return bean;
+       }
+
+       @Override
+       public Object postProcessAfterInitialization(Object bean, String beanName)
+                       throws BeansException {
                if (bean instanceof ExecutionFlow)
-                       SimpleExecutionSpec
+                       DefaultExecutionSpec
                                        .flowInitializationFinished((ExecutionFlow) bean);
                return bean;
        }
+
 }
diff --git a/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/PrimitiveSpecAttribute.java b/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/PrimitiveSpecAttribute.java
new file mode 100644 (file)
index 0000000..daddc0a
--- /dev/null
@@ -0,0 +1,34 @@
+package org.argeo.slc.core.execution;
+
+public class PrimitiveSpecAttribute extends AbstractSpecAttribute {
+//     public enum Type {
+//             string, integer
+//     }
+
+       public final static String TYPE_STRING = "string";
+       public final static String TYPE_INTEGER = "integer";
+       public final static String TYPE_LONG = "long";
+       public final static String TYPE_FLOAT = "float";
+       public final static String TYPE_DOUBLE = "double";
+       public final static String TYPE_BOOLEAN = "boolean";
+
+       private String type = "string";
+       private Object value = null;
+
+       public Object getValue() {
+               return value;
+       }
+
+       public void setValue(Object value) {
+               this.value = value;
+       }
+
+       public String getType() {
+               return type;
+       }
+
+       public void setType(String type) {
+               this.type = type;
+       }
+
+}
diff --git a/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/PrimitiveValue.java b/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/PrimitiveValue.java
new file mode 100644 (file)
index 0000000..e29d67e
--- /dev/null
@@ -0,0 +1,24 @@
+package org.argeo.slc.core.execution;
+
+public class PrimitiveValue {
+       private String type;
+
+       private Object value;
+
+       public String getType() {
+               return type;
+       }
+
+       public void setType(String type) {
+               this.type = type;
+       }
+
+       public Object getValue() {
+               return value;
+       }
+
+       public void setValue(Object value) {
+               this.value = value;
+       }
+
+}
diff --git a/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/RefValue.java b/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/RefValue.java
new file mode 100644 (file)
index 0000000..bc5336c
--- /dev/null
@@ -0,0 +1,14 @@
+package org.argeo.slc.core.execution;
+
+public class RefValue {
+       private String label;
+
+       public String getLabel() {
+               return label;
+       }
+
+       public void setLabel(String label) {
+               this.label = label;
+       }
+
+}
diff --git a/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/SimpleExecutionFlow.java b/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/SimpleExecutionFlow.java
deleted file mode 100644 (file)
index 2f351fb..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-package org.argeo.slc.core.execution;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import org.apache.commons.lang.math.RandomUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.execution.ExecutionFlow;
-import org.argeo.slc.execution.ExecutionSpec;
-import org.argeo.slc.execution.ExecutionSpecAttribute;
-import org.argeo.slc.process.Executable;
-import org.argeo.slc.test.ExecutableTestRun;
-import org.springframework.beans.factory.BeanNameAware;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.validation.MapBindingResult;
-
-public class SimpleExecutionFlow implements ExecutionFlow, InitializingBean,
-               BeanNameAware {
-       private ExecutionSpec executionSpec = new SimpleExecutionSpec();
-       private String name = null;
-       private Map<String, Object> parameters = new HashMap<String, Object>();
-       private List<Executable> executables = new ArrayList<Executable>();
-
-       public SimpleExecutionFlow() {
-
-       }
-
-       public SimpleExecutionFlow(Map<String, Object> parameters) {
-               this.parameters.putAll(parameters);
-       }
-
-       public void execute() {
-               for (Executable executable : executables) {
-                       executable.execute();
-               }
-       }
-
-       public void afterPropertiesSet() throws Exception {
-               // Validate execution specs
-               if (executionSpec == null)
-                       return;
-
-               MapBindingResult errors = new MapBindingResult(parameters, "execution#"
-                               + getName());
-               for (String key : executionSpec.getAttributes().keySet()) {
-                       ExecutionSpecAttribute executionSpecAttr = executionSpec
-                                       .getAttributes().get(key);
-                       if (!parameters.containsKey(key)) {
-                               Object defaultValue = executionSpecAttr.getValue();
-                               if (defaultValue == null)
-                                       errors.rejectValue(key, "Not set and no default value");
-                               else
-                                       parameters.put(key, defaultValue);
-                       } else {// contains key
-                               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
-                                                               + " not compatible with target class "
-                                                               + targetClass);
-                                       }
-                               }
-                       }
-               }
-
-               if (errors.hasErrors())
-                       throw new SlcException("Could not prepare execution flow: "
-                                       + errors.toString());
-       }
-
-       public void setBeanName(String name) {
-               this.name = name;
-       }
-
-       public void setExecutables(List<Executable> executables) {
-               this.executables = executables;
-       }
-
-       public void setExecutionSpec(ExecutionSpec executionSpec) {
-               this.executionSpec = executionSpec;
-       }
-
-       public void setParameters(Map<String, Object> attributes) {
-               this.parameters = attributes;
-       }
-
-       public String getName() {
-               return name;
-       }
-
-       public ExecutionSpec getExecutionSpec() {
-               return executionSpec;
-       }
-
-       public Object getParameter(String name) {
-               if (parameters.containsKey(name)) {
-                       return parameters.get(name);
-               } else {
-                       if (executionSpec.getAttributes().containsKey(name)) {
-                               ExecutionSpecAttribute esa = executionSpec.getAttributes().get(
-                                               name);
-                               if (esa.getValue() != null)
-                                       return esa.getValue();
-                       } else {
-                               throw new SlcException("Key " + name
-                                               + " is not defined in the specifications of "
-                                               + toString());
-                       }
-               }
-               throw new SlcException("Key " + name + " is not set as parameter in "
-                               + toString());
-       }
-
-       public String toString() {
-               return new StringBuffer("Flow ").append(name).toString();
-       }
-
-       public boolean equals(Object obj) {
-               return ((ExecutionFlow) obj).getName().equals(name);
-       }
-}
diff --git a/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/SimpleExecutionSpec.java b/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/SimpleExecutionSpec.java
deleted file mode 100644 (file)
index ed1b76b..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-package org.argeo.slc.core.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.SlcException;
-import org.argeo.slc.execution.ExecutionFlow;
-import org.argeo.slc.execution.ExecutionSpec;
-import org.argeo.slc.execution.ExecutionSpecAttribute;
-import org.springframework.beans.factory.BeanNameAware;
-
-public class SimpleExecutionSpec implements ExecutionSpec, BeanNameAware {
-       private final static Log log = LogFactory.getLog(SimpleExecutionSpec.class);
-
-       private final static ThreadLocal<ExecutionFlow> initializingFlow = new ThreadLocal<ExecutionFlow>();
-
-       private Map<String, ExecutionSpecAttribute> attributes = new HashMap<String, ExecutionSpecAttribute>();
-
-       private String name = null;
-
-       public Map<String, ExecutionSpecAttribute> getAttributes() {
-               return attributes;
-       }
-
-       public void setAttributes(Map<String, ExecutionSpecAttribute> attributes) {
-               this.attributes = attributes;
-       }
-
-       public Object createRef(String name) {
-               ExecutionFlow flow = initializingFlow.get();
-               if (flow == null)
-                       throw new SlcException("No flow is currently initializing."
-                                       + " Declare flow refs as inner beans or prototypes.");
-               /*
-                * RefSpecAttribute refSpecAttribute = (RefSpecAttribute) attributes
-                * .get(name); Class<?> targetClass = refSpecAttribute.getTargetClass();
-                * ExecutionTargetSource targetSource = new ExecutionTargetSource(flow,
-                * targetClass, name); ProxyFactory proxyFactory = new ProxyFactory();
-                * proxyFactory.setTargetClass(targetClass);
-                * proxyFactory.setProxyTargetClass(true);
-                * proxyFactory.setTargetSource(targetSource);
-                * 
-                * return proxyFactory.getProxy();
-                */
-               return flow.getParameter(name);
-       }
-
-       public void setBeanName(String name) {
-               this.name = name;
-       }
-
-       public String getName() {
-               return name;
-       }
-
-       // FLOWS INITIALIZATION SUPPORT
-
-       public static void flowInitializationStarted(ExecutionFlow flow) {
-               if (log.isTraceEnabled())
-                       log.trace("Start initialization of " + flow.hashCode() + " ("
-                                       + flow + " - " + flow.getClass() + ")");
-               initializingFlow.set(flow);
-       }
-
-       public static void flowInitializationFinished(ExecutionFlow flow) {
-               if (log.isTraceEnabled())
-                       log.trace("Finish initialization of " + flow.hashCode() + " ("
-                                       + flow + " - " + flow.getClass() + ")");
-               ExecutionFlow registeredFlow = initializingFlow.get();
-               if (registeredFlow != null) {
-                       if (!flow.getName().equals(registeredFlow.getName()))
-                               throw new SlcException("Current flow is " + flow);
-                       initializingFlow.set(null);
-               }
-       }
-
-       public static Object getInitializingFlowParameter(String key) {
-               if (initializingFlow.get() == null)
-                       throw new SlcException("No initializing flow available.");
-               return initializingFlow.get().getParameter(key);
-       }
-
-       public static Boolean isInFlowInitialization() {
-               return initializingFlow.get() != null;
-       }
-
-       public boolean equals(Object obj) {
-               return ((ExecutionSpec) obj).getName().equals(name);
-       }
-
-}
diff --git a/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/SimpleSpecAttribute.java b/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/SimpleSpecAttribute.java
deleted file mode 100644 (file)
index 0985375..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.argeo.slc.core.execution;
-
-public class SimpleSpecAttribute extends AbstractSpecAttribute {
-       private Object value = null;
-
-       public Object getValue() {
-               return value;
-       }
-
-       public void setValue(Object value) {
-               this.value = value;
-       }
-}
diff --git a/runtime/org.argeo.slc.support.simple/src/main/resources/org/argeo/slc/core/execution/specs.xml b/runtime/org.argeo.slc.support.simple/src/main/resources/org/argeo/slc/core/execution/specs.xml
new file mode 100644 (file)
index 0000000..1e748e5
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+       <bean id="specAttr.primitive" class="org.argeo.slc.core.execution.PrimitiveSpecAttribute"
+               abstract="true" />
+       <bean id="specAttr.ref" class="org.argeo.slc.core.execution.RefSpecAttribute"
+               abstract="true" />
+
+       <bean id="slcTemplate.simpleFlow" class="org.argeo.slc.core.execution.DefaultExecutionFlow"
+               abstract="true" />
+       <bean id="slcTemplate.simpleSpec" class="org.argeo.slc.core.execution.DefaultExecutionSpec"
+               abstract="true" />
+
+</beans>
\ No newline at end of file
index 5d684fb399f6752b5f131b13e83f4d19b8113a91..8a950fcf0b9a172b7fd100dbf9ff220b317359df 100644 (file)
@@ -7,6 +7,9 @@
        http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
 
+       <import resource="specs.xml" />
+       <import resource="tasks/core.xml" />
+
        <bean class="org.springframework.beans.factory.config.CustomScopeConfigurer">
                <property name="scopes">
                        <map>
diff --git a/runtime/org.argeo.slc.support.simple/src/main/resources/org/argeo/slc/core/execution/tasks/core.xml b/runtime/org.argeo.slc.support.simple/src/main/resources/org/argeo/slc/core/execution/tasks/core.xml
new file mode 100644 (file)
index 0000000..0051fe5
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+       <bean id="task.echo" class="org.argeo.slc.core.execution.tasks.Echo"
+               abstract="true" />
+</beans>
\ No newline at end of file