An application accesses the appropriate remote session bean through
the home interface of the bean.
Why and when to perform this task
The session bean can be either the BusinessFlowManager session bean
for process applications or the HumanTaskManager session bean for task applications.
Steps for this task
- Add a reference to the remote session bean to the application deployment
descriptor. Add the reference to one of the following files:
- The application-client.xml file, for a Java™ 2
Platform, Enterprise Edition (J2EE) client application
- The web.xml file, for a Web application
- The ejb-jar.xml file, for an Enterprise JavaBeans™ (EJB)
application
The reference to the remote home interface for process applications
is shown in the following example:
<ejb-ref>
<ejb-ref-name>ejb/BusinessFlowManagerHome</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>com.ibm.bpe.api.BusinessFlowManagerHome</home>
<remote>com.ibm.bpe.api.BusinessFlowManager</remote>
</ejb-ref>
The reference to the remote home interface
for task applications is shown in the following example:
<ejb-ref>
<ejb-ref-name>ejb/HumanTaskManagerHome</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>com.ibm.task.api.HumanTaskManagerHome</home>
<remote>com.ibm.task.api.HumanTaskManager</remote>
</ejb-ref>
If you use WebSphere® Integration Developer to
add the EJB reference to the deployment descriptor, the binding for the EJB
reference is automatically created when the application is deployed. For more
information on adding EJB references, refer to the WebSphere Integration Developer documentation.
- Package the generated stubs with your application.
If
your application runs on a different Java Virtual Machine (JVM) from the one
where the BPEContainer application or the TaskContainer application runs,
complete the following actions:
- For process applications, package the <install_root>/ProcessChoreographer/client/bpe137650.jar file
with the enterprise archive (EAR) file of your application.
- For task applications, package the <install_root>/ProcessChoreographer/client/task137650.jar file with the EAR file of your application.
- Set the Class-Path parameter in the manifest
file of the application module to include the JAR file. The application
module can be a J2EE application, a Web application, or an EJB application.
- Make the home interface of the session bean available to the application
using Java Naming
and Directory Interface (JNDI) lookup mechanisms. The following
example shows this step for a process application:
// Obtain the default initial JNDI context
InitialContext initialContext = new InitialContext();
// Lookup the remote home interface of the BusinessFlowManager bean
Object result =
initialContext.lookup("java:comp/env/ejb/BusinessFlowManagerHome");
// Convert the lookup result to the proper type
BusinessFlowManagerHome processHome =
(BusinessFlowManagerHome)javax.rmi.PortableRemoteObject.narrow
(result,BusinessFlowManagerHome.class);
The
home interface of the session bean contains a create method for EJB objects.
The method returns the remote interface of the session bean.
- Access the remote interface of the session bean. The
following example shows this step for a process application:
BusinessFlowManager process = processHome.create();
- Call the business functions exposed by the service interface. The following example shows this step for a process application:
process.initiate("MyProcessModel",input);
Calls from applications are run as transactions. A transaction
is established and ended in one of the following ways:
Here is an example of how steps 3 through 5 might look for a task
application.
// Obtain the default initial JNDI context
InitialContext initialContext = new InitialContext();
// Lookup the remote home interface of the HumanTaskManager bean
Object result =
initialContext.lookup("java:comp/env/ejb/HumanTaskManagerHome");
// Convert the lookup result to the proper type
HumanTaskManagerHome taskHome =
(HumanTaskManagerHome)javax.rmi.PortableRemoteObject.narrow
(result,HumanTaskManagerHome.class);
...
//Access the remote interface of the session bean.
HumanTaskManager task = taskHome.create();
...
//Call the business functions exposed by the service interface
task.callTask(tkiid,input);