to.etc.webapp.pendingoperations
Class PendingOperationTaskProvider

java.lang.Object
  extended by to.etc.webapp.pendingoperations.PendingOperationTaskProvider
All Implemented Interfaces:
IPollQueueTaskProvider

public class PendingOperationTaskProvider
extends java.lang.Object
implements IPollQueueTaskProvider

This polled task provider checks for tasks to execute in the sys_pending_operations table. It handles all polling chores and properly handles all order requirements for pending operations. Operations here are checked only every 5 minutes.

Author:
Frits Jalvingh Created on Mar 4, 2009

Method Summary
 void addListener(IPendingOperationListener l)
           
 IPendingOperationExecutor findExecutor(PendingOperation po)
          Find an executor for a given pendingOperation type.
static PendingOperationTaskProvider getInstance()
           
 java.lang.Runnable getRunnableTask()
          This checks for a new pending operation to execute.
static void initialize(javax.sql.DataSource ds, java.lang.String serverID)
          Initializes this thing, and adds it to the worker queue handler.
 void initializeOnRegistration(PollingWorkerQueue pwq)
           
 void registerPendingOperationType(java.lang.String type, IPendingOperationExecutor pox)
          Register a pending operation type and it's executor.
 void removeListener(IPendingOperationListener l)
           
 void saveOperation(PendingOperation po, java.io.Serializable object)
          Store a PendingOperation in the table, or die.
 void saveOperation(PendingOperation po, StringInputStream sis)
          Store a PendingOperation in the table, or die.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

initialize

public static void initialize(javax.sql.DataSource ds,
                              java.lang.String serverID)
Initializes this thing, and adds it to the worker queue handler.

Parameters:
serverID -

getInstance

public static PendingOperationTaskProvider getInstance()

addListener

public void addListener(IPendingOperationListener l)

removeListener

public void removeListener(IPendingOperationListener l)

initializeOnRegistration

public void initializeOnRegistration(PollingWorkerQueue pwq)
                              throws java.lang.Exception
Specified by:
initializeOnRegistration in interface IPollQueueTaskProvider
Throws:
java.lang.Exception

getRunnableTask

public java.lang.Runnable getRunnableTask()
                                   throws java.lang.Exception
This checks for a new pending operation to execute. Only one thread can use this operation at a time. The first thread that enters this method obtains the baton and is allowed to continue. Other threads entering see that the baton is used and exit immediately, without a task.

Specified by:
getRunnableTask in interface IPollQueueTaskProvider
Returns:
Throws:
java.lang.Exception
See Also:
IPollQueueTaskProvider.getRunnableTask()

registerPendingOperationType

public void registerPendingOperationType(java.lang.String type,
                                         IPendingOperationExecutor pox)
Register a pending operation type and it's executor.

Parameters:
type -
pox -

findExecutor

public IPendingOperationExecutor findExecutor(PendingOperation po)
Find an executor for a given pendingOperation type.

Parameters:
po -
Returns:

saveOperation

public void saveOperation(PendingOperation po,
                          StringInputStream sis)
                   throws java.lang.Exception
Store a PendingOperation in the table, or die.

Parameters:
po -
sis -
Throws:
java.lang.Exception

saveOperation

public void saveOperation(PendingOperation po,
                          java.io.Serializable object)
                   throws java.lang.Exception
Store a PendingOperation in the table, or die.

Parameters:
po -
sis -
Throws:
java.lang.Exception