Skip to content

Commit

Permalink
SMX4-1191: Add basic support for Activiti
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/servicemix/smx4/features/trunk@1353978 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
gertv committed Jun 26, 2012
1 parent 5bd3760 commit 90547ed
Show file tree
Hide file tree
Showing 8 changed files with 355 additions and 1 deletion.
80 changes: 80 additions & 0 deletions activiti/activiti-config/pom.xml
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -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 changes: 40 additions & 0 deletions activiti/pom.xml
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 19 additions & 1 deletion parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -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>
Expand Down
Loading

0 comments on commit 90547ed

Please sign in to comment.