Abstract |
This example contains sample
source code for an Enterprise Java Bean invoking MQWF API calls.
|
This
example shows ... |
-
How an EJB can implement API calls
in WebSphere and how to call the EJB from a remote client program.
|
You
can use this example ... |
-
As a design pattern for your own EJB
implementation.
|
Minimum
MQWF version required
|
|
Other
required products |
-
WebSphere Application Server Version
5 or any other J2EE 1.3 Application Server.
|
Description |
This sample contains the definition
of a Session Bean that implements a small subset of the MQWF Java
programming interface.
A remote client program demonstrates how to look up the bean's
interface, create a bean instance, invoke its methods and process the result.
The focus of this sample is to demonstrate
how to use object wrapper classes to transport API objects to the client
and how to use stateless API calls to implement a production ready
multi-user multi-threaded EJB environment.
|
Setup |
This
sample was developed with WebSphere Studio Version 5 and
tested with Websphere Application Server
Version 5 on Windows 2000. The following setup steps are for this
environment, however the Java code does not depend on this operating system or EJB
container. It adheres to the EJB 2.0 standards.
To prepare the sample, perform the following steps:
-
Install and configure IBM WebSphere
MQ Workflow and IBM WebSphere Application Server.
-
Package the files WorkflowEJB.java and
WorkflowEJBBean.java into a stateless Enterprise Java Bean. For
simplicity, this sample assumes that the EJB client classes are packaged
into the same jar file. So you must also package the files EJBTestClient.java,
ServiceWrapper.java, ProcessTemplateWrapper.java,
ProcessInstanceWrapper.java and WorkItemWrapper.java
into the bean project.
To do this in IBM WebSphere Studio, perform the following:
- Create a new EJB project.
- Create 2.0 Stateless Enterprise Session Bean WorkflowEJB in the new project.
- Import the java source code into the packages
com.ibm.workflow.api.smp.EJB and com.ibm.workflow.api.smp.EJB.client.
- Generate the deploy and RMIC code and export the enterprise application as an
ear file containing all the required EJB interface classes, deployment
descriptor and META-INF files.
Deploy the resulting ear file in WebSphere Application
Server. If you have Java2 security enabled the sample will need the following
security permissions:
-
When using the MQWF Classic Java API classes:
grant codeBase "file:${application}" {
permission java.lang.RuntimePermission
"loadLibrary.fmcojprf";
permission java.util.PropertyPermission
"java.execsuffix", "read";
permission java.util.PropertyPermission "user.dir",
"read";
permission java.lang.RuntimePermission
"loadLibrary.fmcojloc";
permission java.lang.RuntimePermission
"loadLibrary.fmcojiop";
};
-
When using the MQWF Native Java API classes:
permission java.io.FilePermission "fmcrc", "read";
permission java.io.FilePermission
"${app.installed.path}/fmcjapi.jar", "read";
permission java.io.FilePermission "fmctrc.log",
"write";
Ensure that the EJB application has access to
the MQWF Java API classes. If you have configured and deployed the Web Client
your Application Server will already have global access to the API classes.
To prepare the EJB client code,
perform the following steps:
-
Edit the file EJBInvocation.properties
and customize it for your environment.
It contains default values for the EJB lookup function and for the
workflow client logon.
-
Export the class files of the packages
com.ibm.workflow.api.smp.EJB and com.ibm.workflow.api.smp.EJB.client as a jar
file (alternatively you can export this jar file from the exported enterprise
application ear file). Place this jar file into directory
EJBInvocation.
-
On Windows operating systems edit and customize the
file startclient.cmd to your environment. It contains
classpath settings that your client code requires during compile and
runtime.
-
On all other operating systems, create a script file
similar to startclient.cmd to start the client program.
|
Running
the sample |
To run the
sample, perform the following steps:
-
Start the WebSphere Application Server and
ensure that your EJB application is running.
-
Run startclient.cmd. The sample client program logs on, queries the
process templates, creates a process instance, queries the process instances
and workitems, deletes the process instances and finally logs off.
-
Problems during start of the EJB or during running of the client will be
printed to the WebSphere console log file SystemOut.log.
|
View source code |
WorkflowEJBBean.java
WorkflowEJBBean.html (Javadoc)
EJBTestClient.java
ServiceWrapper.java
ProcessTemplateWrapper.java
ProcessInstanceWrapper.java
WorkItemWrapper.java
|