org.jmonks.batch.framework
Class JobController

java.lang.Object
  extended byorg.jmonks.batch.framework.JobController
All Implemented Interfaces:
JobManagerMBean, JobMonitorMBean
Direct Known Subclasses:
BasicJobController, PoolJobController

public abstract class JobController
extends java.lang.Object
implements JobMonitorMBean, JobManagerMBean

Job Controller is the important component, which actually creates and drives the execution of the job. This defines the logic and the flow, how the user components needs to be written and how they would be driven while executing the job. Framework provides two controllers called as BasicJobController and PoolJobController which defines their own way of executing the job.

JobController provides a factory method which returns the appropriate controller component based on the provided controller config object. This implements the management and monitoring interfaces to make sure all the controller implementations are manageable and monitorable.

Since:
1.0
Version:
1.0
Author:
Suresh Pragada

Field Summary
protected  JobContext jobContext
          JobContext associated to this controller.
 
Constructor Summary
JobController()
           
 
Method Summary
 boolean changeLogLevel(java.lang.String loggerName, org.apache.log4j.Level level)
          Changes the log level for the requested logger name with the given log level.
static JobController createJobController(JobContext jobContext, Main controllerCreator)
           This factory method creates required implementation of the controller based on the controller configuration available in job context and sets the job context to the controller.
abstract  JobStatistics getJobStatistics()
          Returns the statistics of this job.
 org.apache.log4j.Level getLogLevel(java.lang.String loggerName)
          Gets the log level of the given logger name.
abstract  ErrorCode process()
          This method will be called by the Main to process the job.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jmonks.batch.framework.management.JobMonitorMBean
getExpectedRecordsCount, getProcessedRecordsCount, getProcessorIDList, getProcessorState
 
Methods inherited from interface org.jmonks.batch.framework.management.JobManagerMBean
getProcessorStatus, resume, stop, suspend
 

Field Detail

jobContext

protected JobContext jobContext
JobContext associated to this controller.

Constructor Detail

JobController

public JobController()
Method Detail

createJobController

public static JobController createJobController(JobContext jobContext,
                                                Main controllerCreator)

This factory method creates required implementation of the controller based on the controller configuration available in job context and sets the job context to the controller.

Parameters:
jobContext - Job context going to be associated with the controller.
controllerCreator - Main instance which is allowed to create the controller. This is to restrict only framework can instantiate the Controller.
Returns:
Returns the defined implementation of the controller.
Throws:
java.lang.SecurityException - If an attempt is made to create the controller by other than the Main class(framework).
ConfigurationException - If required properties are missing in the controller configuration or the values are invalid.

getLogLevel

public org.apache.log4j.Level getLogLevel(java.lang.String loggerName)
Gets the log level of the given logger name.

Specified by:
getLogLevel in interface JobManagerMBean
Parameters:
loggerName - Name of the logger wants to find the log level.
Returns:
Returns the log level, null, if the given logger could not be found.

changeLogLevel

public boolean changeLogLevel(java.lang.String loggerName,
                              org.apache.log4j.Level level)
Changes the log level for the requested logger name with the given log level.

Specified by:
changeLogLevel in interface JobManagerMBean
Parameters:
loggerName - Logger name needs to be modified.
level - new logging level.
Returns:
Returns true, if log level could be changed, false, otherwise.

process

public abstract ErrorCode process()
This method will be called by the Main to process the job. This returns the ErrorCode explaining whether the process has been failed or succeeded.

Returns:
Returns the ErrorCode as exit status of the job.

getJobStatistics

public abstract JobStatistics getJobStatistics()
Returns the statistics of this job. Statistics will be queried only after the completion of controller processing. Querying before the completion of processing always returns null.

Returns:
Returns the statistics of this job.