Interface UserActivity


public interface UserActivity
The user portion of the activity API. An implementation of this interface presents each thread with the capability to create and manage activities. It is very similar to the OTS Current and JTA UserTransaction.
Since:
1.0.
Version:
$Id: UserActivity.java,v 1.2 2005/05/19 12:13:15 nmcl Exp $
Author:
Mark Little (mark.little@arjuna.com)
  • Method Details

    • start

      void start(String serviceType) throws WrongStateException, SystemException
      Start a new activity with a given coordination type. If there is already an activity associated with the thread then it will be nested. An implementation specific timeout will be associated with the activity (which may be no timeout).
      Parameters:
      serviceType - specifies the type of coordinator which will be instantiated to manage the activity.
      Throws:
      WrongStateException - Thrown if the any currently associated activity is in a state that does not allow a new activity to be enlisted.
      SystemException - Thrown in any other situation.
    • start

      void start(String serviceType, int timeout) throws WrongStateException, InvalidTimeoutException, SystemException
      Start a new activity with a given coordination type. If there is already an activity associated with the thread then it will be nested. If the activity is still active when the specified timeout elapses, it will be terminated.
      Parameters:
      serviceType - specifies the type of coordinator which will be instantiated to manage the activity.
      timeout - The timeout associated with the activity (in seconds). If the activity has not been terminated by the time this period elapses, then it will automatically be terminated.
      Throws:
      WrongStateException - Thrown if the currently associated activity is in a state that does not allow a new activity to be enlisted as a child.
      InvalidTimeoutException - Thrown if the specified timeout is invalid within the current working environment.
      SystemException - Thrown in any other situation.
    • end

      Complete the activity with the current completion status.
      Returns:
      the result of completing the activity. Null is valid and must be interpreted within the context of any HLS that may exist.
      Throws:
      InvalidActivityException - Thrown if the current activity is invalid in the execution environment.
      ActiveChildException - Thrown if the current activity is a parent activity with active children.
      WrongStateException - Thrown if the current activity is not in a state that allows it to be completed in the status requested.
      ProtocolViolationException - Thrown if the a violation of the activity service or HLS protocol occurs.
      NoActivityException - Thrown if there is no activity associated with the invoking thread or none with the given type of coordinator.
      NoPermissionException - Thrown if the invoking thread does not have permission to terminate the transaction.
      SystemException - Thrown if some other error occurred.
      See Also:
    • end

      Complete the activity with the completion status provided.
      Parameters:
      cs - The CompletionStatus to use.
      Returns:
      the result of completing the activity. Null is valid and must be interpreted within the context of any HLS that may exist.
      Throws:
      InvalidActivityException - Thrown if the current activity is invalid in the execution environment.
      ActiveChildException - Thrown if the current activity is a
      WrongStateException - Thrown if the current activity is not in a state that allows it to be completed, or is incompatible with the completion status provided.
      ProtocolViolationException - Thrown if the a violation of the activity service or HLS protocol occurs.
      NoActivityException - Thrown if there is no activity associated with the invoking thread or none with the given type of coordinator.
      NoPermissionException - Thrown if the invoking thread does not have permission to terminate the transaction.
      SystemException - Thrown if some other error occurred.
      See Also:
    • setCompletionStatus

      void setCompletionStatus(CompletionStatus endStatus) throws NoActivityException, WrongStateException, SystemException
      Set the termination status for the current activity, if any.
      Parameters:
      endStatus - The state in which the activity should attempt to terminate. This may be one of the default values provided by WSAS or may be extended in an implementation specific manner by an HLS.
      Throws:
      NoActivityException - Thrown if there is no activity associated with the invoking thread.
      WrongStateException - Thrown if the completion status is incompatible with the current state of the activity.
      SystemException - Thrown if any other error occurs.
    • getCompletionStatus

      Get the completion status currently associated with the activity.
      Returns:
      the termination status for the current activity, if any.
      Throws:
      NoActivityException - Thrown if there is no activity associated with the current thread.
      SystemException - Thrown if any other error occurs.
    • getTimeout

      int getTimeout() throws SystemException
      Get the timeout value currently associated with activities.
      Returns:
      the timeout value in seconds, or 0 if no application specified timeout has been provided.
      Throws:
      SystemException - Thrown if any error occurs.
    • setTimeout

      void setTimeout(int timeout) throws InvalidTimeoutException, SystemException
      Set the timeout to be associated with all subsequently created activities. A default value of 0 is automatically associated with each thread and this means that no application specified timeout is set for activities.
      Parameters:
      timeout - The timeout (in seconds) to associate with all subsequently created activities. This value must be 0 or greater.
      Throws:
      InvalidTimeoutException - Thrown if the timeout value provided is negative, too large, or if timeouts are simply not supported by the activity implementation.
      SystemException - Thrown if any other error occurs.
    • status

      Status status() throws SystemException
      Returns:
      the status of the current activity. If there is no activity associated with the thread then NoActivity will be returned.
      Throws:
      SystemException - Thrown if any error occurs.
      See Also:
    • activityName

      What is the name of the current activity? Use only for debugging purposes!
      Returns:
      the name of the activity.
      Throws:
      NoActivityException - Thrown if there is no activity associated with the invoking thread.
      SystemException - Thrown if any other error occurs.
    • activityId

      Returns:
      the unique activity id.
      Throws:
      NoActivityException - Thrown if there is no activity associated with the invoking thread.
      SystemException - Thrown if any other error occurs.
    • suspend

      Suspend the current activity from this thread and return the token representing the context, if any, or null otherwise. Once called, the thread will have no activities associated with it.
      Returns:
      the token representing the current context, if any, or null otherwise.
      Throws:
      SystemException - Thrown if any error occurs.
    • resume

      Given a token representing a context, associate it with the current thread of control. This will implicitly disassociate the thread from any activities that it may already be associated with. If the parameter is null then the thread is associated with no activity.
      Parameters:
      tx - The activity to associate with this thread. This may be null in which case the current thread becomes associated with no activity.
      Throws:
      InvalidActivityException - Thrown if the activity handle is invalid in this context.
      SystemException - Thrown if any other error occurs.
    • currentActivity

      ActivityHierarchy currentActivity() throws SystemException
      Returns:
      the token representing the current activity context hierarchy, or null if there is none associated with the invoking thread.
      Throws:
      SystemException - Thrown if any error occurs.
    • serviceType

      Returns:
      the service type supplied when the current activity was started.
      Throws:
      NoActivityException - Thrown if there is no activity associated with the invoking thread.
      SystemException - Thrown if any error occurs.