|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jmonks.batch.framework.controller.pool.AbstractPoolJobProcessor
Abstract pool job processor implements some of the responsiblites defined by the
pool job processor and leaves the application specific functionality implementation
to the final processor. Following is an example class shows how to make use of the
AbstractPoolJobProcessor.
public class MyPoolJobProcessor extends AbstractPoolJobProcessor { private Connection connection=null; public void initialize(JobContext jobContext) { // Perform the initialization for this instance of job processor. // Good place to get any references to any resources to be used to // to processing of all the job data. connection=ConnectionManager.getDBConnection(); } public ErrorCode process(Object jobData) { // Perform the business logic on the incoming jobData. connection.performBusinessLogic(jobData); return ErrorCode.JOB_COMPLETED_SUCCESSFULLY; } public void cleanup() { // Do some cleanup after all the jobData has been processed. connection.close(); } }
Field Summary | |
protected ProcessorStatus |
processorStatus
Holds the processor status. |
Constructor Summary | |
AbstractPoolJobProcessor()
|
Method Summary | |
abstract void |
cleanup()
Chance to do any cleanup at the end of the processing. |
long |
getProcessedJobDataCount()
Returns the number of job data objects this particular job processor has finsihed. |
java.lang.Object |
getProcessorState()
Gets the processor to be displyed or anaylyzed for the monitoring purposes. |
ProcessorStatus |
getProcessorStatus()
Gets the processor status being used by the management clients. |
abstract void |
initialize(JobContext jobContext)
Chance to initialize itself using the information provided through job context. |
abstract ErrorCode |
process(java.lang.Object jobData)
Execute the business logic on the given jobData and return the appropriate error code. |
ErrorCode |
processPool(JobContext jobContext,
JobPool pool)
Initializes the processor implementation by calling the initialize method by passing job context reference, gets the job data from the pool and passes that information to the processor implementation for processing and cleans up the processor implementation by calling the cleanup method. |
boolean |
resume()
Resumes the processor. |
boolean |
stop()
Stops the processor. |
boolean |
suspend()
Suspends the processor. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected ProcessorStatus processorStatus
Constructor Detail |
public AbstractPoolJobProcessor()
Method Detail |
public ErrorCode processPool(JobContext jobContext, JobPool pool)
Initializes the processor implementation by calling the initialize method by passing job context reference, gets the job data from the pool and passes that information to the processor implementation for processing and cleans up the processor implementation by calling the cleanup method. It consolidates all the return codes from the processor implementation process method and return the final error code. If it receives null as the return code, continues the processing, but returns pool job processor exception return code.
processPool
in interface PoolJobProcessor
jobContext
- Context the job is being run.pool
- Job pool reference where job data needs to be pulled.
public boolean suspend()
suspend
in interface PoolJobProcessor
public boolean resume()
resume
in interface PoolJobProcessor
public boolean stop()
stop
in interface PoolJobProcessor
public java.lang.Object getProcessorState()
PoolJobProcessor
getProcessorState
in interface PoolJobProcessor
PoolJobProcessor.getProcessorState()
public ProcessorStatus getProcessorStatus()
PoolJobProcessor
getProcessorStatus
in interface PoolJobProcessor
PoolJobProcessor.getProcessorStatus()
public long getProcessedJobDataCount()
PoolJobProcessor
getProcessedJobDataCount
in interface PoolJobProcessor
PoolJobProcessor.getProcessedJobDataCount()
public abstract void initialize(JobContext jobContext)
jobContext
- Context the job is being run.public abstract ErrorCode process(java.lang.Object jobData)
jobData
- Data to be processed.
public abstract void cleanup()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |