Extending the JobBean Class with Job Parameters
Use
This procedure tells you how to modify the HelloJob to pass a parameter to it and make the job output a parameter.
Prerequisites
The HelloJobBean is created.
Procedure
-
In the Project Explorer , from the HelloJobProject open the HelloJobBean.java file.
-
Update the source code as shown in the sample below.
The sample below modifies the MDB class from the previous step. It demonstrates how you can pass a parameter as input for the job and how you create a parameter for the job's output.
You use the getJobParameter() method from the JobContext interface to set a UserName parameter to the job that takes a string as input. You use the setJobParameter () method from the JobContext interface to set a NameLength parameter. The job processes the string input of the UserName parameter (calculates the number of characters in the string) and outputs the result of the calculation by logging a message in the database.
You specify the value of the UserName parameter's input later when you create a scheduler task for the HelloJob . You do not specify the NameLength parameter's output anywhere, as it depends on the input of the UserName parameter.
You specify the data type and the direction of the parameters in the job-definition.xml at step Creating and Editing the job-definition.xml
-
Save the file.
Next Step