- The
ProcessEngineas well as the services are available for injection via@Inject ProcessEngine,@Inject RepositoryService, and so on. - A specific named
ProcessEngineand its services can be injected by adding the qualifier@ProcessEngineName('someEngine'). - The current process instance and task can be injected via
@Inject ProcessInstanceor@Inject Task. - The current business key can be injected via
@Inject @BusinessKey String businessKey. - The current process instance id be injected via
@Inject @ProcessInstanceId String pid.
-
Type-safe injection of
@BusinessProcessScopedbeans using@Inject [additional qualifiers] Type fieldName. -
Unsafe injection of other process variables using the
@ProcessVariable(name?)qualifier:
@Named @BusinessProcessScopedbeans can be referenced directly.- Other process variables can be referenced using the
ProcessVariables-bean via#{processVariables['accountNumber']}.
Inject a process engine based on contextual data
While a specific process engine can be accessed by adding the qualifier@ProcessEngineName('name') to the injection point,
this requires that it is known which process engine is used at design time. A more flexible approach is to resolve the
process engine at runtime based on contextual information such as the logged in user. In this case, @Inject can be used
without a @ProcessEngineName annotation.
To implement resolution from contextual data, the producer bean org.camunda.bpm.engine.cdi.impl.ProcessEngineServicesProducer
must be extended. The following code implements a contextual resolution of the engine by the currently authenticated user.
Note that which contextual data is used and how it is accessed is entirely up to you.
UserInfo represents any kind of context object that identifies the current tenant.
For example, it could be a JAAS principal. The produced engine can be accessed in the following way: