You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ge...@apache.org on 2012/06/26 14:04:01 UTC

svn commit: r1353978 - in /servicemix/smx4/features/trunk: ./ activiti/ activiti/activiti-config/ activiti/activiti-config/src/ activiti/activiti-config/src/main/ activiti/activiti-config/src/main/java/ activiti/activiti-config/src/main/java/org/ activ...

Author: gertv
Date: Tue Jun 26 12:03:58 2012
New Revision: 1353978

URL: http://svn.apache.org/viewvc?rev=1353978&view=rev
Log:
SMX4-1191: Add basic support for Activiti

Added:
    servicemix/smx4/features/trunk/activiti/
    servicemix/smx4/features/trunk/activiti/activiti-config/
    servicemix/smx4/features/trunk/activiti/activiti-config/pom.xml
    servicemix/smx4/features/trunk/activiti/activiti-config/src/
    servicemix/smx4/features/trunk/activiti/activiti-config/src/main/
    servicemix/smx4/features/trunk/activiti/activiti-config/src/main/java/
    servicemix/smx4/features/trunk/activiti/activiti-config/src/main/java/org/
    servicemix/smx4/features/trunk/activiti/activiti-config/src/main/java/org/apache/
    servicemix/smx4/features/trunk/activiti/activiti-config/src/main/java/org/apache/servicemix/
    servicemix/smx4/features/trunk/activiti/activiti-config/src/main/java/org/apache/servicemix/activiti/
    servicemix/smx4/features/trunk/activiti/activiti-config/src/main/java/org/apache/servicemix/activiti/config/
    servicemix/smx4/features/trunk/activiti/activiti-config/src/main/java/org/apache/servicemix/activiti/config/CamelAwareELResolver.java
    servicemix/smx4/features/trunk/activiti/activiti-config/src/main/resources/
    servicemix/smx4/features/trunk/activiti/activiti-config/src/main/resources/OSGI-INF/
    servicemix/smx4/features/trunk/activiti/activiti-config/src/main/resources/OSGI-INF/blueprint/
    servicemix/smx4/features/trunk/activiti/activiti-config/src/main/resources/OSGI-INF/blueprint/activiti-config.xml
    servicemix/smx4/features/trunk/activiti/activiti-config/src/test/
    servicemix/smx4/features/trunk/activiti/activiti-config/src/test/java/
    servicemix/smx4/features/trunk/activiti/activiti-config/src/test/java/org/
    servicemix/smx4/features/trunk/activiti/activiti-config/src/test/java/org/apache/
    servicemix/smx4/features/trunk/activiti/activiti-config/src/test/java/org/apache/servicemix/
    servicemix/smx4/features/trunk/activiti/activiti-config/src/test/java/org/apache/servicemix/activiti/
    servicemix/smx4/features/trunk/activiti/activiti-config/src/test/java/org/apache/servicemix/activiti/config/
    servicemix/smx4/features/trunk/activiti/activiti-config/src/test/java/org/apache/servicemix/activiti/config/CamelAwareELResolverTest.java
    servicemix/smx4/features/trunk/activiti/pom.xml
Modified:
    servicemix/smx4/features/trunk/assemblies/apache-servicemix/src/main/filtered-resources/features.xml
    servicemix/smx4/features/trunk/parent/pom.xml
    servicemix/smx4/features/trunk/pom.xml

Added: servicemix/smx4/features/trunk/activiti/activiti-config/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/activiti/activiti-config/pom.xml?rev=1353978&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/activiti/activiti-config/pom.xml (added)
+++ servicemix/smx4/features/trunk/activiti/activiti-config/pom.xml Tue Jun 26 12:03:58 2012
@@ -0,0 +1,80 @@
+<?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/xsd/maven-4.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.
+    -->
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <artifactId>activiti</artifactId>
+        <groupId>org.apache.servicemix.activiti</groupId>
+        <version>4.5.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>org.apache.servicemix.activiti.config</artifactId>
+    <packaging>bundle</packaging>
+    <name>Apache ServiceMix :: Features :: Activiti Support :: Activiti Configuration</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.activiti</groupId>
+            <artifactId>activiti-camel</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.activiti</groupId>
+            <artifactId>activiti-engine</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.activiti</groupId>
+            <artifactId>activiti-osgi</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.easymock</groupId>
+            <artifactId>easymock</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+                        <Import-Package>*</Import-Package>
+                        <Export-Package>org.apache.servicemix.activiti.config.*</Export-Package>
+                        <Bundle-Description>${project.description}</Bundle-Description>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+
+</project>
\ No newline at end of file

Added: servicemix/smx4/features/trunk/activiti/activiti-config/src/main/java/org/apache/servicemix/activiti/config/CamelAwareELResolver.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/activiti/activiti-config/src/main/java/org/apache/servicemix/activiti/config/CamelAwareELResolver.java?rev=1353978&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/activiti/activiti-config/src/main/java/org/apache/servicemix/activiti/config/CamelAwareELResolver.java (added)
+++ servicemix/smx4/features/trunk/activiti/activiti-config/src/main/java/org/apache/servicemix/activiti/config/CamelAwareELResolver.java Tue Jun 26 12:03:58 2012
@@ -0,0 +1,77 @@
+/*
+ * 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.activiti.config;
+
+import org.activiti.camel.CamelBehaviour;
+import org.activiti.camel.ContextProvider;
+import org.activiti.osgi.blueprint.BlueprintELResolver;
+
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * Custom EL resolver that allows Activiti to interact with routes that have been defined in CamelContexts
+ * for which a ContextProvider has been registered in the service registry.
+ *
+ * All these CamelContext instances will be available through a single CamelBehaviour bean that you can access
+ * with the EL expression ${camel} in your business process definitions.
+ */
+public class CamelAwareELResolver extends BlueprintELResolver {
+
+    public static final String CAMEL_PROPERTY_NAME = "camel";
+    private final List<ContextProvider> providers = new LinkedList<ContextProvider>();
+    private final CamelBehaviour camelBehaviour = new CamelBehaviour(providers);
+
+    @Override
+    public Object getValue(org.activiti.engine.impl.javax.el.ELContext context, Object base, Object property) {
+        if (base == null && property != null && property instanceof String) {
+            String key = (String) property;
+            if (CAMEL_PROPERTY_NAME.endsWith(key)) {
+                context.setPropertyResolved(true);
+                return camelBehaviour;
+            }
+        }
+        return super.getValue(context, base, property);
+    }
+
+    /**
+     * Add a context provider to the global ${camel} variable
+     *
+     * @param provider the context provider
+     */
+    public void addContextProvider(ContextProvider provider) {
+        providers.add(provider);
+    }
+
+    /**
+     * Remove a context provider from the global ${camel} variable
+     *
+     * @param provider the context provider
+     */
+    public void removeContextProvider(ContextProvider provider) {
+        providers.remove(provider);
+    }
+
+    /**
+     * Access the {@link CamelBehaviour} instance that is being returned
+     *
+     * @return the {@link CamelBehaviour} instance
+     */
+    protected CamelBehaviour getCamelBehaviour() {
+        return camelBehaviour;
+    }
+}

Added: servicemix/smx4/features/trunk/activiti/activiti-config/src/main/resources/OSGI-INF/blueprint/activiti-config.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/activiti/activiti-config/src/main/resources/OSGI-INF/blueprint/activiti-config.xml?rev=1353978&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/activiti/activiti-config/src/main/resources/OSGI-INF/blueprint/activiti-config.xml (added)
+++ servicemix/smx4/features/trunk/activiti/activiti-config/src/main/resources/OSGI-INF/blueprint/activiti-config.xml Tue Jun 26 12:03:58 2012
@@ -0,0 +1,74 @@
+<?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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0">
+
+    <ext:property-placeholder />
+
+    <!--
+      Setting up the process engine configuration, using an embedded H2 database together with our default Aries
+      transaction manager.
+    -->
+    <bean id="dataSource" class="org.h2.jdbcx.JdbcDataSource">
+        <property name="URL" value="jdbc:h2:file:${karaf.data}/activiti/database;DB_CLOSE_ON_EXIT=FALSE"/>
+        <property name="user" value="sa"/>
+        <property name="password" value=""/>
+    </bean>
+
+    <reference id="transactionManager" interface="javax.transaction.TransactionManager"/>
+
+    <bean id="configuration" class="org.activiti.engine.impl.cfg.JtaProcessEngineConfiguration" ext:field-injection="true">
+        <property name="databaseType" value="h2"/>
+        <property name="dataSource" ref="dataSource"/>
+        <property name="transactionManager" ref="transactionManager"/>
+        <property name="databaseSchemaUpdate" value="true"/>
+    </bean>
+
+    <!--
+      Set up the custom resolver implementation to ease integration with Camel routes
+    -->
+    <bean id="resolver" class="org.apache.servicemix.activiti.config.CamelAwareELResolver"/>
+
+    <reference-list availability="optional" interface="org.activiti.camel.ContextProvider">
+        <reference-listener ref="resolver" bind-method="addContextProvider" unbind-method="removeContextProvider" />
+    </reference-list>
+
+    <reference-list availability="optional" interface="org.activiti.engine.delegate.JavaDelegate">
+        <reference-listener ref="resolver" bind-method="bindService" unbind-method="unbindService" />
+    </reference-list>
+
+    <!--
+      Set up the Activiti process engine itself
+    -->
+    <bean id="processEngineFactory" class="org.activiti.osgi.blueprint.ProcessEngineFactoryWithELResolver" init-method="init" destroy-method="destroy">
+        <property name="processEngineConfiguration" ref="configuration"/>
+        <property name="bundle" ref="blueprintBundle"/>
+        <property name="blueprintELResolver" ref="resolver" />
+    </bean>
+
+    <bean id="processEngine" factory-ref="processEngineFactory" factory-method="getObject"/>
+
+    <bean id="runtimeService" factory-ref="processEngine" factory-method="getRuntimeService" />
+
+    <!--
+      Register the ProcessEngine and RuntimeService as OSGi services to allow other bundles to use them
+    -->
+    <service ref="processEngine" interface="org.activiti.engine.ProcessEngine"/>
+    <service ref="runtimeService" interface="org.activiti.engine.RuntimeService"/>
+
+</blueprint>
\ No newline at end of file

