Limit the exposed Spring Beans
When using theProcessEngineFactoryBean, by default, all expressions and scripts in the BPMN processes will also “see” all the Spring beans. It’s possible to limit the beans you want to expose or even expose no beans at all using a map that you can configure. The example below exposes a single bean (printer), available to use under the key printer. To expose NO beans at all, pass an empty map as beans property on the SpringProcessEngineConfiguration. When no beans property is set, all Spring beans in the context will be available.
Using Spring Beans in expressions
The exposed beans can be used in expressions. For example, theSpringTransactionIntegrationTest testBasicActivitiSpringIntegration.bpmn20.xml shows how a method on a Spring bean can be invoked using a UEL method expression:
Expression resolving with the shared process engine
In a shared process engine deployment scenario, you have a process engine which dispatches to multiple applications. In this case, there is not a single Spring application context but each application may maintain its own application context. The process engine cannot use a single expression resolver for a single application context but must delegate to the appropriate process application, depending on which process is currently being executed. This functionality is provided by theorg.camunda.bpm.engine.spring.application.SpringProcessApplicationElResolver. This class is a ProcessApplicationElResolver implementation delegating to the local application context. Expression resolving then works in the following way:
- The shared process engine checks which process application corresponds to the process it is currently executing.
- It then delegates to that process application for resolving expressions.
- The process application delegates to the
SpringProcessApplicationElResolverwhich uses the local Spring application context for resolving beans.
The
SpringProcessApplicationElResolver class is automatically detected if the camunda-engine-spring module is included as a library of the process application, not as a global library.Using Spring Beans in scripting
When usingProcessEngineFactoryBean, all Spring beans are accessible in Groovy, JavaScript, and Jython. For example, the ScriptTaskTest-applicationContext.xml exposes the bean ‘testbean’:
Testbean is referenced then form JavaScript: