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
  • Constructor Details

    • 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 Details

    • schedule

      public WorkItem schedule(Work work) throws WorkException, IllegalArgumentException
      Specified by:
      schedule in interface WorkManager
      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 thrown
      IllegalArgumentException
      See Also:
      • WorkManager.schedule(commonj.work.Work)
    • schedule

      public WorkItem schedule(Work work, WorkListener listener) throws WorkException, IllegalArgumentException
      Specified by:
      schedule in interface WorkManager
      Parameters:
      work - the Work to execute
      listener - 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 thrown
      IllegalArgumentException
      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 interface WorkManager
      Parameters:
      timeout - The number of milliseconds until the shutdown is aborted.
      Returns:
      true if shutdown was successful, otherwise false.
      See Also: