You can add a batchlet step to the xml file of a Java™ batch job. Use a batchlet step to perform task-oriented processing such as running a
command or transferring a file.
Before you begin
A batchlet step is started once, runs to completion, and returns an exit status. Unlike a chunk
step, the batchlet step does not read, process, and write individual items, which are data
records.
Complete the following tasks:
- Install the Java batch feature for WebSphere® Application Server Developer Tools for Eclipse. This feature is
optional. You can install it from .
- Create a Java batch project.
- Create a Java batch job in the Java batch project.
About this task
Use the Job Specification Language (JSL) editor to create the batchlet step. Then, create a
batchlet class and add it to the batchlet step to implement the step.
Procedure
- In the Job Specification Language (JSL) editor, open the xml file for your Java batch job.
The JSL editor opens automatically if you click Finish when you create a
Java batch job. An xml file with the same name as the batch
job displays in the JSL editor.
If you are adding a step to an existing Java batch job xml
file, complete the following steps to open the xml file in the JSL editor:
- In the Enterprise Explorer view, select your Java batch
project that you created.
- Select .
- Double-click the xml file for your Java batch job.
The
file displays in the JSL editor.
- Select the job node on the Overview tab; click
Add.
- Select Step; click OK.
- Optional: Change the ID in the ID* field of the Details
tab.
- Select the step node on the Overview tab; click
Add.
- Select Batchlet; click OK.
- Include a batchlet class to implement the batchlet step.
You can create a new batchlet class for your project, use an existing batchlet class within your
project, or use an existing batchlet class in another project that is in the class path of your
project. Complete one of the following tasks:
- Create a class to implement this batchlet step.
- Click the reference link on the Details tab.
The New Batchlet
Class wizard displays.
- In the Java package field, specify the name of the package.
- In the Class name field, specify the name of the class.
- Optional: Optional: In the Super class field, specify the
name of the super class.
- Optional: Optional: In the Interfaces field, add more
interfaces to be implemented by this class.
- For Batch artifact loading options, accept the default value of
Use the fully qualified name of the class.
- If you select the Use the fully qualified name of the class option, the
runtime environment treats the batch artifact reference as a class name and loads the reference
through the thread context class loader. The loading is done to resolve a batch artifact reference
when the archive loader returns null for this reference.
- If you select the Use context and dependency injection (CDI) option, the
runtime environment uses the CDI implementation-specific loader to resolve the batch artifact
reference by using the bean name that you
specify.
- If you select the Add the class to the batch.xml file option, the runtime
environment uses the archive loader to resolve the reference by looking for the specified identifier
in the batch.xml file.
- Use an existing batchlet class to implement the batchlet step.
- Click Browse on the Details tab.
- Search for classes by name by selecting Search for classes and then
typing the class name.
- Select the class name from Matching items.
- As an alternative to the search, if a batch.xml file exists, select
Browse entries in batch.xml and then select one of the entries from the
table.
- Click OK.
- Click Finish.
Results
You created a batchlet step for a Java batch job. You
included a batchlet class in the batchlet step so that you can implement the step in the Java batch job. You created the batchlet class or used an existing
one.