Class WorkCoordinator


  • public final class WorkCoordinator
    extends Object
    WorkCoordinator : Coordinates one work's execution. Handles all exception conditions and does JTS coordination.
    Author:
    Binod P.G
    • Constructor Detail

      • WorkCoordinator

        public WorkCoordinator​(jakarta.resource.spi.work.Work work,
                               long timeout,
                               jakarta.resource.spi.work.ExecutionContext ec,
                               com.sun.corba.ee.spi.threadpool.WorkQueue queue,
                               jakarta.resource.spi.work.WorkListener listener,
                               WorkManagementProbeProvider probeProvider,
                               ConnectorRuntime runtime,
                               String raName,
                               WorkContextHandlerImpl handler)
        Constructs a coordinator
        Parameters:
        work - A work object as submitted by the resource adapter
        timeout - timeout for the work instance
        ec - ExecutionContext object.
        queue - WorkQueue of the threadpool, to which the work will be submitted
        listener - WorkListener object from the resource adapter.
    • Method Detail

      • getRAName

        public String getRAName()
      • submitWork

        public void submitWork​(int waitModeValue)
        Submits the work to the queue and generates a work accepted event.
      • preInvoke

        public void preInvoke()
        Pre-invoke operation. This does the following
         1. Notifies the  WorkManager.startWork  method.
         2. Checks whether the wok has already been timed out.
         3. Recreates the transaction with JTS.
         
      • setupContext

        public void setupContext​(OneWork oneWork)
                          throws jakarta.resource.spi.work.WorkException
        Throws:
        jakarta.resource.spi.work.WorkException
      • postInvoke

        public void postInvoke()
        Post-invoke operation. This does the following after the work is executed.
         1. Releases the transaction with JTS.
         2. Generates work completed event.
         3. Clear the thread context.
         
      • proceed

        public boolean proceed()
        Checks the work is good to proceed with further processing.
        Returns:
        true if the work is good and false if it is bad.
      • isTimedOut

        public boolean isTimedOut()
      • getException

        public jakarta.resource.spi.work.WorkException getException()
        Retrieves the exception created during the work's execution.
        Returns:
        a WorkException object.
      • setException

        public void setException​(Throwable e)
        Accepts an exception object and converts to a WorkException object.
        Parameters:
        e - Throwable object.
      • lock

        public void lock()
        Lock the thread upto the end of execution or start of work execution.
      • toString

        public String toString()
        Returns the string representation of WorkCoordinator.
        Overrides:
        toString in class Object
        Returns:
        Unique identification concatenated by work object.
      • setState

        public void setState​(int state)
        Sets the state of the work coordinator object
        Parameters:
        state - CREATED or Either STARTED or COMPLETED or TIMEDOUT
      • getState

        public int getState()
        Retrieves the state of the work coordinator object.
        Returns:
        Integer represnting the state.
      • getExecutionContext

        public static jakarta.resource.spi.work.ExecutionContext getExecutionContext​(jakarta.resource.spi.work.ExecutionContext ec,
                                                                                     jakarta.resource.spi.work.Work work)
      • increaseSeed

        public static int increaseSeed()