Added: servicemix/smx4/features/trunk/activiti/activiti-config/src/test/java/org/apache/servicemix/activiti/config/CamelAwareELResolverTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/activiti/activiti-config/src/test/java/org/apache/servicemix/activiti/config/CamelAwareELResolverTest.java?rev=1353978&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/activiti/activiti-config/src/test/java/org/apache/servicemix/activiti/config/CamelAwareELResolverTest.java (added)
+++ servicemix/smx4/features/trunk/activiti/activiti-config/src/test/java/org/apache/servicemix/activiti/config/CamelAwareELResolverTest.java Tue Jun 26 12:03:58 2012
@@ -0,0 +1,35 @@
+package org.apache.servicemix.activiti.config;
+
+import org.activiti.engine.impl.javax.el.ELContext;
+import org.junit.Test;
+
+import static org.apache.servicemix.activiti.config.CamelAwareELResolver.CAMEL_PROPERTY_NAME;
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.*;
+
+/**
+ * Tests for {@link CamelAwareELResolver}
+ */
+public class CamelAwareELResolverTest {
+
+    private final CamelAwareELResolver resolver = new CamelAwareELResolver();
+
+    @Test
+    public void testGetValue() {
+        assertNull(resolver.getValue(null, null, null));
+        assertNull(resolver.getValue(null, null, "NonCamelProperty"));
+
+        ELContext context = expectELContextResolved();
+        assertSame(resolver.getCamelBehaviour(), resolver.getValue(context, null, CAMEL_PROPERTY_NAME));
+    }
+
+    /*
+     * Set up a mock ELContext that expects the property to get resolved
+     */
+    private ELContext expectELContextResolved() {
+        ELContext context = createMock(ELContext.class);
+        context.setPropertyResolved(true);
+        replay(context);
+        return context;
+    }
+}

Added: servicemix/smx4/features/trunk/activiti/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/activiti/pom.xml?rev=1353978&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/activiti/pom.xml (added)
+++ servicemix/smx4/features/trunk/activiti/pom.xml Tue Jun 26 12:03:58 2012
@@ -0,0 +1,40 @@
+<?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/xsd/maven-4.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.
+    -->
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.servicemix</groupId>
+        <artifactId>parent</artifactId>
+        <version>4.5.0-SNAPSHOT</version>
+        <relativePath>../parent/pom.xml</relativePath>
+    </parent>
+
+    <groupId>org.apache.servicemix.activiti</groupId>
+    <artifactId>activiti</artifactId>
+    <packaging>pom</packaging>
+    <name>Apache ServiceMix :: Features :: Activiti Support</name>
+
+    <modules>
+        <module>activiti-config</module>
+    </modules>
+
+</project>

Modified: servicemix/smx4/features/trunk/assemblies/apache-servicemix/src/main/filtered-resources/features.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/assemblies/apache-servicemix/src/main/filtered-resources/features.xml?rev=1353978&r1=1353977&r2=1353978&view=diff
==============================================================================
--- servicemix/smx4/features/trunk/assemblies/apache-servicemix/src/main/filtered-resources/features.xml (original)
+++ servicemix/smx4/features/trunk/assemblies/apache-servicemix/src/main/filtered-resources/features.xml Tue Jun 26 12:03:58 2012
@@ -314,4 +314,19 @@
         <feature version="${activemq.version}">activemq-blueprint</feature>
         <bundle>blueprint:file:etc/activemq-broker.xml</bundle>
     </feature>
