Chapter 16. CDI Integration
16.1. About CDI
Apart from the API based approach, Red Hat JBoss BPM Suite 6 also provides the Context and Dependency Injection (CDI) to build your custom applications. CDI is a collection of component management services for the Java EE platform that enables developers to use enterprise beans in web applications. The benefits of CDI include a simplified architecture and more resuable code.
The jbpm-services-cdi module provides CDI wrappers of Kie Services that enable these services to be injected in any CDI bean.
A workaround is needed on the Oracle WebLogic Server for CDI to work. For more information, see Additional Notes in the Red Hat JBoss BPM Suite Oracle WebLogic Installation and Configuration Guide.
16.2. Defining MBeans for CDI Integration
To make use of jbpm-kie-services in your system, you must provide some MBeans to satisfy all dependencies of the services. There are several MBeans that depend on actual scenarios.
- Entity manager and entity manager factory
- User group callback for human tasks
- Identity provider to pass authenticated user information to the services
Procedure
When running in a JEE environment such as JBoss Application Server, ensure that the mbean satisfies all requirements of the jbpm-kie-services:
public class EnvironmentProducer { @PersistenceUnit(unitName = "org.jbpm.domain") private EntityManagerFactory emf; @Inject @Selectable private UserGroupCallback userGroupCallback; @Produces public EntityManagerFactory getEntityManagerFactory() { return this.emf; } @Produces @RequestScoped public EntityManager getEntityManager() { EntityManager em = emf.createEntityManager(); return em; } public void close(@Disposes EntityManager em) { em.close(); } @Produces public UserGroupCallback produceSelectedUserGroupCalback() { return userGroupCallback; } @Produces public IdentityProvider produceIdentityProvider { return new IdentityProvider() { // implement IdentityProvider }; } }Configure the
deployments/business-central.war/WEB-INF/beans.xmlfile to change the current settings of the newusergroupcallbackimplementation:<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://docs.jboss.org/cdi/beans_1_0.xsd"> <alternatives> <class>org.jbpm.services.task.identity.JAASUserGroupCallbackImpl</class> </alternatives> </beans>
Noteorg.jbpm.services.task.identity.JAASUserGroupCallbackImplis just an example here to demonstrate the settings of the application server regardless of what it actually is (LDAP, DB, etc).

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.