部署 OSGi 批处理应用程序

您可以将现有批处理应用程序打包为 OSGi 应用程序。然后部署该包,以便您可以将批处理工件公开为服务以使这些工件对批处理容器可视。

关于此任务

打包 OSGi 批处理应用程序,修改 Blueprint xml 文件以将批处理工件描述为服务,并将 OSGi 批处理应用程序导出为企业捆绑软件归档 (EBA)。然后创建 xJCL。最后,部署 OSGi 批处理应用程序。

过程

  1. 打包 OSGi 批处理应用程序。

    将 OSGi 批处理应用程序打包为 EBA。该 EBA 至少包含您的批处理捆绑软件,即,Blueprint 捆绑软件。API 捆绑软件和分派器捆绑软件会一次性安装到内部捆绑软件存储库中。

    请参阅有关创建客户机捆绑软件的主题,并遵循打包 OSGi 应用程序的步骤。

  2. 编写 Blueprint xml。

    必须将作业步骤和批处理数据流声明为服务,以便调度程序可调用它们。如果 OSGi 批处理应用程序实现检查点策略算法或结果算法,那么还必须将应用程序实现的每个算法声明为服务。

    1. 将每个作业步骤声明为 Blueprint 服务。
      1. 设置接口属性。
        1. 如果该步骤是计算密集型步骤,请将属性设置为 com.ibm.websphere.ci.CIWork
        2. 如果该步骤是事务批处理步骤,请将属性设置为 com.ibm.websphere.batch.BatchJobStepInterface
      2. 将 ref 属性设置为用于声明步骤 bean 的 bean 标识。
      3. 使用 xjcl:classname 键和一个值来声明属性,该值是实现该步骤的 Java™ 类。
      4. 为实现该步骤的 Java 类声明 bean。
      5. 将 scope 属性设置为 prototype

      计算密集型步骤示例:

      <bean id="IVTStep1" class="com.ibm.websphere.batch.samples.tests.steps.GenerateDataStep" scope="prototype"/>
      
      <service ref="IVTStep1" interface="com.ibm.websphere.ci.CIWork" id="step1">
      	<service-properties>
      	      <entry key="xjcl:classname" value="com.ibm.websphere.batch.samples.tests.steps.GenerateDataStep"/>
      	</service-properties>
      </service> 

      事务批处理步骤示例:

      <bean id="EchoStep2" class="com.ibm.websphere.batch.samples.tests.steps.TestBatchJobStep" scope="prototype"/>
      
      <service ref="EchoStep2" interface="com.ibm.websphere.batch.BatchJobStepInterface" id="echostep1">
      	<service-properties>
      	      <entry key="xjcl:classname" value="com.ibm.websphere.batch.samples.tests.steps.TestBatchJobStep"/>
      	</service-properties>
      </service> 
    2. 将每个批处理数据流声明为 Blueprint 服务。
      1. 将 interface 属性设置为 com.ibm.websphere.batch.BatchDataStream
      2. 将 ref 属性设置为用于声明批处理数据流 bean 的 bean 标识。
      3. 使用 xjcl:classname 键和一个值来声明属性,该值是实现批处理数据流的 Java 类。
      4. 为实现该批处理数据流的 Java 类声明 bean。
      5. 将 scope 属性设置为 prototype

      批处理数据流示例:

      <bean id="output" class="com.ibm.websphere.batch.samples.tests.bds.TestOutputBatchDataStream" scope="prototype"/>
      <service ref="output" interface="com.ibm.websphere.batch.BatchDataStream" id="out1">
      	<service-properties>
            <entry key="xjcl:impl-class" value="com.ibm.websphere.batch.samples.tests.bds.TestOutputBatchDataStream"/>
      	</service-properties>
      </service>  
    3. 将检查点策略算法声明为 Blueprint 服务。

      如果您的 OSGi 批处理应用程序实现检查点策略算法,请将该算法声明为 Blueprint 服务。否则,跳过此步骤。

      1. 将 interface 属性设置为 com.ibm.wsspi.batch.CheckpointPolicyAlgorithm
      2. 将 ref 属性设置为用于声明检查点 bean 的 bean 标识。
      3. 使用 xjcl:classname 键和一个值来声明属性,该值是实现检查点策略算法的 Java 类。
      4. 为实现该检查点策略算法的 Java 类声明 bean。
      5. 将 scope 属性设置为 prototype

      检查点策略算法示例:

      <bean id="chkpt" class="com.ibm.websphere.batch.samples.MyCheckpointAlgorithm" scope="prototype"/>
      <service ref="chkpt" interface="com.ibm.wsspi.batch.CheckpointPolicyAlgorithm" id="ck1">
      	<service-properties>
            <entry key="xjcl:impl-class" value="com.ibm.websphere.batch.samples.MyCheckpointAlgorithm"/>
      	</service-properties>
      </service>    
    4. 将结果算法声明为 Blueprint 服务。

      如果您的 OSGi 批处理应用程序实现结果算法,请将该算法声明为 Blueprint 服务。否则,跳过此步骤。

      1. 将 interface 属性设置为 com.ibm.wsspi.batch.ResultsAlgorithm
      2. 将 ref 属性设置为用于声明结果算法 bean 的 bean 标识。
      3. 使用 xjcl:classname 键和一个值来声明属性,该值是实现结果算法的 Java 类。
      4. 为实现该结果算法的 Java 类声明 bean。
      5. 将 scope 属性设置为 prototype

      结果算法示例:

      <bean id="myres" class="com.ibm.websphere.batch.samples.MyResultsAlgorithm" scope="prototype"/>
      <service ref="myres" interface="com.ibm.wsspi.batch.ResultsAlgorithm" id="r1">
      	<service-properties>
            <entry key="xjcl:impl-class" value="com.ibm.websphere.batch.samples.MyResultsAlgorithm"/>
      	</service-properties>
      </service>    
  3. 将 OSGi 批处理应用程序导出为 EBA。
  4. 创建 xJCL。
    按创建其他批处理应用程序的方式创建 xJCL,但在创建 xJCL 时有几点差异:
    • 使作业步骤上的 application-name 属性成为所部署资产名称。所部署资产是组合单元。
    • 使步骤的类名子元素匹配步骤服务的 xjcl:classname 属性。
      以下示例使用此过程中先前列示的事务批处理步骤示例中的 com.ibm.websphere.batch.samples.tests.steps.TestBatchJobStep 的 xjcl:classname 属性。
      <step id=”step1”>
      <classname> com.ibm.websphere.batch.samples.tests.steps.TestBatchJobStep</classname>
      </step>
  5. 部署 OSGi 批处理应用程序。

    请阅读有关将 OSGi 应用程序部署为业务级应用程序的主题,并遵循那些步骤。

结果

您已打包 OSGi 批处理应用程序,修改 Blueprint xml 文件以将批处理工件描述为服务,并将 OSGi 批处理应用程序导出为企业捆绑软件归档 (EBA)。然后您创建了 xJCL。最后,您部署了 OSGi 批处理应用程序。


指示主题类型的图标 任务主题



时间戳记图标 最近一次更新时间: last_date
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=tgrid_cgbatchosgi
文件名:tgrid_cgbatchosgi.html