| java.lang.Object java.lang.Thread com.jcorporate.expresso.core.registry.ExpressoThread com.jcorporate.expresso.core.job.Job
All known Subclasses: com.jcorporate.expresso.services.job.TestJob, com.jcorporate.expresso.services.job.ClearOldValidation, com.jcorporate.expresso.services.job.ValidationJob, com.jcorporate.expresso.ext.job.SendNotice, com.jcorporate.expresso.services.job.ControllerJob,
Job | abstract public class Job extends ExpressoThread (Code) | | A Job is an asynchronous task who's results will generally be emailed to
the user initiating the job. Jobs themselves are executed by JobHandler, and
are also capable of getting queued in such a way as to repeatedly execute.
Important: from Expresso 5.6, threadlocal datamembers are expected to hold User ID and
data context. Therefore, any subclass of Job should set this information
at the beginning of run() by calling, in the subclass, super.run(); as the first line
of the subclass run() method.
author: Michael Nash See Also: com.jcorporate.expresso.core.utility.JobHandler since: Expresso 1.0 |
Constructor Summary | |
public | Job() |
Method Summary | |
protected void | addFunction(String name, String descrip) If a job can do more than one distinct function, it registers
those functions so that the administration controller can
tell the user about them. | public void | addParamValidValues(String paramCode, Vector paramValidValues) Adds a list of valid values for the particular parmeters. | protected void | addParameter(String paramCode, String paramDescrip) | protected void | finish(String msg) | protected void | finish(String msg, Throwable t) | public CrontabEntry | getCronAlarmEntry() | protected String | getDataContext() | public Hashtable | getFunctions() | public String | getJobNumber() | protected String | getJobParameter(String paramCode) Convenience method to get the job parameters one by one as needed.
Parameters: paramCode - to retrieve. | protected List | getJobParameterList() | public JobQueue | getJobQueueEntry() | public Vector | getParamValidValues(String paramCode) | public String | getParameterDescription(String paramName) | public Hashtable | getParameterNamesAndDescriptions() | protected String | getSchema(String schemaClass) | protected String | getString(String stringCode) Getstring without any substitution capabilities
Parameters: stringCode - the string code. | protected String | getString(String stringCode, String arg1) Internationalization methods. | protected String | getString(String stringCode, String arg1, String arg2) Internationalization methods. | protected String | getString(String stringCode, String arg1, String arg2, String arg3) Internationalization methods. | protected String | getString(String stringCode, String arg1, String arg2, String arg3, String arg4) Internationalization methods. | protected String | getString(String stringCode, Object[] args) Pass on a call to retrieve an appropriate localized string from the
correct Schema object. | public String | getTitle() Retrieve the title of the job. | public String | getUser() | protected boolean | hasParameters() | public static synchronized Job | instantiate(String className) | public boolean | multiThreaded() Implementors of this class must override this to return true if they are
multi-threaded, e.g. | public void | run() | protected synchronized void | sendMail(String subject, String myRecipients, Vector mailMessage) | public void | setCronAlarmEntry(CrontabEntry obj) | public synchronized void | setQueue(JobQueue newJobQueue) Set the JobQueue object that created this job. | protected void | setSchema(String schemaClass) Tell this Job object what Schema it belongs to. | public void | setUseCron(boolean useCron) | public boolean | useCron() |
IS_NOTIFY_ON_JOB_SUCCESS | final public static String IS_NOTIFY_ON_JOB_SUCCESS(Code) | | Key for if we should notify the user on a successful job.
|
log | protected static Logger log(Code) | | The log4j Logger
|
Job | public Job()(Code) | | Default Constructor
|
addFunction | protected void addFunction(String name, String descrip)(Code) | | If a job can do more than one distinct function, it registers
those functions so that the administration controller can
tell the user about them.
Parameters: name - the name of the function Parameters: descrip - the function description |
addParamValidValues | public void addParamValidValues(String paramCode, Vector paramValidValues)(Code) | | Adds a list of valid values for the particular parmeters. Will be
automatically be picked up by the controller that generically launches
any jobs.
Parameters: paramCode - the parameter code Parameters: paramValidValues - Vector of valid value objects |
addParameter | protected void addParameter(String paramCode, String paramDescrip)(Code) | | Add a parameter
Parameters: paramCode - the actual parameter code, similar to the parametercode for a controller. Parameters: paramDescrip - The "user friendly" name of the description. |
finish | protected void finish(String msg)(Code) | | Finish up the Job, clearing the job queue entry, sending a completion email,
flush the queues, etc
Parameters: msg - the message to send to the queuing user |
finish | protected void finish(String msg, Throwable t)(Code) | | Finish up the Job, clearing the job queue entry, sending a completion email,
flush the queues, etc
Parameters: msg - the message to send to the queuing user Parameters: t - The Exception to log in the message |
getCronAlarmEntry | public CrontabEntry getCronAlarmEntry()(Code) | | Retrieve the cron alarm entry
Object |
getDataContext | protected String getDataContext() throws DBException(Code) | | Retrieve the data context of the job
java.lang.String |
getFunctions | public Hashtable getFunctions()(Code) | | Retrieve the functions the Job Handler can execute
Hashtable |
getJobNumber | public String getJobNumber()(Code) | | Return the jobnumber of this job
String |
getJobParameter | protected String getJobParameter(String paramCode) throws DBException(Code) | | Convenience method to get the job parameters one by one as needed.
Parameters: paramCode - to retrieve. The string of the param value, or null if no such named parameterexists. throws: DBException - if there's an error reading the values. |
getJobParameterList | protected List getJobParameterList() throws DBException(Code) | | Returns a List of the parameters given to the job
A List of the parameters or null if there are no parametersfor the job. throws: DBException - upon error |
getJobQueueEntry | public JobQueue getJobQueueEntry() throws DBException(Code) | | Return the job queue entry that caused this job to begin
JobQueue A JobQueue object throws: DBException - If the object cannot be returned |
getParamValidValues | public Vector getParamValidValues(String paramCode)(Code) | | Retrieve all valid values for the given parameter
Parameters: paramCode - the parameter name a vector of valid value objects |
getParameterDescription | public String getParameterDescription(String paramName)(Code) | | Get the value of a specified parameter
Parameters: paramName - the parameter name java.lang.String the parameter value or null |
getParameterNamesAndDescriptions | public Hashtable getParameterNamesAndDescriptions()(Code) | | Retreive all parameters
hashtable of parameters |
getSchema | protected String getSchema(String schemaClass) throws ServerException(Code) | | Instantiate & return the schema class given in the current parameter
BUG BUG: This function isn't right, what was the intention: -MR
Parameters: schemaClass - the schema class to set A Schema object instantiated from the class named by the'SchemaClass' parameter |
getString | protected String getString(String stringCode, Object[] args)(Code) | | Pass on a call to retrieve an appropriate localized string from the
correct Schema object. This is a convenience method that can be used
within Job objects to save having to build a long call to the
static methods in the Messages object.
Parameters: stringCode - the string code to look up in the messages bundle Parameters: args - the formatting object array java.lang.String the expanded value throws: IllegalArgumentException - if the stringCode cannot be found inthe schema's message bundle. |
getTitle | public String getTitle()(Code) | | Retrieve the title of the job. Override in your own job for a descriptive
entry
java.lang.String |
getUser | public String getUser()(Code) | | Return the username who requested this job
String |
hasParameters | protected boolean hasParameters() throws DBException(Code) | | Does this job have parameters?
true if it does. throws: DBException - upon error |
instantiate | public static synchronized Job instantiate(String className) throws ServerException(Code) | | Convenience method to create a Job from it's name
Parameters: className - the classname to instantiate an instantiated Job throws: ServerException - upon instantiation error |
multiThreaded | public boolean multiThreaded()(Code) | | Implementors of this class must override this to return true if they are
multi-threaded, e.g. can be run at the same time as other jobs.
boolean True if this job can be run in parallel with other jobs |
run | public void run()(Code) | | Implement the actual logic for this server object
|
sendMail | protected synchronized void sendMail(String subject, String myRecipients, Vector mailMessage)(Code) | | Send an e-mail message to a list of recipients
Parameters: subject - Subject of the message Parameters: myRecipients - Recipients of the message Parameters: mailMessage - Contents of the message, as strings in a vector |
setCronAlarmEntry | public void setCronAlarmEntry(CrontabEntry obj)(Code) | | Sets the cron alarm entry
Parameters: obj - the cron alarm entry |
setQueue | public synchronized void setQueue(JobQueue newJobQueue)(Code) | | Set the JobQueue object that created this job. Called by the
server when the job is launched, so we have this information available.
Parameters: newJobQueue - JobQueue object that triggered this job |
setSchema | protected void setSchema(String schemaClass)(Code) | | Tell this Job object what Schema it belongs to. This is used
when the Job tries to use it's "getString(String, Object[])"
method to prepare internationalized messages - it passes the call
along to the appropriate schema which knows how to locate the
proper message file.
Parameters: schemaClass - the schema class name |
setUseCron | public void setUseCron(boolean useCron)(Code) | | If a job will be executed in cron process - say it
Parameters: useCron - true if this job will be executed in cron process |
useCron | public boolean useCron()(Code) | | Should we use Crontab?
true if set |
|
|