Previous Topic: POJO JobsNext Topic: RMI Jobs


Define a POJO Job

You can define a POJO job to create a Java object instance with no arguments, invoke a method on the object instance, and store the method's output.

Note: To run these jobs, your system requires the following agents:

Follow these steps:

  1. Open the Application that you want to add the job to in the Define perspective.

    The Application appears in the workspace.

  2. Select the POJO job from the Application and Web Services group in the Palette view, and drag the job to the workspace.

    The POJO icon appears on the Application workspace view.

  3. Right-click the POJO icon, and select Edit from the pop-up menu.

    The Basic page of the POJO dialog opens.

  4. Complete the following required fields:
    Name

    Defines the name of the job that you want to schedule.

    Limits: 128 alphanumeric characters, plus the special characters commercial at (@), pound (#), dollar sign ($), underscore (_), square brackets ([]), brace brackets ({}), and percent sign (%) as a symbolic variable introducer character.

    Agent name

    Specifies the name of the agent that lets you access a remote server and invoke a method on a Java object.

    Class name

    Specifies the Java class to instantiate.

    Example: java.lang.String

    Method

    Specifies the Java method to call on the instance of the Java object.

    Example: concat

  5. (Optional) Specify the following information:
    Output destination

    Specifies the location of the Java serialized object produced by the job.

    Limits: Up to 256 characters

    Note: If you do not specify an output destination, the Java serialized object is stored in the spool directory on the agent computer using the job name and a numeric suffix as the file name.

  6. (Optional) Click Method Parameters in the left pane.

    The Method Parameters page opens in the right pane.

  7. Click New to add parameters for the method.

    The New Parameter dialog opens.

  8. Select one of the following parameter options:

    The fields that are related to the option appear.

  9. Complete the following fields, as required:
    Type

    Specifies the Java class of the parameter. This field is mandatory for the Value and Array parameter options only.

    Example: Integer

    Value

    (Optional) Specifies the String value for the method parameter. This field is used with the Value parameter option.

    Example: 2

    Payload producing job

    Specifies the name of the predecessor job that produced the Java serialized object to be used as an input parameter. This field is used with the Payload producing job parameter option.

    Note: The job must be defined within the same Application as the job you are defining.

    Example: ANYJOB.URI

    Array

    Specifies a set of string values for the method parameter. Click Add to enter each value. This field is used with the Array parameter option.

    Example: 1, 2, 3

  10. Click OK.

    The New Parameter dialog closes and the parameters appear in a list.

  11. Click OK.

    The POJO job is defined.

Example: Define a POJO Job

Suppose that you want to define a POJO job that creates an empty java string, and calls the method parseInt on it with the argument “5”.

Follow these steps:

  1. Enter the following required information in the Basic page:
  2. Add the following parameter in the Method Parameters page:
  3. Click OK.

Example: Create a Custom Java Class and Invoke a Method on it Using a POJO Job

Suppose that you want to create a custom Java class (Calculate) and invoke a method on it using a POJO job. In this example, the job calls the sum method from the Calculate class. The Calculate class belongs to a package named client.

Follow these steps:

  1. Create a custom Java class as follows:
    package client;
    public class Calculate
    {
     public int sum (int num1, int num2)
     {
      return num1 + num2;
     }
    }
    
  2. Run the following command at the command prompt:
    javac -d . Calculate.java
    

    The custom Java class is compiled and the Calculate.class file is generated in the current directory.

    Note: The dot (.) in the command indicates the current directory into which the class file is generated. You can also specify a specific directory, for example, javac -d C:\temp Calculate.java.

  3. Stop the agent.
  4. Create the Classes directory in the following location:
    agent_install_dir\jars\ext
    
  5. Create the client directory in the following location:
    agent_install_dir\jars\ext\Classes
    

    client is the name of the package that the Calculate class belongs to.

  6. Copy the Calculate.class file into the client directory that you created:
    agent_install_dir\jars\ext\Classes\client
    
  7. Start the agent.
  8. Enter the following required information in the Basic page of the POJO job:
  9. Add the following two parameters in the Method Parameters page:
  10. Click OK.

Example: Instantiate a New Class Wrapped in a JAR File

Suppose that you want to instantiate a new class (Calculate) that is wrapped in a JAR file (axis.jar). In this example, the job calls the sub method from the Calculate class. The Calculate class belongs to a package named client.

Follow these steps:

  1. Stop the agent.
  2. Copy the axis.jar file in the following location:
    agent_install_dir\jars\ext
    

    The axis.jar file contains the client package that the Calculate class belongs to.

  3. Start the agent.
  4. Enter the following required information in the Basic page of the POJO job:
  5. Add the following two parameters in the Method Parameters page:
  6. Click OK.

Example: Define a Payload Consuming Job

Suppose that you want to create a payload consuming job that uses a serialized Java object as an input parameter from a payload producing job.

In this example, the POJO job (POJO1) appends two string values by calling a method (append2Strings) from a class (QATest5) and returns a java.lang.String value to the Web Service RPC/Encoded job (WebService1). The class belongs to a package named client. The WebService1 job performs Celsius to Fahrenheit conversion on the java.lang.String value that is returned from POJO1 job.

Note: Restart the agent after you deploy the QATest5 class file in the agent installation directory.

Follow these steps:

  1. Open the application that you want to add the payload producing and payload consuming jobs to.
  2. Enter the following required information in the Basic page of the POJO job:
  3. Add the following two parameters in the Method Parameters page:
  4. Click OK.
  5. Enter the following required information in the Basic page of the Web Service RPC/Encoded job:
  6. Add the following parameter in the Operation Parameters page:
  7. Add the following information in the Operation Response page:
  8. Click OK.
  9. Add the dependencies link from the POJO1 job to the WebService1 job.

More information:

Payload Producing and Payload Consuming Jobs

POJO Jobs