You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by lh...@apache.org on 2008/02/26 00:51:58 UTC
svn commit: r631042 [1/2] - in /servicemix/smx3/branches/servicemix-3.2: ./
archetypes/ archetypes/servicemix-archetypes-itests/
archetypes/servicemix-archetypes-itests/src/test/java/org/apache/servicemix/tooling/
archetypes/servicemix-osworkflow-servi...
Author: lhein
Date: Mon Feb 25 15:51:46 2008
New Revision: 631042
URL: http://svn.apache.org/viewvc?rev=631042&view=rev
Log:
- added OSWorkflow component (SM-1155)
Added:
servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-archetypes-itests/src/test/java/org/apache/servicemix/tooling/OSWorkflowServiceUnitTest.java
servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/
servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/pom.xml
servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/
servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/
servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/
servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/META-INF/
servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/META-INF/maven/
servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/META-INF/maven/archetype.xml
servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/
servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/pom.xml
servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/src/
servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/src/main/
servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/src/main/java/
servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/src/main/java/ExampleCondition.java
servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/src/main/java/ExampleFunction.java
servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/src/main/resources/
servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/src/main/resources/exampleflow.xml
servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/src/main/resources/osworkflow.xml
servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/src/main/resources/workflows.xml
servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/src/main/resources/xbean.xml
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/pom.xml
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/main/
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/main/java/
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/main/java/org/
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/main/java/org/apache/
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/main/java/org/apache/servicemix/
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/main/java/org/apache/servicemix/osworkflow/
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/main/java/org/apache/servicemix/osworkflow/OSWorkflow.java
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/main/java/org/apache/servicemix/osworkflow/OSWorkflowBootstrap.java
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/main/java/org/apache/servicemix/osworkflow/OSWorkflowComponent.java
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/main/java/org/apache/servicemix/osworkflow/OSWorkflowEndpoint.java
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/main/java/org/apache/servicemix/osworkflow/WorkflowManager.java
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/main/java/org/apache/servicemix/osworkflow/package.html
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/test/
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/test/java/
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/test/java/org/
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/test/java/org/apache/
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/test/java/org/apache/servicemix/
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/test/java/org/apache/servicemix/osworkflow/
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/test/java/org/apache/servicemix/osworkflow/OSWorkflowFailureTest.java
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/test/java/org/apache/servicemix/osworkflow/OSWorkflowSucessTest.java
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/test/java/org/apache/servicemix/osworkflow/conditions/
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/test/java/org/apache/servicemix/osworkflow/conditions/ExampleCondition.java
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/test/java/org/apache/servicemix/osworkflow/functions/
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/test/java/org/apache/servicemix/osworkflow/functions/AnswerExampleFunction.java
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/test/java/org/apache/servicemix/osworkflow/functions/ExampleFunction.java
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/test/java/org/apache/servicemix/osworkflow/functions/FailExampleFunction.java
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/test/resources/
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/test/resources/exampleflow.xml
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/test/resources/log4j-tests.properties
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/test/resources/log4j.properties
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/test/resources/osworkflow.xml
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/test/resources/spring.xml
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/test/resources/workflows.xml
Modified:
servicemix/smx3/branches/servicemix-3.2/archetypes/pom.xml
servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-archetypes-itests/pom.xml
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/pom.xml
servicemix/smx3/branches/servicemix-3.2/distributions/apache-servicemix/pom.xml
servicemix/smx3/branches/servicemix-3.2/distributions/apache-servicemix/src/main/release/bin/smx-arch
servicemix/smx3/branches/servicemix-3.2/distributions/apache-servicemix/src/main/release/bin/smx-arch.bat
servicemix/smx3/branches/servicemix-3.2/pom.xml
Modified: servicemix/smx3/branches/servicemix-3.2/archetypes/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/archetypes/pom.xml?rev=631042&r1=631041&r2=631042&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/archetypes/pom.xml (original)
+++ servicemix/smx3/branches/servicemix-3.2/archetypes/pom.xml Mon Feb 25 15:51:46 2008
@@ -59,6 +59,7 @@
<module>servicemix-archetypes-itests</module>
<module>servicemix-cxf-bc-service-unit</module>
<module>servicemix-cxf-se-service-unit</module>
+ <module>servicemix-osworkflow-service-unit</module>
</modules>
<build>
Modified: servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-archetypes-itests/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-archetypes-itests/pom.xml?rev=631042&r1=631041&r2=631042&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-archetypes-itests/pom.xml (original)
+++ servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-archetypes-itests/pom.xml Mon Feb 25 15:51:46 2008
@@ -166,6 +166,11 @@
<artifactId>servicemix-cxf-bc-service-unit</artifactId>
<version>${servicemix-version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.servicemix</groupId>
+ <artifactId>servicemix-osworkflow-service-unit</artifactId>
+ <version>${servicemix-version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.servicemix</groupId>
@@ -220,6 +225,11 @@
<dependency>
<groupId>org.apache.servicemix</groupId>
<artifactId>servicemix-saxon</artifactId>
+ <version>${servicemix-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicemix</groupId>
+ <artifactId>servicemix-osworkflow</artifactId>
<version>${servicemix-version}</version>
</dependency>
</dependencies>
Added: servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-archetypes-itests/src/test/java/org/apache/servicemix/tooling/OSWorkflowServiceUnitTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-archetypes-itests/src/test/java/org/apache/servicemix/tooling/OSWorkflowServiceUnitTest.java?rev=631042&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-archetypes-itests/src/test/java/org/apache/servicemix/tooling/OSWorkflowServiceUnitTest.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-archetypes-itests/src/test/java/org/apache/servicemix/tooling/OSWorkflowServiceUnitTest.java Mon Feb 25 15:51:46 2008
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.tooling;
+
+public class OSWorkflowServiceUnitTest extends AbstractArchetypeTest {
+
+ public void testOSWorkflowServiceUnit() throws Exception {
+ testServiceMixArchetype("osworkflow-service-unit");
+ }
+
+}
Added: servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/pom.xml?rev=631042&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/pom.xml (added)
+++ servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/pom.xml Mon Feb 25 15:51:46 2008
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.servicemix</groupId>
+ <artifactId>archetypes</artifactId>
+ <version>3.2.2-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.apache.servicemix.tooling</groupId>
+ <artifactId>servicemix-osworkflow-service-unit</artifactId>
+ <name>ServiceMix :: Archetypes :: OSWorkflowServiceUnit</name>
+
+</project>
Added: servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/META-INF/maven/archetype.xml
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/META-INF/maven/archetype.xml?rev=631042&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/META-INF/maven/archetype.xml (added)
+++ servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/META-INF/maven/archetype.xml Mon Feb 25 15:51:46 2008
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<archetype>
+ <id>servicemix-osworkflow-service-unit</id>
+ <sources>
+ <source>src/main/java/ExampleCondition.java</source>
+ <source>src/main/java/ExampleFunction.java</source>
+ </sources>
+ <resources>
+ <resource>src/main/resources/xbean.xml</resource>
+ <resource>src/main/resources/osworkflow.xml</resource>
+ <resource>src/main/resources/workflows.xml</resource>
+ <resource>src/main/resources/exampleflow.xml</resource>
+ </resources>
+</archetype>
Added: servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/pom.xml?rev=631042&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/pom.xml (added)
+++ servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/pom.xml Mon Feb 25 15:51:46 2008
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>${groupId}</groupId>
+ <artifactId>${artifactId}</artifactId>
+ <packaging>jbi-service-unit</packaging>
+ <version>${version}</version>
+ <name>A custom project</name>
+ <url>http://www.myorganization.org</url>
+ @{repositories}
+ <properties>
+ <servicemix-version>@{servicemix-version}</servicemix-version>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.servicemix</groupId>
+ <artifactId>servicemix-shared</artifactId>
+ <version>${servicemix-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicemix</groupId>
+ <artifactId>servicemix-core</artifactId>
+ <version>${servicemix-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicemix</groupId>
+ <artifactId>servicemix-osworkflow</artifactId>
+ <version>${servicemix-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.servicemix.tooling</groupId>
+ <artifactId>jbi-maven-plugin</artifactId>
+ <version>${servicemix-version}</version>
+ <extensions>true</extensions>
+ <configuration>
+ <type>service-unit</type>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/src/main/java/ExampleCondition.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/src/main/java/ExampleCondition.java?rev=631042&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/src/main/java/ExampleCondition.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/src/main/java/ExampleCondition.java Mon Feb 25 15:51:46 2008
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ${packageName};
+
+import java.util.Map;
+
+import com.opensymphony.module.propertyset.PropertySet;
+import com.opensymphony.workflow.Condition;
+import com.opensymphony.workflow.WorkflowException;
+
+public class ExampleCondition implements Condition {
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.opensymphony.workflow.Condition#passesCondition(java.util.Map,
+ * java.util.Map, com.opensymphony.module.propertyset.PropertySet)
+ */
+ public boolean passesCondition(Map transientVars, Map args, PropertySet propertySet) throws WorkflowException
+ {
+ boolean result = false;
+
+ if (propertySet.exists("ExampleKey"))
+ {
+ if (propertySet.getString("ExampleKey").equals("ExampleValue"))
+ {
+ result = true;
+ }
+ else
+ {
+ result = false;
+ }
+ }
+ else
+ {
+ result = false;
+ }
+
+ return result;
+ }
+}
Added: servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/src/main/java/ExampleFunction.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/src/main/java/ExampleFunction.java?rev=631042&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/src/main/java/ExampleFunction.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/src/main/java/ExampleFunction.java Mon Feb 25 15:51:46 2008
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ${packageName};
+
+import java.util.Map;
+
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.xml.transform.dom.DOMSource;
+
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.osworkflow.OSWorkflow;
+import org.apache.servicemix.osworkflow.OSWorkflowEndpoint;
+import org.apache.xpath.CachedXPathAPI;
+import org.w3c.dom.Node;
+
+import com.opensymphony.module.propertyset.PropertySet;
+import com.opensymphony.workflow.FunctionProvider;
+import com.opensymphony.workflow.WorkflowException;
+
+public class ExampleFunction implements FunctionProvider {
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.opensymphony.workflow.FunctionProvider#execute(java.util.Map,
+ * java.util.Map, com.opensymphony.module.propertyset.PropertySet)
+ */
+ public void execute(Map transientVars, Map args, PropertySet propertySet) throws WorkflowException
+ {
+ NormalizedMessage msg = null;
+ OSWorkflowEndpoint ep = null;
+ boolean isAsynchron = false;
+ MessageExchange exchange = null;
+
+ if (transientVars.containsKey(OSWorkflow.KEY_ASYNC_PROCESSING))
+ {
+ isAsynchron = (Boolean)transientVars.get(OSWorkflow.KEY_ASYNC_PROCESSING);
+ }
+ else
+ {
+ throw new WorkflowException("ExampleFunction: Missing transient variable for async object. (" + OSWorkflow.KEY_ASYNC_PROCESSING + ")");
+ }
+
+ if (transientVars.containsKey(OSWorkflow.KEY_EXCHANGE))
+ {
+ exchange = (MessageExchange)transientVars.get(OSWorkflow.KEY_EXCHANGE);
+ }
+ else
+ {
+ throw new WorkflowException("ExampleFunction: Missing transient variable for exchange object. (" + OSWorkflow.KEY_EXCHANGE + ")");
+ }
+
+ if (transientVars.containsKey(OSWorkflow.KEY_IN_MESSAGE))
+ {
+ msg = (NormalizedMessage)transientVars.get(OSWorkflow.KEY_IN_MESSAGE);
+ }
+ else
+ {
+ throw new WorkflowException("ExampleFunction: Missing transient variable for message object. (" + OSWorkflow.KEY_IN_MESSAGE + ")");
+ }
+
+ if (transientVars.containsKey(OSWorkflow.KEY_ENDPOINT))
+ {
+ ep = (OSWorkflowEndpoint)transientVars.get(OSWorkflow.KEY_ENDPOINT);
+ }
+ else
+ {
+ throw new WorkflowException("ExampleFunction: Missing transient variable for endpoint object. (" + OSWorkflow.KEY_ENDPOINT + ")");
+ }
+
+ SourceTransformer sourceTransformer = new SourceTransformer();
+
+ try
+ {
+ DOMSource inMessageXml = (DOMSource)sourceTransformer.toDOMSource(msg.getContent());
+
+ // Parse out the actual message content
+ CachedXPathAPI xpath = new CachedXPathAPI();
+
+ Node exampleNode = xpath.selectSingleNode(inMessageXml.getNode(), "/example");
+
+ if (exampleNode != null)
+ {
+ String value = exampleNode.getTextContent();
+ propertySet.setString("ExampleKey", value);
+ }
+ else
+ {
+ throw new WorkflowException("ExampleFunction: Missing tag: example");
+ }
+ }
+ catch (Exception ex)
+ {
+ throw new WorkflowException(ex);
+ }
+ finally
+ {
+ // if the exchange came as asynchronous inOnly or RobustInOnly
+ // we will now send a receipt to the sender
+ try
+ {
+ if (isAsynchron)
+ {
+ ep.done(exchange);
+ }
+ }
+ catch (MessagingException mex)
+ {
+ throw new WorkflowException(mex);
+ }
+ }
+ }
+}
Added: servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/src/main/resources/exampleflow.xml
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/src/main/resources/exampleflow.xml?rev=631042&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/src/main/resources/exampleflow.xml (added)
+++ servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/src/main/resources/exampleflow.xml Mon Feb 25 15:51:46 2008
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<!DOCTYPE workflow PUBLIC
+ "-//OpenSymphony Group//DTD OSWorkflow 2.8//EN"
+ "http://www.opensymphony.com/osworkflow/workflow_2_8.dtd">
+<workflow>
+
+ <initial-actions>
+ <action id="1" name="Start Workflow">
+ <results>
+ <unconditional-result old-status="Finished" status="Queued" step="1"/>
+ </results>
+ </action>
+ </initial-actions>
+
+ <steps>
+
+ <step id="1" name="Example Step">
+ <actions>
+
+ <action id="2" name="Examine Message Exchange">
+ <restrict-to>
+ <conditions>
+ <condition type="class">
+ <arg name="class.name">
+ com.opensymphony.workflow.util.StatusCondition </arg>
+ <arg name="status">Queued</arg>
+ </condition>
+ </conditions>
+ </restrict-to>
+
+ <pre-functions>
+ <function type="class">
+ <arg name="class.name"> ${packageName}.ExampleFunction </arg>
+ </function>
+ </pre-functions>
+
+ <results>
+ <unconditional-result old-status="Finished" status="Examined" step="-1"/>
+ </results>
+ </action>
+
+ <action id="3" name="Finish Example">
+ <restrict-to>
+ <conditions type="AND">
+ <condition type="class">
+ <arg name="class.name">
+ com.opensymphony.workflow.util.StatusCondition </arg>
+ <arg name="status">Examined</arg>
+ </condition>
+ <condition type="class">
+ <arg name="class.name">
+ ${packageName}.ExampleCondition </arg>
+ </condition>
+ </conditions>
+ </restrict-to>
+
+ <results>
+ <unconditional-result old-status="Finished" status="Evaluated" step="2"/>
+ </results>
+
+ </action>
+
+ </actions>
+ </step>
+
+ <step id="2" name="finished" />
+
+ </steps>
+</workflow>
Added: servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/src/main/resources/osworkflow.xml
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/src/main/resources/osworkflow.xml?rev=631042&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/src/main/resources/osworkflow.xml (added)
+++ servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/src/main/resources/osworkflow.xml Mon Feb 25 15:51:46 2008
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<osworkflow>
+ <persistence class="com.opensymphony.workflow.spi.memory.MemoryWorkflowStore"/>
+ <factory class="com.opensymphony.workflow.loader.XMLWorkflowFactory">
+ <property key="resource" value="workflows.xml" />
+ </factory>
+</osworkflow>
\ No newline at end of file
Added: servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/src/main/resources/workflows.xml
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/src/main/resources/workflows.xml?rev=631042&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/src/main/resources/workflows.xml (added)
+++ servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/src/main/resources/workflows.xml Mon Feb 25 15:51:46 2008
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<workflows>
+ <workflow name="exampleflow" type="resource" location="exampleflow.xml"/>
+</workflows>
Added: servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/src/main/resources/xbean.xml
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/src/main/resources/xbean.xml?rev=631042&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/src/main/resources/xbean.xml (added)
+++ servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-osworkflow-service-unit/src/main/resources/archetype-resources/src/main/resources/xbean.xml Mon Feb 25 15:51:46 2008
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+
+<beans xmlns:osworkflow="http://servicemix.apache.org/osworkflow/1.0"
+ xmlns:replaceMe="http://servicemix.apache.org/replaceMe">
+
+ <osworkflow:endpoint service="replaceMe:myworkflow"
+ endpoint="myWorkflowEndpoint"
+ action="1"
+ caller="myWorkflowUser"
+ workflowName="exampleflow" />
+
+</beans>
Modified: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/pom.xml?rev=631042&r1=631041&r2=631042&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/pom.xml (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/pom.xml Mon Feb 25 15:51:46 2008
@@ -42,6 +42,7 @@
<module>servicemix-eip</module>
<module>servicemix-jsr181</module>
<module>servicemix-lwcontainer</module>
+ <module>servicemix-osworkflow</module>
<module>servicemix-quartz</module>
<module>servicemix-saxon</module>
<module>servicemix-script</module>
Added: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/pom.xml?rev=631042&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/pom.xml (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/pom.xml Mon Feb 25 15:51:46 2008
@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+ <parent>
+ <groupId>org.apache.servicemix</groupId>
+ <artifactId>serviceengines</artifactId>
+ <version>3.2.2-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.servicemix</groupId>
+ <artifactId>servicemix-osworkflow</artifactId>
+ <packaging>jbi-component</packaging>
+ <name>ServiceMix :: OSWorkflow</name>
+ <description>OSWorkflow Service Engine</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.servicemix</groupId>
+ <artifactId>servicemix-shared</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicemix</groupId>
+ <artifactId>servicemix-core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>opensymphony</groupId>
+ <artifactId>osworkflow</artifactId>
+ <version>2.7.0</version>
+ </dependency>
+ <dependency>
+ <groupId>opensymphony</groupId>
+ <artifactId>oscore</artifactId>
+ <version>2.2.4</version>
+ </dependency>
+ <dependency>
+ <groupId>opensymphony</groupId>
+ <artifactId>propertyset</artifactId>
+ <version>1.3</version>
+ </dependency>
+ <dependency>
+ <groupId>opensymphony</groupId>
+ <artifactId>quartz</artifactId>
+ <version>1.5.2</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>bsh</groupId>
+ <artifactId>bsh</artifactId>
+ <version>1.3.0</version>
+ </dependency>
+ <dependency>
+ <groupId>bsf</groupId>
+ <artifactId>bsf</artifactId>
+ <version>2.3.0</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.servicemix.tooling</groupId>
+ <artifactId>jbi-maven-plugin</artifactId>
+ <version>${servicemix-version}</version>
+ <extensions>true</extensions>
+ <configuration>
+ <type>service-engine</type>
+ <bootstrap>org.apache.servicemix.osworkflow.OSWorkflowBootstrap</bootstrap>
+ <component>org.apache.servicemix.osworkflow.OSWorkflowComponent</component>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.xbean</groupId>
+ <artifactId>maven-xbean-plugin</artifactId>
+ <version>${xbean-version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>mapping</goal>
+ </goals>
+ <configuration>
+ <namespace>http://servicemix.apache.org/osworkflow/1.0</namespace>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <workingDirectory>${basedir}</workingDirectory>
+ <includes>
+ <include>**/*Test.*</include>
+ </includes>
+ <excludes>
+ <!-- exclude abstract test cases -->
+ <exclude>**/Abstract*.*</exclude>
+
+ <!-- TODO -->
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+
+ </build>
+
+</project>
Added: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/main/java/org/apache/servicemix/osworkflow/OSWorkflow.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/main/java/org/apache/servicemix/osworkflow/OSWorkflow.java?rev=631042&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/main/java/org/apache/servicemix/osworkflow/OSWorkflow.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/main/java/org/apache/servicemix/osworkflow/OSWorkflow.java Mon Feb 25 15:51:46 2008
@@ -0,0 +1,195 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.osworkflow;
+
+import java.util.Map;
+
+import javax.jbi.messaging.InOnly;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.RobustInOnly;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.opensymphony.workflow.InvalidInputException;
+import com.opensymphony.workflow.InvalidRoleException;
+import com.opensymphony.workflow.Workflow;
+import com.opensymphony.workflow.WorkflowException;
+import com.opensymphony.workflow.basic.BasicWorkflow;
+import com.opensymphony.workflow.config.DefaultConfiguration;
+
+/**
+ * @author lhe
+ */
+public class OSWorkflow extends Thread {
+ private static Log log = LogFactory.getLog(OSWorkflow.class);
+
+ public static final String KEY_EXCHANGE = "exchange";
+
+ public static final String KEY_IN_MESSAGE = "in-message";
+
+ public static final String KEY_ENDPOINT = "endpoint";
+
+ public static final String KEY_CALLER = "caller";
+
+ public static final String KEY_ASYNC_PROCESSING = "asynchronous";
+
+ private Workflow osWorkflowInstance = null;
+
+ private String caller = null;
+
+ private String osWorkflowName = null;
+
+ private Map map = null;
+
+ private int action = -1;
+
+ private long workflowId = -1l;
+
+ private boolean finished = false;
+
+ private boolean aborted = false;
+
+ private OSWorkflowEndpoint endpoint = null;
+
+ private MessageExchange exchange = null;
+
+ /**
+ * creates and initializes a new workflow object
+ *
+ * @param ep
+ * the endpoint reference
+ * @param workflowName
+ * the unique workflow name as defined in workflows.xml
+ * @param action
+ * the initial action
+ * @param map
+ * the value map
+ * @param caller
+ * the caller
+ * @param exchange
+ * the received message exchange
+ */
+ public OSWorkflow(OSWorkflowEndpoint ep, String workflowName, int action,
+ Map map, String caller, MessageExchange exchange) {
+ super(workflowName);
+ setDaemon(true);
+
+ this.endpoint = ep; // remember the endpoint which called the osworkflow
+ this.osWorkflowName = workflowName;
+ this.osWorkflowInstance = null;
+ this.action = action;
+ this.map = map;
+ this.caller = caller;
+ this.exchange = exchange;
+
+ // now fill the transient vars with some useful objects
+ this.map.put(KEY_ENDPOINT, this.endpoint);
+ this.map.put(KEY_CALLER, this.caller);
+ this.map.put(KEY_IN_MESSAGE, this.exchange.getMessage("in"));
+ this.map.put(KEY_EXCHANGE, this.exchange);
+ this.map
+ .put(
+ KEY_ASYNC_PROCESSING,
+ (this.exchange instanceof InOnly || this.exchange instanceof RobustInOnly));
+ }
+
+ /**
+ * initializes the workflow and a default config
+ *
+ * @return the unique workflow id
+ */
+ private long createWorkflow() throws InvalidRoleException,
+ InvalidInputException, WorkflowException {
+ this.osWorkflowInstance = new BasicWorkflow(this.caller);
+ DefaultConfiguration config = new DefaultConfiguration();
+ this.osWorkflowInstance.setConfiguration(config);
+ long workflowId = this.osWorkflowInstance.initialize(
+ this.osWorkflowName, this.action, this.map);
+ return workflowId;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Thread#run()
+ */
+ @Override
+ public void run() {
+ // call the endpoint method for init actions
+ this.endpoint.preWorkflow();
+
+ log.debug("Starting workflow...");
+ log.debug("Name: " + this.osWorkflowName);
+ log.debug("Action: " + this.action);
+ log.debug("Caller: " + this.caller);
+ log.debug("Map: " + this.map);
+
+ // loop as long as there are more actions to do and the workflow is not
+ // finished or aborted
+ while (!finished && !aborted) {
+ // initial creation
+ if (this.osWorkflowInstance == null) {
+ try {
+ this.workflowId = createWorkflow();
+ } catch (Exception ex) {
+ log.error("Error creating the workflow", ex);
+ aborted = true;
+ break;
+ }
+ }
+
+ // determine the available actions
+ int[] availableActions = this.osWorkflowInstance
+ .getAvailableActions(this.workflowId, this.map);
+
+ // check if there are more actions available
+ if (availableActions.length == 0) {
+ // no, no more actions available - workflow finished
+ log.debug("No more actions. Workflow is finished...");
+ this.finished = true;
+ } else {
+ // get first available action to execute
+ int nextAction = availableActions[0];
+
+ log.debug("call action " + nextAction);
+ try {
+ // call the action
+ this.osWorkflowInstance.doAction(this.workflowId,
+ nextAction, this.map);
+ } catch (InvalidInputException iiex) {
+ log.error(iiex);
+ aborted = true;
+ } catch (WorkflowException wfex) {
+ log.error(wfex);
+ aborted = true;
+ }
+ }
+ }
+
+ log.debug("Stopping workflow...");
+ log.debug("Name: " + this.osWorkflowName);
+ log.debug("Action: " + this.action);
+ log.debug("Caller: " + this.caller);
+ log.debug("Map: " + this.map);
+ log.debug("WorkflowId: " + this.workflowId);
+ log.debug("End state: " + (finished ? "Finished" : "Aborted"));
+
+ // call the endpoint method for cleanup actions or message exchange
+ this.endpoint.postWorkflow();
+ }
+}
Added: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/main/java/org/apache/servicemix/osworkflow/OSWorkflowBootstrap.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/main/java/org/apache/servicemix/osworkflow/OSWorkflowBootstrap.java?rev=631042&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/main/java/org/apache/servicemix/osworkflow/OSWorkflowBootstrap.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/main/java/org/apache/servicemix/osworkflow/OSWorkflowBootstrap.java Mon Feb 25 15:51:46 2008
@@ -0,0 +1,183 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.osworkflow;
+
+import javax.jbi.JBIException;
+import javax.jbi.component.Bootstrap;
+import javax.jbi.component.InstallationContext;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+/**
+ * Bootstrap class. This class is useful to perform tasks at installation /
+ * uninstallation time
+ *
+ * @author lhe
+ */
+public class OSWorkflowBootstrap implements Bootstrap {
+ protected InstallationContext context;
+
+ protected ObjectName mbeanName;
+
+ /**
+ * creates a new bootstrap
+ */
+ public OSWorkflowBootstrap() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jbi.component.Bootstrap#getExtensionMBeanName()
+ */
+ public ObjectName getExtensionMBeanName() {
+ return mbeanName;
+ }
+
+ /**
+ * returns the extension mbean
+ *
+ * @return the object
+ */
+ protected Object getExtensionMBean() throws Exception {
+ return null;
+ }
+
+ /**
+ * creates the extension mbean object name
+ *
+ * @return the object name
+ * @throws Exception
+ */
+ protected ObjectName createExtensionMBeanName() throws Exception {
+ return this.context.getContext().getMBeanNames()
+ .createCustomComponentMBeanName("bootstrap");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jbi.component.Bootstrap#init(javax.jbi.component.InstallationContext)
+ */
+ public void init(InstallationContext installContext) throws JBIException {
+ try {
+ this.context = installContext;
+ doInit();
+ } catch (JBIException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new JBIException("Error calling init", e);
+ }
+ }
+
+ /**
+ *
+ * @throws Exception
+ */
+ protected void doInit() throws Exception {
+ Object mbean = getExtensionMBean();
+ if (mbean != null) {
+ this.mbeanName = createExtensionMBeanName();
+ MBeanServer server = this.context.getContext().getMBeanServer();
+ if (server == null) {
+ throw new JBIException("null mBeanServer");
+ }
+ if (server.isRegistered(this.mbeanName)) {
+ server.unregisterMBean(this.mbeanName);
+ }
+ server.registerMBean(mbean, this.mbeanName);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jbi.component.Bootstrap#cleanUp()
+ */
+ public void cleanUp() throws JBIException {
+ try {
+ doCleanUp();
+ } catch (JBIException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new JBIException("Error calling cleanUp", e);
+ }
+ }
+
+ /**
+ * clean up
+ *
+ * @throws Exception
+ */
+ protected void doCleanUp() throws Exception {
+ if (this.mbeanName != null) {
+ MBeanServer server = this.context.getContext().getMBeanServer();
+ if (server == null) {
+ throw new JBIException("null mBeanServer");
+ }
+ if (server.isRegistered(this.mbeanName)) {
+ server.unregisterMBean(this.mbeanName);
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jbi.component.Bootstrap#onInstall()
+ */
+ public void onInstall() throws JBIException {
+ try {
+ doOnInstall();
+ } catch (JBIException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new JBIException("Error calling onInstall", e);
+ }
+ }
+
+ /**
+ * called upon installation
+ *
+ * @throws Exception
+ */
+ protected void doOnInstall() throws Exception {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jbi.component.Bootstrap#onUninstall()
+ */
+ public void onUninstall() throws JBIException {
+ try {
+ doOnUninstall();
+ } catch (JBIException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new JBIException("Error calling onUninstall", e);
+ }
+ }
+
+ /**
+ * called upon uninstallation
+ *
+ * @throws Exception
+ */
+ protected void doOnUninstall() throws Exception {
+ }
+}
Added: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/main/java/org/apache/servicemix/osworkflow/OSWorkflowComponent.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/main/java/org/apache/servicemix/osworkflow/OSWorkflowComponent.java?rev=631042&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/main/java/org/apache/servicemix/osworkflow/OSWorkflowComponent.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/main/java/org/apache/servicemix/osworkflow/OSWorkflowComponent.java Mon Feb 25 15:51:46 2008
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.osworkflow;
+
+import java.util.List;
+
+import org.apache.servicemix.common.DefaultComponent;
+
+/**
+ * @org.apache.xbean.XBean element="component" description="OSWorkflow
+ * Component"
+ * @author lhe
+ */
+public class OSWorkflowComponent extends DefaultComponent {
+ private OSWorkflowEndpoint[] endpoints;
+
+ /**
+ * returns the endpoints
+ *
+ * @return the endpoints
+ */
+ public OSWorkflowEndpoint[] getEndpoints() {
+ return endpoints;
+ }
+
+ /**
+ * sets the endpoints
+ *
+ * @param endpoints
+ */
+ public void setEndpoints(OSWorkflowEndpoint[] endpoints) {
+ this.endpoints = endpoints;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.servicemix.common.DefaultComponent#getConfiguredEndpoints()
+ */
+ protected List getConfiguredEndpoints() {
+ return asList(endpoints);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.servicemix.common.DefaultComponent#getEndpointClasses()
+ */
+ protected Class[] getEndpointClasses() {
+ return new Class[] {OSWorkflowEndpoint.class};
+ }
+}
Added: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/main/java/org/apache/servicemix/osworkflow/OSWorkflowEndpoint.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/main/java/org/apache/servicemix/osworkflow/OSWorkflowEndpoint.java?rev=631042&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/main/java/org/apache/servicemix/osworkflow/OSWorkflowEndpoint.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/main/java/org/apache/servicemix/osworkflow/OSWorkflowEndpoint.java Mon Feb 25 15:51:46 2008
@@ -0,0 +1,486 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.osworkflow;
+
+import java.util.HashMap;
+
+import javax.jbi.component.ComponentContext;
+import javax.jbi.management.DeploymentException;
+import javax.jbi.messaging.DeliveryChannel;
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOnly;
+import javax.jbi.messaging.InOut;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessageExchangeFactory;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.jbi.messaging.RobustInOnly;
+import javax.jbi.messaging.MessageExchange.Role;
+import javax.jbi.servicedesc.ServiceEndpoint;
+import javax.xml.namespace.QName;
+import javax.xml.transform.Source;
+
+import org.apache.servicemix.common.Endpoint;
+import org.apache.servicemix.common.ExchangeProcessor;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+
+/**
+ * @org.apache.xbean.XBean element="endpoint"
+ *
+ * @author lhe
+ */
+public class OSWorkflowEndpoint extends Endpoint implements ExchangeProcessor {
+ private static final long TIME_OUT = 30000;
+
+ private ServiceEndpoint activated;
+
+ private DeliveryChannel channel;
+
+ private MessageExchangeFactory exchangeFactory;
+
+ private String workflowName;
+
+ private String caller;
+
+ private int action;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.servicemix.common.Endpoint#getRole()
+ */
+ public Role getRole() {
+ return Role.PROVIDER;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.servicemix.common.Endpoint#activate()
+ */
+ public void activate() throws Exception {
+ logger = this.serviceUnit.getComponent().getLogger();
+ ComponentContext ctx = getServiceUnit().getComponent()
+ .getComponentContext();
+ channel = ctx.getDeliveryChannel();
+ exchangeFactory = channel.createExchangeFactory();
+ activated = ctx.activateEndpoint(service, endpoint);
+ start();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.servicemix.common.Endpoint#deactivate()
+ */
+ public void deactivate() throws Exception {
+ stop();
+ ServiceEndpoint ep = activated;
+ activated = null;
+ ComponentContext ctx = getServiceUnit().getComponent()
+ .getComponentContext();
+ ctx.deactivateEndpoint(ep);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.servicemix.common.Endpoint#getProcessor()
+ */
+ public ExchangeProcessor getProcessor() {
+ return this;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.servicemix.common.Endpoint#validate()
+ */
+ public void validate() throws DeploymentException {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.servicemix.common.ExchangeProcessor#start()
+ */
+ public void start() throws Exception {
+ // initialize the workflow manager
+ WorkflowManager.getInstance();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.servicemix.common.ExchangeProcessor#stop()
+ */
+ public void stop() {
+ // shut down first finishing running threads
+ WorkflowManager.getInstance().prepareShutdown(true);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.servicemix.common.ExchangeProcessor#process(javax.jbi.messaging.MessageExchange)
+ */
+ public void process(MessageExchange exchange) throws Exception {
+ if (exchange == null) {
+ return;
+ }
+
+ // The component acts as a consumer, this means this exchange is
+ // received because
+ // we sent it to another component. As it is active, this is either an
+ // out or a fault
+ // If this component does not create / send exchanges, you may just
+ // throw an
+ // UnsupportedOperationException
+ if (exchange.getRole() == Role.CONSUMER) {
+ onConsumerExchange(exchange);
+ }
+
+ // The component acts as a provider, this means that another component
+ // has requested our
+ // service
+ // As this exchange is active, this is either an in or a fault (out are
+ // send by this
+ // component)
+ else if (exchange.getRole() == MessageExchange.Role.PROVIDER) {
+ onProviderExchange(exchange);
+ }
+
+ // Unknown role
+ else {
+ throw new MessagingException(
+ "OSWorkflowEndpoint.onMessageExchange(): Unknown role: "
+ + exchange.getRole());
+ }
+ }
+
+ /**
+ * handles the incoming consumer messages
+ *
+ * @param exchange
+ * @throws MessagingException
+ */
+ protected void onConsumerExchange(MessageExchange exchange)
+ throws MessagingException {
+ // Out message
+ if (exchange.getMessage("out") != null) {
+ exchange.setStatus(ExchangeStatus.DONE);
+ channel.send(exchange);
+ }
+
+ // Fault message
+ else if (exchange.getFault() != null) {
+ exchange.setStatus(ExchangeStatus.DONE);
+ channel.send(exchange);
+ }
+
+ // This is not compliant with the default MEPs
+ else {
+ throw new MessagingException(
+ "OSWorkflowEndpoint.onConsumerExchange(): Consumer exchange is ACTIVE, but no out or fault is provided");
+ }
+ }
+
+ /**
+ * handles the incoming provider messages
+ *
+ * @param exchange
+ * @throws MessagingException
+ */
+ protected void onProviderExchange(MessageExchange exchange)
+ throws MessagingException {
+ // Exchange is finished
+ if (exchange.getStatus() == ExchangeStatus.DONE) {
+ return;
+ }
+ // Exchange has been aborted with an exception
+ else if (exchange.getStatus() == ExchangeStatus.ERROR) {
+ return;
+ }
+ // Fault message
+ else if (exchange.getFault() != null) {
+ exchange.setStatus(ExchangeStatus.DONE);
+ channel.send(exchange);
+ } else {
+ NormalizedMessage in = exchange.getMessage("in");
+
+ if (in == null) {
+ // no in message - strange
+ throw new MessagingException(
+ "OSWorkflowEndpoint.onProviderExchange(): Exchange has no IN message");
+ } else {
+ // create a new workflow object
+ OSWorkflow osWorkflow = new OSWorkflow(this, this.workflowName,
+ this.action, new HashMap(), this.caller, exchange);
+
+ if (exchange instanceof InOnly
+ || exchange instanceof RobustInOnly) {
+ // do start the workflow in separate thread
+ try {
+ WorkflowManager.getInstance().executeWorkflow(
+ osWorkflow);
+ } catch (Exception ex) {
+ logger.error(ex);
+ }
+ } else {
+ // synchronous processing, keep state ACTIVE
+ // do start the workflow and join the thread
+ try {
+ osWorkflow.start();
+ osWorkflow.join();
+ } catch (Exception ex) {
+ logger.error(ex);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * returns the delivery channel for the endpoint
+ *
+ * @return the delivery channel
+ */
+ public DeliveryChannel getChannel() {
+
+ return this.channel;
+ }
+
+ /**
+ * returns the message exchange factory
+ *
+ * @return the message exchange factory
+ */
+ public MessageExchangeFactory getMessageExchangeFactory() {
+ return this.exchangeFactory;
+ }
+
+ /**
+ * sends the given DOMSource as message to the given service (inOnly)
+ *
+ * @param service
+ * the service name to send the message to
+ * @param source
+ * the source to put in the in message content
+ * @return true on sucessful delivering or false on failure
+ * @throws MessagingException
+ * on any messaging exception
+ */
+ public boolean sendMessage(QName service, Source source)
+ throws MessagingException {
+ InOnly inOnly = channel.createExchangeFactoryForService(service)
+ .createInOnlyExchange();
+ NormalizedMessage msg = inOnly.createMessage();
+ msg.setContent(source);
+ inOnly.setInMessage(msg);
+ if (channel.sendSync(inOnly)) {
+ return inOnly.getStatus() == ExchangeStatus.DONE;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * sends the given DOMSource as message to the given service (inOut)
+ *
+ * @param service
+ * the service name to send the message to
+ * @param source
+ * the source to put in the in message content
+ * @return the DOMSource of the out message or null
+ * @throws MessagingException
+ * on any messaging exception
+ */
+ public Source sendRequest(QName service, Source source)
+ throws MessagingException {
+ InOut inOut = channel.createExchangeFactoryForService(service)
+ .createInOutExchange();
+ NormalizedMessage msg = inOut.createMessage();
+ msg.setContent(source);
+ inOut.setInMessage(msg);
+
+ if (channel.sendSync(inOut)) {
+ SourceTransformer sourceTransformer = new SourceTransformer();
+
+ try {
+ Source result = sourceTransformer.toDOMSource(inOut
+ .getOutMessage().getContent());
+
+ inOut.setStatus(ExchangeStatus.DONE);
+ channel.send(inOut);
+
+ return result;
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ return null;
+ }
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * sends the given DOMSource as message to the given service (inOut)
+ *
+ * @param service
+ * the service name to send the message to
+ * @param source
+ * the source to put in the in message content
+ * @return the DOMSource of the out message or null
+ * @throws MessagingException
+ * on any messaging exception
+ */
+ public MessageExchange sendRawInOutRequest(QName service, Source source)
+ throws MessagingException {
+ InOut inOut = channel.createExchangeFactoryForService(service)
+ .createInOutExchange();
+ NormalizedMessage msg = inOut.createMessage();
+ msg.setContent(source);
+ inOut.setInMessage(msg);
+ if (channel.sendSync(inOut)) {
+ return inOut;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * creates a msg object
+ *
+ * @param qname
+ * the service which will be the receiver
+ * @param inOut
+ * should it be inOut or InOnly
+ * @return the created exchange
+ * @throws MessagingException
+ */
+ public MessageExchange getNewExchange(QName qname, boolean inOut)
+ throws MessagingException {
+ MessageExchange exchange = null;
+
+ if (inOut) {
+ exchange = channel.createExchangeFactoryForService(qname)
+ .createInOutExchange();
+ } else {
+ exchange = channel.createExchangeFactoryForService(qname)
+ .createInOnlyExchange();
+ }
+
+ return exchange;
+ }
+
+ /**
+ * sends a done to the channel
+ *
+ * @param ex
+ * @throws MessagingException
+ */
+ public void done(MessageExchange ex) throws MessagingException {
+ ex.setStatus(ExchangeStatus.DONE);
+ channel.send(ex);
+ }
+
+ /**
+ * sends a msg to the channel
+ *
+ * @param ex
+ * @param sync
+ * @throws MessagingException
+ */
+ public void send(MessageExchange ex, boolean sync)
+ throws MessagingException {
+ if (sync) {
+ channel.sendSync(ex, TIME_OUT);
+ } else {
+ channel.send(ex);
+ }
+ }
+
+ /**
+ * sends a error to the channel
+ *
+ * @param ex
+ * @throws MessagingException
+ */
+ public void fail(MessageExchange ex) throws MessagingException {
+ ex.setStatus(ExchangeStatus.ERROR);
+ channel.send(ex);
+ }
+
+ /**
+ * @return the workflowName
+ */
+ public String getWorkflowName() {
+ return this.workflowName;
+ }
+
+ /**
+ * @param workflowName
+ * the workflowName to set
+ */
+ public void setWorkflowName(String workflowName) {
+ this.workflowName = workflowName;
+ }
+
+ /**
+ * @return the caller
+ */
+ public String getCaller() {
+ return this.caller;
+ }
+
+ /**
+ * @param caller
+ * the caller to set
+ */
+ public void setCaller(String caller) {
+ this.caller = caller;
+ }
+
+ /**
+ * @return the action
+ */
+ public int getAction() {
+ return this.action;
+ }
+
+ /**
+ * @param action
+ * the action to set
+ */
+ public void setAction(int action) {
+ this.action = action;
+ }
+
+ /**
+ * init actions
+ */
+ public void preWorkflow() {
+ // nothing for now
+ }
+
+ /**
+ * cleanup action
+ */
+ public void postWorkflow() {
+ // nothing for now
+ }
+}
Added: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/main/java/org/apache/servicemix/osworkflow/WorkflowManager.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/main/java/org/apache/servicemix/osworkflow/WorkflowManager.java?rev=631042&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/main/java/org/apache/servicemix/osworkflow/WorkflowManager.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/main/java/org/apache/servicemix/osworkflow/WorkflowManager.java Mon Feb 25 15:51:46 2008
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.osworkflow;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * @author lhe
+ */
+public class WorkflowManager {
+ private static final int WORKER_COUNT = 30;
+
+ private static WorkflowManager manager = null;
+
+ private ExecutorService executor;
+
+ /**
+ * private constructor - singleton pattern
+ */
+ private WorkflowManager() {
+ executor = Executors.newFixedThreadPool(WORKER_COUNT);
+ }
+
+ /**
+ * returns the instance of the task queue
+ *
+ * @return manager instance
+ */
+ public synchronized static WorkflowManager getInstance() {
+ if (manager == null) {
+ manager = new WorkflowManager();
+ }
+ return manager;
+ }
+
+ /**
+ * executes the given runnable inside the task queue
+ *
+ * @param r
+ * a runnable object
+ */
+ public void executeWorkflow(Runnable r) {
+ executor.execute(r);
+ }
+
+ /**
+ * shuts the task queue down
+ *
+ * @param firstFinishRunningTasks
+ * true if running task should be finished before shutdown
+ */
+ public void prepareShutdown(boolean firstFinishRunningTasks) {
+ if (firstFinishRunningTasks) {
+ executor.shutdown();
+ } else {
+ executor.shutdownNow();
+ }
+ }
+}
Added: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/main/java/org/apache/servicemix/osworkflow/package.html
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/main/java/org/apache/servicemix/osworkflow/package.html?rev=631042&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/main/java/org/apache/servicemix/osworkflow/package.html (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/main/java/org/apache/servicemix/osworkflow/package.html Mon Feb 25 15:51:46 2008
@@ -0,0 +1,28 @@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<html>
+<head>
+</head>
+<body>
+
+A workflow JBI component using the
+<a href="http://www.opensymphony.com/osworkflow/">OSWorkflow</a> library
+
+</body>
+</html>
Added: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/test/java/org/apache/servicemix/osworkflow/OSWorkflowFailureTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/test/java/org/apache/servicemix/osworkflow/OSWorkflowFailureTest.java?rev=631042&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/test/java/org/apache/servicemix/osworkflow/OSWorkflowFailureTest.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/test/java/org/apache/servicemix/osworkflow/OSWorkflowFailureTest.java Mon Feb 25 15:51:46 2008
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.osworkflow;
+
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOut;
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.client.DefaultServiceMixClient;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.servicemix.tck.SpringTestSupport;
+import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+
+public class OSWorkflowFailureTest extends SpringTestSupport {
+
+ private static Log logger = LogFactory.getLog(OSWorkflowFailureTest.class);
+
+ public void test() throws Exception {
+ DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
+ InOut me = client.createInOutExchange();
+ me.setService(new QName("urn:test", "service"));
+ me.getInMessage().setContent(
+ new StringSource("<example>WrongExampleValue</example>"));
+ client.sendSync(me);
+ if (me.getStatus() == ExchangeStatus.ERROR) {
+ if (me.getFault() != null) {
+ fail("Received FAULT: "
+ + new SourceTransformer().toString(me.getFault()
+ .getContent()));
+ } else if (me.getError() != null) {
+ throw me.getError();
+ } else {
+ fail("Received ERROR status");
+ }
+ } else {
+ logger.info(new SourceTransformer().toString(me.getOutMessage()
+ .getContent()));
+ }
+ }
+
+ protected AbstractXmlApplicationContext createBeanFactory() {
+ return new ClassPathXmlApplicationContext("spring.xml");
+ }
+
+}
Added: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/test/java/org/apache/servicemix/osworkflow/OSWorkflowSucessTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/test/java/org/apache/servicemix/osworkflow/OSWorkflowSucessTest.java?rev=631042&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/test/java/org/apache/servicemix/osworkflow/OSWorkflowSucessTest.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-osworkflow/src/test/java/org/apache/servicemix/osworkflow/OSWorkflowSucessTest.java Mon Feb 25 15:51:46 2008
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.osworkflow;
+
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOut;
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.client.DefaultServiceMixClient;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.servicemix.tck.SpringTestSupport;
+import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+
+public class OSWorkflowSucessTest extends SpringTestSupport {
+
+ private static Log logger = LogFactory.getLog(OSWorkflowSucessTest.class);
+
+ public void test() throws Exception {
+ DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
+ InOut me = client.createInOutExchange();
+ me.setService(new QName("urn:test", "service"));
+ me.getInMessage().setContent(
+ new StringSource("<example>ExampleValue</example>"));
+ client.sendSync(me);
+ if (me.getStatus() == ExchangeStatus.ERROR) {
+ if (me.getFault() != null) {
+ fail("Received FAULT: "
+ + new SourceTransformer().toString(me.getFault()
+ .getContent()));
+ } else if (me.getError() != null) {
+ throw me.getError();
+ } else {
+ fail("Received ERROR status");
+ }
+ } else {
+ logger.info(new SourceTransformer().toString(me.getOutMessage()
+ .getContent()));
+ }
+ }
+
+ protected AbstractXmlApplicationContext createBeanFactory() {
+ return new ClassPathXmlApplicationContext("spring.xml");
+ }
+
+}