+
+    <!-- Activiti support -->
+    <feature name="activiti" version="${activiti.version}" resolver="(obr)">
+        <feature version="${cxf.version}">cxf-specs</feature>
+        <feature version="${aries.version}">transaction</feature>
+        <bundle dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.wsdl4j/${wsdl4j.bundle.version}</bundle>
+        <bundle dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.mybatis/${mybatis.bundle.version}</bundle>
+        <bundle dependency="true">mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.scripting-api-1.0/${servicemix.specs.version}</bundle>
+        <bundle dependency="true">mvn:commons-lang/commons-lang/${commons-lang.version}</bundle>
+        <bundle>mvn:org.activiti/activiti-engine/${activiti.version}</bundle>
+        <bundle>mvn:org.activiti/activiti-osgi/${activiti.version}</bundle>
+        <bundle>mvn:org.activiti/activiti-camel/${activiti.version}</bundle>
+        <bundle>mvn:org.apche.servicemix.activiti/org.apache.servicemix.activiti.config/${project.version}</bundle>
+    </feature>
+
 </features>

Modified: servicemix/smx4/features/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/parent/pom.xml?rev=1353978&r1=1353977&r2=1353978&view=diff
==============================================================================
--- servicemix/smx4/features/trunk/parent/pom.xml (original)
+++ servicemix/smx4/features/trunk/parent/pom.xml Tue Jun 26 12:03:58 2012
@@ -38,6 +38,7 @@
   <!-- Properties -->
   <properties>
     <activemq.version>5.5.1</activemq.version>
+    <activiti.version>5.9</activiti.version>
     <camel.version>2.9.0</camel.version>
     <cxf.version>2.6.1</cxf.version>
 
@@ -86,7 +87,24 @@
         <version>${project.version}</version>
       </dependency>
 
-      <!-- ServiceMix NMR -->
+      <dependency>
+        <groupId>org.activiti</groupId>
+        <artifactId>activiti-camel</artifactId>
+        <version>${activiti.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.activiti</groupId>
+        <artifactId>activiti-engine</artifactId>
+        <version>${activiti.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.activiti</groupId>
+        <artifactId>activiti-osgi</artifactId>
+        <version>${activiti.version}</version>
+      </dependency>
+
+
+        <!-- ServiceMix NMR -->
       <dependency>
         <groupId>org.apache.servicemix.nmr</groupId>
         <artifactId>apache-servicemix-nmr</artifactId>

Modified: servicemix/smx4/features/trunk/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/pom.xml?rev=1353978&r1=1353977&r2=1353978&view=diff
==============================================================================
--- servicemix/smx4/features/trunk/pom.xml (original)
+++ servicemix/smx4/features/trunk/pom.xml Tue Jun 26 12:03:58 2012
@@ -37,6 +37,7 @@
 
     <modules>
         <module>parent</module>
+        <module>activiti</module>
         <module>branding</module>
         <module>camel</module>
         <module>cxf</module>
@@ -106,6 +107,18 @@
                 <enabled>false</enabled>
             </snapshots>
         </repository>
+        <!-- Alfresco repository contains Activiti artifacts -->
+        <repository>
+            <id>alfresco.public</id>
+            <name>Alfresco Public Repository</name>
+            <url>https://maven.alfresco.com/nexus/content/groups/public</url>
+            <releases>
+                <enabled>true</enabled>
+            </releases>
+            <snapshots>
+                <enabled>false</enabled>
+            </snapshots>
+        </repository>
     </repositories>
 
     <properties>
@@ -155,6 +168,7 @@
         <josql.bundle.version>1.5_4</josql.bundle.version>
         <jsmpp.bundle.version>2.1.0_2</jsmpp.bundle.version>
         <mvel.bundle.version>2.0.8_4</mvel.bundle.version>
+        <mybatis.bundle.version>3.0.2_1</mybatis.bundle.version>
         <opensaml.bundle.version>2.4.1_1</opensaml.bundle.version>
         <jodatime.bundle.version>1.5.2_2</jodatime.bundle.version>
         <oscore.bundle.version>2.2.4_4</oscore.bundle.version>
@@ -191,6 +205,7 @@
         <axiom.version>1.2.12</axiom.version>
         <bouncycastle.version>140</bouncycastle.version>
         <commons-jexl.version>2.0.1</commons-jexl.version>
+        <commons-lang.version>2.6</commons-lang.version>
         <commons-logging.version>1.1.1</commons-logging.version>
         <drools.version>5.1.1</drools.version>
         <groovy.version>1.8.3</groovy.version>