Class WorkManagerImpl
- java.lang.Object
-
- com.tangosol.coherence.servlet.commonj.impl.WorkManagerImpl
-
- All Implemented Interfaces:
WorkManager
public class WorkManagerImpl extends Object implements WorkManager
This is a simple implementation of a WorkManager that uses a thread pool to delegate the work to. The number of daemon threads can be configured, but default is 10.- Author:
- Torkel Dominique
- See Also:
WorkManager
-
-
Field Summary
-
Fields inherited from interface com.tangosol.coherence.servlet.commonj.WorkManager
IMMEDIATE, INDEFINITE
-
-
Constructor Summary
Constructors Constructor Description WorkManagerImpl()
WorkManagerImpl(int minThreads, int maxThreads)
WorkManagerImpl(int minThreads, int maxThreads, int maxQueueSize)
WorkManagerImpl(ExecutorService executor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WorkItem
schedule(Work work)
WorkItem
schedule(Work work, WorkListener listener)
boolean
shutdown(long timeout)
This method is not part of CommonJ but is needed here since our implementation creates threads that needs to be cleaned up.
-
-
-
Constructor Detail
-
WorkManagerImpl
public WorkManagerImpl()
-
WorkManagerImpl
public WorkManagerImpl(int minThreads, int maxThreads)
-
WorkManagerImpl
public WorkManagerImpl(int minThreads, int maxThreads, int maxQueueSize)
-
WorkManagerImpl
public WorkManagerImpl(ExecutorService executor)
-
-
Method Detail
-
schedule
public WorkItem schedule(Work work) throws WorkException, IllegalArgumentException
- Specified by:
schedule
in interfaceWorkManager
- Parameters:
work
- the Work to execute- Returns:
- The workitem representing the asynchronous work. If the Work is serializable then a RemoteWorkItem is always returned.
- Throws:
WorkException
- If queuing this up results in an exception then a WorkException is thrownIllegalArgumentException
- See Also:
WorkManager.schedule(commonj.work.Work)
-
schedule
public WorkItem schedule(Work work, WorkListener listener) throws WorkException, IllegalArgumentException
- Specified by:
schedule
in interfaceWorkManager
- Parameters:
work
- the Work to executelistener
- an optional WorkListener- Returns:
- The workitem representing the asynchronous work. If the Work is serializable then a RemoteWorkItem is always returned.
- Throws:
WorkException
- If queuing this up results in an exception then a WorkException is thrownIllegalArgumentException
- See Also:
WorkManager.schedule(commonj.work.Work, commonj.work.WorkListener)
-
shutdown
public boolean shutdown(long timeout)
Description copied from interface:WorkManager
This method is not part of CommonJ but is needed here since our implementation creates threads that needs to be cleaned up.- Specified by:
shutdown
in interfaceWorkManager
- Parameters:
timeout
- The number of milliseconds until the shutdown is aborted.- Returns:
- true if shutdown was successful, otherwise false.
- See Also:
WorkManager.shutdown(long)
-
-