Java Reference
In-Depth Information
CustomerServiceImpl is a simple class. At the top, we see that we've injected three dependencies:
springConfiguration (which doesn't get used—though its configuration is worth noting because you
may use it to access other services), repositoryService , and executionService . The class provides a few
salient methods (some of which are required by its interface, CustomerService ):
void setupProcessDefinitions()
Customer createCustomer(String email, String passphrase, String firstName,
String lastName)
void sendCustomerVerificationEmail(Long customerId)
void authorizeCustomer(Long customerId)
In the bean, setupProcessDefinitions is run when the bean is created. It iterates through the
processDefinitions collection and “deploys” the resource whose path it is given. If you monitor the logs,
you'll witness SQL being issued against the database, creating the runtime structure of your process
definition inside the database.
11-5. Building a Business Process
Problem
You've built a service that uses jBPM to create a working service. We've seen how jBPM is configured,
and we've even built a service for a business requirement (the sign-up of customers). The last element
that remains is the process definition itself. What does a business process definition look like? How does
a process definition reference Spring beans?
Solution
We'll build a process definition that codifies the steps diagrammed in Figure 11-1 at the beginning of
the chapter. This process definition will reference Spring beans using the JBoss expression language.
Finally, we'll walk through how the business process uses our customerService bean and how the
customerService bean uses the business process to handle the customer's sign-up.
Approach
Let's examine the business process itself ( RegisterCustomer.jpdl.xml ). In jBPM, a business process is
built using jPDL. You can use the Eclipse plug-in to model jBPM processes, but the jPDL schema is so
simple that you don't really need it. This is not like BPEL where it can become all but intolerably
complicated to write the code by hand. What follows is the XML for the business process:
<?xml version="1.0" encoding="UTF-8"?>
<process name="RegisterCustomer" xmlns=" http://jbpm.org/4.0/jpdl">
<start>
<transition to="send-verification-email" />
</start>
 
Search WWH ::




Custom Search