|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.objectweb.easybeans.jca.workmanager.ResourceWorkManager
public class ResourceWorkManager
Implementation of the Resource Work Manager API.
Field Summary | |
---|---|
private static long |
FEW_MORE_SECONDS
Wait few more seconds when waiting. |
private int |
freeThreads
Threads that are ready to work. |
private static JLog |
logger
Logger. |
private int |
maxpoolsz
The maximum size of the pool. |
private static long |
MILLISECONDS
MilliSeconds value. |
private int |
minpoolsz
The minimum size of the pool. |
private static int |
poolnumber
Identifier of this pool. |
private int |
poolsz
The current size of thread pool. |
private boolean |
stopped
Pool status : by default, it is not stopped. |
private static int |
threadnumber
Thread number (when building ResourceWorkThread, it assigns a new thread number). |
private javax.transaction.TransactionManager |
transactionManager
TransactionManager to use. |
private long |
waitingTime
The time to wait (in millisec). |
private java.util.LinkedList<ResourceWork> |
workList
List of ResourceWork (which wrap Work object). |
Fields inherited from interface javax.resource.spi.work.WorkManager |
---|
IMMEDIATE, INDEFINITE, UNKNOWN |
Constructor Summary | |
---|---|
ResourceWorkManager(javax.transaction.TransactionManager transactionManager,
int minsz,
int maxsz,
long threadwait)
Default Constructor. |
Method Summary | |
---|---|
private void |
doMyWork(javax.resource.spi.work.Work work,
long timeout,
javax.resource.spi.work.ExecutionContext executionContext,
javax.resource.spi.work.WorkListener workListener,
long creationTime)
Internal method doing the work. |
void |
doWork(javax.resource.spi.work.Work work)
Accepts a Work instance for processing. |
void |
doWork(javax.resource.spi.work.Work work,
long timeout,
javax.resource.spi.work.ExecutionContext executionContext,
javax.resource.spi.work.WorkListener workListener)
Accepts a Work instance for processing. |
int |
getCurrentPoolSize()
|
int |
getMaxPoolSize()
|
int |
getMinPoolSize()
|
void |
nextWork()
Do the next JWork object to be run. |
void |
scheduleWork(javax.resource.spi.work.Work work)
Accepts a Work instance for processing. |
void |
scheduleWork(javax.resource.spi.work.Work work,
long timeout,
javax.resource.spi.work.ExecutionContext executionContext,
javax.resource.spi.work.WorkListener workListener)
Accepts a Work instance for processing. |
void |
setMaxPoolSize(int maxsz)
Sets the max pool size. |
void |
setMinPoolSize(int minsz)
Sets the min pool size. |
long |
startWork(javax.resource.spi.work.Work work)
Accepts a Work instance for processing. |
long |
startWork(javax.resource.spi.work.Work work,
long timeout,
javax.resource.spi.work.ExecutionContext executionContext,
javax.resource.spi.work.WorkListener workListener)
Accepts a Work instance for processing. |
void |
stopThreads()
Remove this WorkManager : Stop all threads. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final long MILLISECONDS
private static JLog logger
private java.util.LinkedList<ResourceWork> workList
private static int poolnumber
private static int threadnumber
private int maxpoolsz
private int minpoolsz
private int poolsz
private int freeThreads
private long waitingTime
private boolean stopped
private static final long FEW_MORE_SECONDS
private javax.transaction.TransactionManager transactionManager
Constructor Detail |
---|
public ResourceWorkManager(javax.transaction.TransactionManager transactionManager, int minsz, int maxsz, long threadwait)
minsz
- the minimum pool sizemaxsz
- the maximum pool sizetransactionManager
- the transaction manager to use.threadwait
- max time in seconds a thread will wait.Method Detail |
---|
public int getCurrentPoolSize()
public int getMinPoolSize()
public int getMaxPoolSize()
public void setMinPoolSize(int minsz)
minsz
- the min pool size.public void setMaxPoolSize(int maxsz)
maxsz
- the max pool size.public void doWork(javax.resource.spi.work.Work work) throws javax.resource.spi.work.WorkRejectedException, javax.resource.spi.work.WorkCompletedException, javax.resource.spi.work.WorkException
doWork
in interface javax.resource.spi.work.WorkManager
work
- The unit of work to be done. Could be long or short-lived.
javax.resource.spi.work.WorkRejectedException
- a Work instance has been rejected from
further processing.
javax.resource.spi.work.WorkCompletedException
- a Work instance has completed execution
with an exception.
javax.resource.spi.work.WorkException
- if work is not donepublic void doWork(javax.resource.spi.work.Work work, long timeout, javax.resource.spi.work.ExecutionContext executionContext, javax.resource.spi.work.WorkListener workListener) throws javax.resource.spi.work.WorkRejectedException, javax.resource.spi.work.WorkCompletedException, javax.resource.spi.work.WorkException
doWork
in interface javax.resource.spi.work.WorkManager
work
- The unit of work to be done. Could be long or short-lived.timeout
- a time duration (in milliseconds) within which the
execution of the Work instance must start. Otherwise, the Work
instance is rejected with a WorkRejectedException set to an
appropriate error code (WorkRejectedException.TIMED_OUT).executionContext
- an object containing the execution context with
which the submitted Work instance must be executed.workListener
- an object which would be notified when the various
Work processing events (work accepted, work rejected, work
started, work completed) occur.
javax.resource.spi.work.WorkRejectedException
- a Work instance has been rejected from
further processing.
javax.resource.spi.work.WorkCompletedException
- a Work instance has completed execution
with an exception.
javax.resource.spi.work.WorkException
- if work is not donepublic long startWork(javax.resource.spi.work.Work work) throws javax.resource.spi.work.WorkRejectedException, javax.resource.spi.work.WorkException
startWork
in interface javax.resource.spi.work.WorkManager
work
- The unit of work to be done. Could be long or short-lived.
javax.resource.spi.work.WorkRejectedException
- a Work instance has been rejected from
further processing.
javax.resource.spi.work.WorkException
- if work is not startedpublic long startWork(javax.resource.spi.work.Work work, long timeout, javax.resource.spi.work.ExecutionContext executionContext, javax.resource.spi.work.WorkListener workListener) throws javax.resource.spi.work.WorkRejectedException, javax.resource.spi.work.WorkException
startWork
in interface javax.resource.spi.work.WorkManager
work
- The unit of work to be done. Could be long or short-lived.timeout
- a time duration (in milliseconds) within which the
execution of the Work instance must start. Otherwise, the Work
instance is rejected with a WorkRejectedException set to an
appropriate error code (WorkRejectedException.TIMED_OUT).executionContext
- an object containing the execution context with
which the submitted Work instance must be executed.workListener
- an object which would be notified when the various
Work processing events (work accepted, work rejected, work
started, work completed) occur.
javax.resource.spi.work.WorkRejectedException
- a Work instance has been rejected from
further processing.
javax.resource.spi.work.WorkException
- if work is not startedpublic void scheduleWork(javax.resource.spi.work.Work work) throws javax.resource.spi.work.WorkRejectedException, javax.resource.spi.work.WorkException
scheduleWork
in interface javax.resource.spi.work.WorkManager
work
- The unit of work to be done. Could be long or short-lived.
javax.resource.spi.work.WorkRejectedException
- - indicates that a Work instance has been
rejected from further processing. This can occur due to internal
factors.
javax.resource.spi.work.WorkException
- if work is not scheduled.public void scheduleWork(javax.resource.spi.work.Work work, long timeout, javax.resource.spi.work.ExecutionContext executionContext, javax.resource.spi.work.WorkListener workListener) throws javax.resource.spi.work.WorkRejectedException, javax.resource.spi.work.WorkException
scheduleWork
in interface javax.resource.spi.work.WorkManager
work
- The unit of work to be done. Could be long or short-lived.timeout
- a time duration (in milliseconds) within which the
execution of the Work instance must start. Otherwise, the Work
instance is rejected with a WorkRejectedException set to an
appropriate error code (WorkRejectedException.TIMED_OUT).executionContext
- an object containing the execution context with
which the submitted Work instance must be executed.workListener
- an object which would be notified when the various
Work processing events (work accepted, work rejected, work
started, work completed) occur.
javax.resource.spi.work.WorkRejectedException
- a Work instance has been rejected from
further processing.
javax.resource.spi.work.WorkException
- if work is not scheduled.private void doMyWork(javax.resource.spi.work.Work work, long timeout, javax.resource.spi.work.ExecutionContext executionContext, javax.resource.spi.work.WorkListener workListener, long creationTime) throws javax.resource.spi.work.WorkException
work
- The unit of work to be done. Could be long or short-lived.timeout
- a time duration (in milliseconds) within which the
execution of the Work instance must start. Otherwise, the Work
instance is rejected with a WorkRejectedException set to an
appropriate error code (WorkRejectedException.TIMED_OUT).executionContext
- an object containing the execution context with
which the submitted Work instance must be executed.workListener
- an object which would be notified when the various
Work processing events (work accepted, work rejected, work
started, work completed) occur.creationTime
- the date of the creation of the work
javax.resource.spi.work.WorkException
- if work is not performed.public void nextWork() throws javax.resource.spi.work.WorkException, java.lang.InterruptedException, ResourceWorkManagerStoppedException
javax.resource.spi.work.WorkException
- if work is not done
java.lang.InterruptedException
- if one object can't wait.
ResourceWorkManagerStoppedException
- if the manager is stopped.public void stopThreads()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |