|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.kuali.rice.kcb.quartz.ConcurrentJob<T>
public abstract class ConcurrentJob<T>
Base class for jobs that must obtain a set of work items atomically
Field Summary | |
---|---|
protected ExecutorService |
executor
|
protected org.apache.log4j.Logger |
LOG
|
protected org.springframework.transaction.PlatformTransactionManager |
txManager
|
Constructor Summary | |
---|---|
ConcurrentJob()
|
Method Summary | ||
---|---|---|
protected org.springframework.transaction.support.TransactionTemplate |
createNewTransaction()
Helper method for creating a TransactionTemplate initialized to create a new transaction |
|
protected
|
executeInTransaction(org.springframework.transaction.support.TransactionCallback callback)
|
|
protected void |
finishProcessing(ProcessingResult<T> result)
Template method called after processing of work items has completed |
|
protected Collection<Collection<T>> |
groupWorkItems(Collection<T> workItems,
ProcessingResult<T> result)
Template method that subclasses should override to group work items into units of work |
|
protected abstract Collection<T> |
processWorkItems(Collection<T> items)
Template method that subclasses should override to process a given work item and mark it as untaken afterwards |
|
ProcessingResult<T> |
run()
Main processing method which invokes subclass implementations of template methods to obtain available work items, and process them concurrently |
|
void |
setExecutorService(ExecutorService executor)
Sets the ExecutorService to use to process work items. |
|
void |
setTransactionManager(org.springframework.transaction.PlatformTransactionManager txManager)
Sets the PlatformTransactionManager |
|
protected abstract Collection<T> |
takeAvailableWorkItems()
Template method that subclasses should override to obtain a set of available work items and mark them as taken |
|
protected abstract void |
unlockWorkItem(T item)
Template method that subclasses should override to unlock a given work item when procesing has failed. |
|
protected void |
unlockWorkItemAtomically(T workItem)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final org.apache.log4j.Logger LOG
protected ExecutorService executor
protected org.springframework.transaction.PlatformTransactionManager txManager
Constructor Detail |
---|
public ConcurrentJob()
Method Detail |
---|
public void setExecutorService(ExecutorService executor)
ExecutorService
to use to process work items. Default is single-threaded.
executor
- the ExecutorService
to use to process work items. Default is single-threaded.public void setTransactionManager(org.springframework.transaction.PlatformTransactionManager txManager)
PlatformTransactionManager
txManager
- the PlatformTransactionManager
protected org.springframework.transaction.support.TransactionTemplate createNewTransaction()
protected abstract Collection<T> takeAvailableWorkItems()
protected Collection<Collection<T>> groupWorkItems(Collection<T> workItems, ProcessingResult<T> result)
workItems
- list of work items to break into groupsresult
- ProcessingResult to modify if there are any failures...this is sort of a hack because previously
failure to obtain a deliverer was considered a work item failure, and now this method has been factored out...
but the tests still want to see the failure
protected abstract Collection<T> processWorkItems(Collection<T> items)
item
- the work item
protected abstract void unlockWorkItem(T item)
item
- the work item to unlockpublic ProcessingResult<T> run()
protected void finishProcessing(ProcessingResult<T> result)
protected void unlockWorkItemAtomically(T workItem)
protected <X> X executeInTransaction(org.springframework.transaction.support.TransactionCallback callback)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |