org.jmonks.batch.framework.controller.basic
Class BasicJobProcessor

java.lang.Object
  extended byorg.jmonks.batch.framework.controller.basic.BasicJobProcessor

public abstract class BasicJobProcessor
extends java.lang.Object

BasicJobProcessor lets job developers to implement their business logic in the process method and this method will be executed by the BasicJobController.

      public class MyBasicJobProcessor extends BasicJobProcessor
      {
          public ErrorCode process(JobContext jobContext)
          {
              //Perform the business logic.
              return ErrorCode.JOB_COMPLETED_SUCCESSFULLY;
          }
      }
  

Since:
1.0
Version:
1.0
Author:
Suresh Pragada

Field Summary
protected  ProcessorStatus processorStatus
          Indicates the status of this processor.
protected  java.lang.Thread processorThread
          Holds the thread references this processor has been spawned.
 
Constructor Summary
BasicJobProcessor()
           
 
Method Summary
abstract  long getProcessedRecordsCount()
          This is for monitoring applications to know how many records this particular (if there are multiple job processors) job processor has finished processing.
abstract  java.lang.Object getProcessorState()
          This is for monitoring applications to know what the information (record) this job processor is processing.
 ProcessorStatus getProcessorStatus()
          Returns the status of the processor as a ProcessorStatus object, which gives the information like whether the processor is running, suspended, resumed or stopped.
abstract  long getTotalRecordsCount()
          This is for monitoring applications to know how many records this particular (if there are multiple job processors) job processor is going to process.
abstract  ErrorCode process(JobContext jobContext)
           Does the processing and return the appropriate error code.
 boolean resume()
           Basic job controller calls this method to resume the job processor, when it receives a resume message from the managemet interface.
 boolean stop()
           Basic job controller calls this method to stop the job processor, when it receives a stop message from the managemet interface.
 boolean suspend()
           Basic job controller calls this method to suspend the job processor, when it receives a suspsend message from the managemet interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

processorThread

protected java.lang.Thread processorThread
Holds the thread references this processor has been spawned. This reference will be used to suspend, resume and stop the processor.


processorStatus

protected ProcessorStatus processorStatus
Indicates the status of this processor.

Constructor Detail

BasicJobProcessor

public BasicJobProcessor()
Method Detail

suspend

public boolean suspend()

Basic job controller calls this method to suspend the job processor, when it receives a suspsend message from the managemet interface. Default implementation will suspend the job processor abruptly as soon as it receives the message. Implementors can provide their own implementation by overriding this method to provide better mechanism.

Returns:
Returns true if processor has suspended, false otherwise.

resume

public boolean resume()

Basic job controller calls this method to resume the job processor, when it receives a resume message from the managemet interface. Default implementation will resume the job processor abruptly as soon as it receives the message. Implementors can provide their own implementation by overriding this method to provide better mechanism.

Returns:
Returns true if processor has resumed, false otherwise.

stop

public boolean stop()

Basic job controller calls this method to stop the job processor, when it receives a stop message from the managemet interface. Default implementation will stop the job processor abruptly as soon as it receives the message. Implementors can provide their own implementation by overriding this method to provide better mechanism.

Returns:
Returns true if processor has stopped, false otherwise.

process

public abstract ErrorCode process(JobContext jobContext)

Does the processing and return the appropriate error code. Properties configured for this job processor can be retrieved from the JobContext.

Parameters:
jobContext - Context of the job, where all the properties will be defined.
Returns:
Returns the appropriate error code needs to be passed to the invocation layer.

getProcessorState

public abstract java.lang.Object getProcessorState()
This is for monitoring applications to know what the information (record) this job processor is processing. Implementers should provide the granular level of information that this processor is processing at this time for better monitoring of this job. This returns object which can be used for the purpose of display.

Returns:
Returns the information (record) this processor is processing.

getProcessorStatus

public ProcessorStatus getProcessorStatus()
Returns the status of the processor as a ProcessorStatus object, which gives the information like whether the processor is running, suspended, resumed or stopped. Defalt implementation of this method returns the status based on the default implementation of suspend, resume and stop methods.

Returns:
Returns the processor status.

getTotalRecordsCount

public abstract long getTotalRecordsCount()
This is for monitoring applications to know how many records this particular (if there are multiple job processors) job processor is going to process.

Returns:
Returns the number of records/jobs this processor is going to process.

getProcessedRecordsCount

public abstract long getProcessedRecordsCount()
This is for monitoring applications to know how many records this particular (if there are multiple job processors) job processor has finished processing.

Returns:
Returns the number of records/jobs this processor has finished processing.