486 WebSphere Business Integrator Server Foundation V5.1 Handbook
18.4 Development
For this chapter we have created a sample J2EE V1.3 application with all the
code, we are not going to provide step-by-step instructions about how to build
such an application. The description you can find here is how to use the Shared
Work Area service in a J2EE application.
To develop an application using the Shared Work Area service, you need add
two JAR files to your Java build directory: acwa.jar and distexcep.jar.
Figure 18-2 Java Build Path for the server application
The EJB module
The sample application has an EJB module and an application client module.
The EJB module has two session EJBs: SessionFaçade, BusinessLogic.
The SessionFaçade is a façade component that routes the customer request to
the appropriate business logic invocation. Only the SessionFaçade has remote
interface, the subsequent logic beans only have local interface. We get the
BusinessLogic local instance in ejbCreate() method to gain some performance
private BusinessLogicLocalHome home = null;
Chapter 18. Shared Work Area service 487
private BusinessLogicLocalHome home = null;
public void ejbCreate() throws javax.ejb.CreateException {
try {
InitialContext ctx = new InitialContext();
// Get the BusinessLogic bean instance
home = (BusinessLogicLocalHome) ctx.lookup(businessName);
business = home.create();
} catch (NamingException e) {
System.out.println("SessionFacde Bean : Lookup the BusinessBean
The actual business invocation will be delegated to BusinessLogic bean method.
// Business logic invocation
public void bookingProcess(){
There are two serializable classes: CustomerInfo.java and TravelInfo.java.
These two classes will store the information exchanged between client and
server side. In the TravelInfo.java, we defined a travelConfirmNumber parameter
to store the confirmation information generated by the server. Because we will
specify the travelInfoArea partition as "bidirectional", we assume this information
will be propagated back to client thread automatically.
As usual, in the BusinessLogic bean, we get the partition service instance in
ejbCreate() method to gain some performance benefit.
import com.ibm.websphere.workarea.NoSuchPartitionException;
import com.ibm.websphere.workarea.PropertyModeType;
import com.ibm.websphere.workarea.UserWorkArea;
import com.ibm.websphere.workarea.WorkAreaPartitionManager;
private static final String jndiName =
private WorkAreaPartitionManager manager = null;
private UserWorkArea custInfoArea = null;
private UserWorkArea travelInfoArea = null;
private CustomerInfo custInfo = null;
private TravelInfo travelInfo = null;
public void ejbCreate() throws javax.ejb.CreateException {
try {
InitialContext ctx = new InitialContext();
manager = (WorkAreaPartitionManager) ctx.lookup(jndiName);
488 WebSphere Business Integrator Server Foundation V5.1 Handbook
} catch (Exception e) {
try {
custInfoArea = (UserWorkArea)
travelInfoArea = (UserWorkArea)
} catch (NoSuchPartitionException e) {
The WorkAreaPartitionManager instance looks up the WebSphere JNDI for the
java:comp/websphere/WorkAreaPartitionManager. Then, we get the two Work
Area partitions which are defined on the server using the
partition_name") method.
How the makeReservation() business method works:
1. Retrieve all the information: UserWorkArea.retrieveAllKeys() method will
return all the informations included in the Work Area.
2. Make some changes to TravelInfo class, to simulate that we have some follow
on invocation to generate the confirmation number for user travel booking.
3. Reset the property in the Work Area and try to propagate this information
back to the client side. We use the UserWorkArea.set() method to achieve
Example 18-1 Propagating back to the client side
// The reservation business method
public void makeReservation() {
System.out.println("BusinessLogicBean: Testing...");
// Get information from CustomerInformation work area
try {
String[] custInfoProperties = custInfoArea.retrieveAllKeys();
if (custInfoProperties != null) {
for (int i = 0; i < custInfoProperties.length; i++) {
// … print out information here
} else {
System.out.println("BusinessLogicBean: No Properties found!...");
// You can make some other invocations like WPC to process the user
// request based on the user information
// Then, Store the confirm information in the bidirectional work area

Get WebSphere Business Integration Server Foundation V5.1 Handbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.