Q.1.
jBPM will expose beans using the:-
Q.2.
jBPM, and indeed most workflow engines, passivate state for you, allowing a process to wait on external events :-
Q.3.
We override the List bean (with id annotatedHibernateClasses) that we created for the last recipe (jbpm4 context.xml) to provide the session factory with a collection of annotated entities which is here as:- <?xml version="1.encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:tx="http://www.springframework.org/schema/tx"  xmlns:p="http://www.springframework.org/schema/p" xmlns:util="http://www.springframework.org/schema/util"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd "> <import resource="jbpm4-context.xml"/> <context:annotation-config/> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method propagation="REQUIRED" name="*"/> </tx:attributes> </tx:advice> <aop:config> <aop:advisor advice-ref="txAdvice" pointcut="execution(*  com.apress.springrecipes..jbpm4.*.*(..))"/> </aop:config> <util:list id="annotatedHibernateClasses"> <value>com.apress.springrecipes.jbpm.jbpm4.customers.Customer</value> </util:list> <bean id="customerService" class="com.apress.springrecipes.jbpm.jbpm4.customers. CustomerServiceImpl"> <property name="processDefinitions"> <list> <value>/process-definitions/RegisterCustomer.jpdl.xml</value> </list> </property> </bean> </beans>
Q.4.
The method annotated with @PostConstruct will be run after the bean’s been configured to let the user inject custom initialization logic.
Q.5.
The business process file’s name needs to end in :-
Q.6.
At the top, we’ve injected some dependencies:
Q.7.
The class(CustomerServiceImpl) provides a few salient methods:- package com.apress.springrecipes.jbpm.jbpm4.customers; public interface CustomerService { void sendWelcomeEmail(Long customerId); void deauthorizeCustomer(Long customerId); void authorizeCustomer(Long customerId); Customer getCustomerById(Long customerId); Customer createCustomer(String email, String password, String firstName,  String lastName); void sendCustomerVerificationEmail(Long customerId); }
Q.8.
In the bean, setupProcessDefinitions is run when the bean is created.
Q.9.
Process definition will reference Spring beans using the JBoss expression language.
Q.10.
In jBPM, a business process is built using jPDL.
Q.11.
In the customerService bean, a client will use createCustomer to create a customer record. <?xml version="1.encoding="UTF-8"?> <process name="RegisterCustomer" xmlns="http://jbpm.org/4.0/jpdl"> <start> <transition to="send-verification-email" /> </start> <java name="send-verification-email" expr="#{customerService}" method="sendCustomerVerificationEmail"> <arg> <object expr="#{customerId}" /> </arg> <transition to="confirm-receipt-of-verification-email" /> </java> <state name="confirm-receipt-of-verification-email"> <transition to="send-welcome-email" /> </state> <java name="send-welcome-email" expr="#{customerService}" method="sendWelcomeEmail"> <arg> <object expr="#{customerId}" /> </arg> </java> </process>
Q.12.
Inside the createCustomer method, we use jBPM to start the business process to track the Customer. This is done with the :- <?xml version="1.encoding="UTF-8"?> <process name="RegisterCustomer" xmlns="http://jbpm.org/4.0/jpdl"> <start> <transition to="send-verification-email" /> </start> <java name="send-verification-email" expr="#{customerService}" method="sendCustomerVerificationEmail"> <arg> <object expr="#{customerId}" /> </arg> <transition to="confirm-receipt-of-verification-email" /> </java> <state name="confirm-receipt-of-verification-email"> <transition to="send-welcome-email" /> </state> <java name="send-welcome-email" expr="#{customerService}" method="sendWelcomeEmail"> <arg> <object expr="#{customerId}" /> </arg> </java> </process>
Q.13.
Once in the java element named send-verification-email, jBPM will invoke the method:-
Q.14.
Inside authorizeCustomer, the service queries the server for the any processes waiting at the:-
Q.15.
The authorizeCustomer method also updates the Customer entity, marking it as authorized. From there, execution proceeds to the send-welcome-email java element.