com.sun.enterprise.connectors.work
Class WorkCoordinator

java.lang.Object
  extended by com.sun.enterprise.connectors.work.WorkCoordinator

public final class WorkCoordinator
extends java.lang.Object

WorkCoordinator : Coordinates one work's execution. Handles all exception conditions and does JTS coordination.

Author:
Binod P.G

Constructor Summary
WorkCoordinator(Work work, long timeout, ExecutionContext ec, com.sun.corba.ee.spi.orbutil.threadpool.WorkQueue queue, WorkListener listener, WorkManagementProbeProvider probeProvider, ConnectorRuntime runtime, java.lang.String raName, WorkContextHandler handler)
          Constructs a coordinator
 
Method Summary
 WorkException getException()
          Retrieves the exception created during the work's execution.
static ExecutionContext getExecutionContext(ExecutionContext ec, Work work)
           
 java.lang.String getRAName()
           
 int getState()
          Retrieves the state of the work coordinator object.
 boolean isTimedOut()
           
 void lock()
          Lock the thread upto the end of execution or start of work execution.
 void postInvoke()
          Post-invoke operation.
 void preInvoke()
          Pre-invoke operation.
 boolean proceed()
          Checks the work is good to proceed with further processing.
 void setException(java.lang.Throwable e)
          Accepts an exception object and converts to a WorkException object.
 void setState(int state)
          Sets the state of the work coordinator object
 void setupContext(OneWork oneWork)
           
 void submitWork(int waitModeValue)
          Submits the work to the queue and generates a work accepted event.
 java.lang.String toString()
          Returns the string representation of WorkCoordinator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WorkCoordinator

public WorkCoordinator(Work work,
                       long timeout,
                       ExecutionContext ec,
                       com.sun.corba.ee.spi.orbutil.threadpool.WorkQueue queue,
                       WorkListener listener,
                       WorkManagementProbeProvider probeProvider,
                       ConnectorRuntime runtime,
                       java.lang.String raName,
                       WorkContextHandler 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 java.lang.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 WorkException
Throws:
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 WorkException getException()
Retrieves the exception created during the work's execution.

Returns:
a WorkException object.

setException

public void setException(java.lang.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 java.lang.String toString()
Returns the string representation of WorkCoordinator.

Overrides:
toString in class java.lang.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 ExecutionContext getExecutionContext(ExecutionContext ec,
                                                   Work work)


Copyright © 2012 GlassFish Community. All Rights Reserved.