WebSphere Extended Deployment Compute Grid, Version 6.1.1
             Operating Systems: AIX, HP-UX, Linux, Solaris, Windows


POJO programming model

A batch application in WebSphere Extended Deployment Version 6.1 is implemented as a simple Plain Old Java Object (POJO) and packaged as Enterprise JavaBeans (EJB) modules into Enterprise Archive (EAR) files for deployment. Building a POJO-based batch application is the preferred method for building a batch application.

The following sections describe the components of a batch application.

Batch job step

A batch application can be comprised of one ore more batch steps. Each batch step is a POJO, which implements the interface com.ibm.websphere.batch.BatchJobStepInterface. The implementation of this interface provides the business logic of the batch step that the batch runtime invokes to run the batch application.

During packaging of a batch application, each batch step is declared as a CMP entity bean and the business logic in the POJO is associated with the bean using an Environment Entry in the EJB deployment descriptor. The CMP entity bean acts as a batch job step wrapper. Its implementation is provided by the WebSphere Extended Deployment runtime. Therefore, this bean is declared in the EJB deployment descriptor and not actually packaged. Multiple steps are defined in a single batch application

Batch controller bean

A batch application also includes a stateless session bean which is provided by the WebSphere Extended Deployment runtime that acts as a job step controller. Like the step CMP entity bean, the controller stateless session bean is declared in the application deployment descriptor. Declare the controller bean once per batch application.

Batch data streams

Each batch step can use zero or more batch data streams for the input and output of data. A batch data stream is a POJO that implements the interface com.ibm.websphere.batch.BatchDataStream.

Checkpoint algorithms

Checkpoint algorithms help the batch runtime decide how often to commit the global transaction under which batch steps are invoked. Checkpoint algorithms are built as POJOs by implementing the interface com.ibm.wsspi.batch.CheckpointAlgorithm. The batch runtime also provides a ready-to-use time-based and record-based checkpoint algorithms.

Results algorithms

An optional feature of the batch programming model, results algorithms, is used to manipulate the return codes of batch jobs. The batch runtime provides a simple results algorithm which returns the highest numerical return code value of all the job steps.

Components of a batch application

Table 1. Components of a batch application that are provided by the batch application developer
Component Type Implementation Provider
Batch job step POJO com.ibm.websphere.BatchJobStepInterface Batch application
Batch data stream POJO com.ibm.websphere.batchDataStream Batch application
Checkpoint algorithm POJO com.ibm.wsspi.batchCheckpointAlgorithm Batch application (can use runtime-provided implementation instead)
Results algorithm POJO com.ibm.wsspi.batchResultsAlgorithm Batch application (can use runtime-provided implementation instead)
Table 2. Components of a batch application that are provided by the batch runtime
Component Type Implementation Provider
Batch job controller Session bean   Batch runtime
Batch job step wrapper CMP entity bean   Batch runtime
Checkpoint algorithm POJO   Batch runtime (applications can provide their own)
Results algorithm POJO   Batch runtime (applications can provide their own)

Example

EJB Deployment Descriptor:

<ejb-jar id="ejb-jar_ID">
   <display-name>POJOSampleEJBs</display-name>
   <enterprise-beans>
      <!--Batch Job Controller Bean -->
      <session id="POJOJob">
         <ejb-name>POJOJob</ejb-name>
         <home>com.ibm.ws.batch.BatchJobControllerHome</home>
         <remote>com.ibm.ws.batch.BatchJobController</remote>
         <ejb-class>com.ibm.ws.batch.BatchJobControllerBean</ejb-class>
         <session-type>Stateless</session-type>
         <transaction-type>Bean</transaction-type>
         <ejb-local-ref id="EJBLocalRef_1168709876999">
            <ejb-ref-name>ejb/POJOStep1</ejb-ref-name>
            <ejb-ref-type>Entity</ejb-ref-type>
            <local-home>com.ibm.websphere.batch.BatchJobStepLocalHomeInterface </local-home>
             <local>com.ibm.websphere.batch.BatchJobStepLocalInterface</local>
            <ejb-link>POJOStep1</ejb-link>
         </ejb-local-ref>
         <ejb-local-ref id="EJBLocalRef_1127247535990">
            <ejb-ref-name>ejb/POJOStep2</ejb-ref-name>
            <ejb-ref-type>Entity</ejb-ref-type>
            <local-home>com.ibm.websphere.batch.BatchJobStepLocalHomeInterface</local-home>
            <local>com.ibm.websphere.batch.BatchJobStepLocalInterface</local>
           <ejb-link>POJOStep2</ejb-link>
         </ejb-local-ref>
         <resource-ref id="ResourceRef_1168711637701">
            <!-- default Work Manager for Batch Jobs -->
            <res-ref-name>wm/BatchWorkManager</res-ref-name>
            <res-type>commonj.work.WorkManager</res-type>
            <res-auth>Container</res-auth>
            <res-sharing-scope>Shareable</res-sharing-scope>
         </resource-ref>
      </session>

      <!-- Batch Job Step # 1 -->
      <entity id="POJOStep1">
         <ejb-name>POJOStep1</ejb-name>
         <local-home>com.ibm.websphere.batch.BatchJobStepLocalHomeInterface </local-home>
         <local>com.ibm.websphere.batch.BatchJobStepLocalInterface</local>
         <!-- Batch Job Step Wrapper -->
         <ejb-class>com.ibm.ws.batch.DefaultBatchJobStepBean</ejb-class>
         <persistence-type>Container</persistence-type>
         <prim-key-class>com.ibm.websphere.batch.BatchJobStepKey </prim-key-class>
         <reentrant>False</reentrant>
         <cmp-version>2.x</cmp-version>
         <abstract-schema-name>POJOStep1</abstract-schema-name>
         <cmp-field id="CMPAttribute_1168709093522">
            <field-name>jobID</field-name>
         </cmp-field>
         <cmp-field id="CMPAttribute_1168709093542">
            <field-name>stepID</field-name>
         </cmp-field>
         <!-- Environment Entry associating Step POJO to the Wrapper -->
         <env-entry>
            <description>POJO class name for the batch step</description>
            <env-entry-name>POJOclass</env-entry-name>
            <env-entry-type>java.lang.String</env-entry-type>
            <!-- POJO Job Step implementation -->
            <env-entry-value>com.ibm.websphere.samples.POJOStep1</env-entry-value>
         </env-entry>
      </entity>

      <!-- Batch Job Step # 2 -->
      <entity id="POJOStep2">
         <ejb-name>POJOStep2</ejb-name>
         <local-home>com.ibm.websphere.batch.BatchJobStepLocalHomeInterface </local-home>
         <local>com.ibm.websphere.batch.BatchJobStepLocalInterface</local>
         <!-- Batch Job Step Wrapper -->
         <ejb-class>com.ibm.ws.batch.DefaultBatchJobStepBean</ejb-class>
         <persistence-type>Container</persistence-type>
         <prim-key-class>com.ibm.websphere.batch.BatchJobStepKey</prim-key-class>
         <reentrant>False</reentrant>
         <cmp-version>2.x</cmp-version>
         <abstract-schema-name>POJOStep2</abstract-schema-name>
         <cmp-field id="CMPAttribute_1127248451496">
            <field-name>jobID</field-name>
         </cmp-field>
         <cmp-field id="CMPAttribute_1127248451497">
            <field-name>stepID</field-name>
         </cmp-field>
         <!-- Environment Entry associating Step POJO to the Wrapper -->
         <env-entry>
            <description>POJO class name for the batch step</description>
            <env-entry-name>POJOclass</env-entry-name>
            <env-entry-type>java.lang.String</env-entry-type>
            <!-- POJO Job Step implementation -->
            <env-entry-value>com.ibm.websphere.samples.POJOStep2</env-entry-value>
         </env-entry>
      </entity>
   </enterprise-beans>

   <assembly-descriptor id="AssemblyDescriptor_1168711087550">
      <container-transaction>
         <method>
            <ejb-name>POJOStep1</ejb-name>
            <method-name>*</method-name>
         </method>
         <method>
            <ejb-name>POJOStep2</ejb-name>
            <method-name>*</method-name>
         </method>
         <!-- TX REQUIRED-->
         <trans-attribute>Required</trans-attribute>
      </container-transaction>
   </assembly-descriptor>
</ejb-jar>




Related concepts
The batch programming model
Related tasks
Developing a simple batch application
Building a batch application using POJO
Concept topic    

Terms of Use | Feedback

Last updated: Oct 30, 2009 1:38:02 PM EDT
http://publib.boulder.ibm.com/infocenter/wxdinfo/v6r1m1/index.jsp?topic=/com.ibm.websphere.gridmgr.doc/info/scheduler/ccgpojomodel.html