-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
Showing
8 changed files
with
355 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
77 changes: 77 additions & 0 deletions
77
...viti-config/src/main/java/org/apache/servicemix/activiti/config/CamelAwareELResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
activiti/activiti-config/src/main/resources/OSGI-INF/blueprint/activiti-config.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
35 changes: 35 additions & 0 deletions
35
...-config/src/test/java/org/apache/servicemix/activiti/config/CamelAwareELResolverTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.