Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

SMX4-1191: Add basic support for Activiti

git-svn-id: https://svn.apache.org/repos/asf/servicemix/smx4/features/trunk@1353978 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
commit 90547ed01768918e376637f4aa2b943d05d9281d 1 parent 5bd3760
Gert Vanthienen gertv authored
80 activiti/activiti-config/pom.xml
View
@@ -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>
77 activiti/activiti-config/src/main/java/org/apache/servicemix/activiti/config/CamelAwareELResolver.java
View
@@ -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;
+ }
+}
74 activiti/activiti-config/src/main/resources/OSGI-INF/blueprint/activiti-config.xml
View
@@ -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>
35 activiti/activiti-config/src/test/java/org/apache/servicemix/activiti/config/CamelAwareELResolverTest.java
View
@@ -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;
+ }
+}
40 activiti/pom.xml
View
@@ -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>
15 assemblies/apache-servicemix/src/main/filtered-resources/features.xml
View
@@ -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>
20 parent/pom.xml
View
@@ -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>
15 pom.xml
View
@@ -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>
Please sign in to comment.
Something went wrong with that request. Please try again.