Follow these steps to learn how to develop, package and deploy your own TaskBean.
Step 1: Subclass TaskBean
Using the TaskBean API, subclass the org.taskBean.TaskBeanService. At
a minimum you must override the process method. Review the JavaDocs and
other supporting documentation to learn how to take advantage of some of the more
advanced features like Customizers, input Viewers, output Viewers, ....etc. For the
sake of this example, the TaskBean will have a class name of
com.acme.MyTask.
package com.acme;
import org.taskbean.TaskBeanService;
public class MyTask extends TaskBeanService {
public void process(TaskBeanContext op, JobContext run, Object inBean, Object outBean)
{
/**
* Create and name a logger to use to log all messages. The name
* can be anything you like. You can create multiple loggers. This
* allows you to filter on log message when viewing
* the runtime logs for a TaskBean.
*/
Logger myLogger = Logger.getLogger("myLogger");
myLogger.log(Level.INFO, "Hello out there");
//Remember that you can perform any server-side logic here like
//access a database perform RMI, JMS, web services calls, .....etc
return;
}
/**
* If your specific TaskBean does not use an output JavaBean then
* have this method return null.
*/
public Class getOutputBeanClass() throws ClassNotFoundException {
return null;
}
/**
* Returns the name of the input JavaBean used during processing and
* can be edited by the Customizer.
*
* If your specific TaskBean does not use an input JavaBean then
* have this method return null.
*/
public Class getInputBeanClass() throws ClassNotFoundException {
return null;
}
}
Compile the TaskBean related classes and place them in a JAR file called bean.jar.
later. bean.jar should contain at a minimum all the TaskBean related classes. If
your TaskBean uses other third party JARs, these can also be included (this will be described
later).
Create a file called taskbean.conf that will contain meta information relating
to the TaskBean. This file is very important and must be set properly for the TaskBean
to be recognized. The two most important properties are TaskBeanService,
which specifies the name of the TaskBeanService subclass and Version, which
assigns a version number to the TaskBean. The version must follow the naming schema
x-y-z (e.g. 1-0-0, 2-1-0, 3-5-1). The file will look something like this:
TaskBeanService: com.acme.MyTask
Version: 1-0-0
Description: Simple little example.
Author: Sam Taha
Company: Grand Logic, Inc.
JARS:
Take the bean.jar and the taskbean.conf files and JAR
them up. Here is an example of what the JAR contents might look like:
com-acme-MyTask-v1-0-0/
bean.jar
taskbean.conf
lib/ /* place any third party JARs in this directory */
JAR up the content of the directory structure as shown above. The name of the JAR
file will be com-acme-MyTask-v1-0-0.tba. As shown, the name of the
TBA file is made up of the TaskBeanService subclass and the version number.
Take the com-acme-MyTask-v1-0-0.tba file and place it in the JobServer's
jobserver/taskbean directory. When the JobServer Engine is restarted or
when the TaskBean repository is reloaded, the TBA file will be expanded and the TaskBean
within it will be recognized by JobServer.
You can use the TaskBean Management tool available in JobServer to analyze
the new TaskBean. This tool also allows you to load new TaskBeans.
Using the JobServer's Job Designer tool, you can now choose this newly created TaskBean
when defining and configuring a Job.