org.objectweb.jass.as
Class UserActivityImpl

java.lang.Object
  extended byorg.objectweb.jass.as.UserActivityImpl
All Implemented Interfaces:
java.io.Serializable, javax.activity.UserActivity
Direct Known Subclasses:
ActivityManagerImpl

public class UserActivityImpl
extends java.lang.Object
implements javax.activity.UserActivity, java.io.Serializable

Implements the access interface to the AS (UserActivity) available to HLSs.

Author:
fran Date: Feb 12, 2004 org.objectweb.jass.asUserActivityImpl.java
See Also:
Serialized Form

Field Summary
static java.lang.String CHILDLIFETIME_SS_NAME
           
static int DEFAULT_TIMEOUT
           
static java.lang.String SYNCHRONIZATION_SS_NAME
           
 
Constructor Summary
UserActivityImpl()
          Default Constructor.
 
Method Summary
 void begin(int timeout)
          Create a new Activity and associate it with the current thread.
 javax.activity.Outcome broadcast(java.lang.String signalSetName)
          Causes the SignalSet specified by signalSetName to start producing signals for all registered Actions.
 javax.activity.Outcome complete()
          Causes the active Activity context to be completed with its current CompletionStatus.
 javax.activity.Outcome completeWithStatus(int completionStatus)
          Causes the active Activity context to complete with the specified CompletionStatus.
 void forget(javax.activity.GlobalId globalId)
          NOT YET IMPLEMENTED
 int getCompletionStatus()
          Returns the current value of the CompletionStatus of the active Activity.
 javax.activity.ActivityCoordinator getCoordinator()
          Returns the ActivityCoordinator of the active Activity, or null if there is no Activity associated with the calling thread.
 javax.activity.GlobalId getGlobalId()
          Returns the GlobalId of the active Activity.
static int getInstances()
           
 java.lang.String getName()
          Returns a printable string describing the active Activity.
 int getNumberOfActivities()
          Return the number of activities in the activities HashMap.
 javax.activity.ActivityCoordinator getParentCoordinator()
          Returns the ActivityCoordinator of the parent of the active Activity, or null if the active Activity is a top-level Activity.
 javax.activity.propertygroup.PropertyGroup getPropertyGroup(java.lang.String name)
          NOT YET IMPLEMENTED
 javax.activity.coordination.ServiceManager getService()
          Returns the registered ServiceManager for this UserActivity instance.
 int getStatus()
          Returns the current value of the Status of the active Activity.
 int getTimeout()
          Returns the default timeout value.
 javax.activity.GlobalId[] recover()
          NOT YET IMPLEMENTED
 javax.activity.ActivityCoordinator recreate(javax.activity.GlobalId activity, javax.activity.GlobalId parent, boolean resume)
          NOT YET IMPLEMENTED
 void registerService(javax.activity.coordination.ServiceManager service)
          Registers a ServiceManager for the type of high-level service (HLS) whose activities are to be demarcated through the target UserActivity instance.
static void setActivityIdGenerator(ActivityIdGenerator generator)
          Sets the Activity Id Generator for all Activity Service instances.
 void setCompletionStatus(int completionStatus)
          OK Sets the CompletionStatus of the active Activity.
 void setTimeout(int timeout)
          Sets the default timeout, in seconds, after which an Activity may be automatically completed by the Activity service.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TIMEOUT

public static int DEFAULT_TIMEOUT

SYNCHRONIZATION_SS_NAME

public static java.lang.String SYNCHRONIZATION_SS_NAME

CHILDLIFETIME_SS_NAME

public static java.lang.String CHILDLIFETIME_SS_NAME
Constructor Detail

UserActivityImpl

public UserActivityImpl()
Default Constructor. It takes count of the number of service instances created.

Method Detail

begin

public void begin(int timeout)
           throws javax.activity.InvalidStateException,
                  javax.activity.ServiceNotRegisteredException,
                  javax.activity.TimeoutRangeException,
                  javax.activity.SystemException
Create a new Activity and associate it with the current thread.

Specified by:
begin in interface javax.activity.UserActivity
Parameters:
timeout - - the period (in seconds) within which the Activity must be completed. If it is not completed within this period then it is subject to being completed by the Activity service with the CompletionStatusFail status.
Throws:
javax.activity.InvalidStateException - - Thrown if the parent Activity has been marked as CompletionStatusFailOnly.
javax.activity.ServiceNotRegisteredException - - Thrown if no ServiceManager has been registered.
javax.activity.TimeoutRangeException - - Thrown if timeout is less than -1 or if it is outside an administratively configured range in the deployed system.
javax.activity.SystemException

completeWithStatus

public javax.activity.Outcome completeWithStatus(int completionStatus)
                                          throws javax.activity.NoActivityException,
                                                 javax.activity.ActivityPendingException,
                                                 javax.activity.ContextPendingException,
                                                 javax.activity.ServiceNotRegisteredException,
                                                 javax.activity.NotOriginatorException,
                                                 javax.activity.InvalidStateException,
                                                 javax.activity.ActivityNotProcessedException,
                                                 javax.activity.SystemException
Causes the active Activity context to complete with the specified CompletionStatus. If a CompletionSignalSet is used by the registered ServiceManager, then it will be driven by the Activity service to obtain completion signals to distribute to any registered Actions. If the Activity is nested within a parent, then the parent Activity becomes associated with the thread on completion of this operation. If there are any child active or suspended Activities or transactions and the CompletionStatus is CompletionStatusFail or CompletionStatusFailOnly then those child Activites will have their CompletionStatuses set to CompletionStatusFailOnly and any child transaction will be called to setRollbackOnly.

Specified by:
completeWithStatus in interface javax.activity.UserActivity
Parameters:
completionStatus -
Returns:
Throws:
javax.activity.NoActivityException
javax.activity.ActivityPendingException
javax.activity.ContextPendingException
javax.activity.ServiceNotRegisteredException
javax.activity.NotOriginatorException
javax.activity.InvalidStateException
javax.activity.ActivityNotProcessedException
javax.activity.SystemException

complete

public javax.activity.Outcome complete()
                                throws javax.activity.NoActivityException,
                                       javax.activity.ActivityPendingException,
                                       javax.activity.ContextPendingException,
                                       javax.activity.ServiceNotRegisteredException,
                                       javax.activity.NotOriginatorException,
                                       javax.activity.ActivityNotProcessedException,
                                       javax.activity.SystemException
Causes the active Activity context to be completed with its current CompletionStatus. If a CompletionSignalSet is used by the registered ServiceManager, then it will be driven by the Activity service to obtain completion signals to distribute to any registered Actions. If the Activity is nested within a parent, then the parent Activity becomes associated with the thread on completion of this operation. If there are any child active or suspended Activities or transactions and the CompletionStatus is CompletionStatusFail or CompletionStatusFailOnly then those child Activites will have their CompletionStatus set to CompletionStatusFailOnly and any child transaction will be called to setRollbackOnly.

Specified by:
complete in interface javax.activity.UserActivity
Returns:
The Outcome returned is both set by and given meaning by the SignalSet used for completion. In the absence of a CompletionSignalSet a null Outcome object reference is returned.
Throws:
javax.activity.NoActivityException
javax.activity.ActivityPendingException
javax.activity.ContextPendingException
javax.activity.ServiceNotRegisteredException
javax.activity.NotOriginatorException
javax.activity.ActivityNotProcessedException
javax.activity.SystemException

setCompletionStatus

public void setCompletionStatus(int completionStatus)
                         throws javax.activity.NoActivityException,
                                javax.activity.InvalidStateException,
                                javax.activity.ServiceNotRegisteredException,
                                javax.activity.SystemException
OK Sets the CompletionStatus of the active Activity. This method may be called multiple times before the Activity is completed, and the CompletionStatus may be changed between CompletionStatusSuccess and CompletionStatusFail to indicate a point in time value. Once the CompletionStatus has been set to CompletionStatusFailOnly, it may not be changed again.

Specified by:
setCompletionStatus in interface javax.activity.UserActivity
Parameters:
completionStatus - - the CompletionStatus value to set.
Throws:
javax.activity.NoActivityException - - Thrown if there is no Activity associated with the calling thread of execution.
javax.activity.InvalidStateException - - Thrown if an attempt is made to update a CompletionStatus of CompletionStatusFailOnly or if a null or invalid value is specified by completionStatus.
javax.activity.ServiceNotRegisteredException - - Thrown if no ServiceManager has been registered.
javax.activity.SystemException

getCompletionStatus

public int getCompletionStatus()
                        throws javax.activity.ServiceNotRegisteredException,
                               javax.activity.NoActivityException,
                               javax.activity.SystemException
Returns the current value of the CompletionStatus of the active Activity.

Specified by:
getCompletionStatus in interface javax.activity.UserActivity
Returns:
The CompletionStatus of the active Activity.
Throws:
javax.activity.ServiceNotRegisteredException - - Thrown if there is no Activity associated with the calling thread of execution.
javax.activity.NoActivityException - - Thrown if no ServiceManager has been registered.
javax.activity.SystemException - - Thrown if the Activity service encounters an unexpected error condition.

getStatus

public int getStatus()
              throws javax.activity.ServiceNotRegisteredException,
                     javax.activity.SystemException
Returns the current value of the Status of the active Activity.

Specified by:
getStatus in interface javax.activity.UserActivity
Returns:
The Status of the active Activity.
Throws:
javax.activity.ServiceNotRegisteredException - Thrown if no ServiceManager has been registered.
javax.activity.SystemException - Thrown if the Activity service encounters an unexpected error condition.

getName

public java.lang.String getName()
                         throws javax.activity.ServiceNotRegisteredException,
                                javax.activity.SystemException
Returns a printable string describing the active Activity.

Specified by:
getName in interface javax.activity.UserActivity
Returns:
a printable string describing the active Activity. If no Activity is associated with the calling thread then null is returned.
Throws:
javax.activity.ServiceNotRegisteredException - Thrown if no ServiceManager has been registered.
javax.activity.SystemException - - Thrown if the Activity service encounters an unexpected error condition.

setTimeout

public void setTimeout(int timeout)
                throws javax.activity.ServiceNotRegisteredException,
                       javax.activity.TimeoutRangeException,
                       javax.activity.SystemException
Sets the default timeout, in seconds, after which an Activity may be automatically completed by the Activity service.

Specified by:
setTimeout in interface javax.activity.UserActivity
Parameters:
timeout - - the default timeout period (in seconds) used by any future Activities begun with a timeout value of zero. This default is used for an Activity that is begun with a timeout parameter value of 0. A value of -1 indicates no timeout. A value of 0 for the default timeout indicates that a system-managed value or implementation-specific default should be used. The timeout is a useful mechanism for protecting against clients that fail to end an Activity in a timely fashion.
Throws:
javax.activity.ServiceNotRegisteredException - - Thrown if no ServiceManager has been registered.
javax.activity.TimeoutRangeException - - Thrown if timeout is less than -1 or if it is outside an administratively configured range in the deployed system.
javax.activity.SystemException - - Thrown if the Activity service encounters an unexpected error condition.

getTimeout

public int getTimeout()
               throws javax.activity.ServiceNotRegisteredException,
                      javax.activity.SystemException
Returns the default timeout value.

Specified by:
getTimeout in interface javax.activity.UserActivity
Returns:
The default timeout value, in seconds.
Throws:
javax.activity.ServiceNotRegisteredException - - Thrown if no ServiceManager has been registered.
javax.activity.SystemException

getGlobalId

public javax.activity.GlobalId getGlobalId()
                                    throws javax.activity.ServiceNotRegisteredException,
                                           javax.activity.SystemException
Returns the GlobalId of the active Activity.

Specified by:
getGlobalId in interface javax.activity.UserActivity
Returns:
The GlobalId of the active Activity, or null if there is no Activity associated with the thread.
Throws:
javax.activity.ServiceNotRegisteredException
javax.activity.SystemException

broadcast

public javax.activity.Outcome broadcast(java.lang.String signalSetName)
                                 throws javax.activity.NoActivityException,
                                        javax.activity.SignalSetUnknownException,
                                        javax.activity.ServiceNotRegisteredException,
                                        javax.activity.InvalidActivityException,
                                        javax.activity.ActivityNotProcessedException,
                                        javax.activity.SystemException
Causes the SignalSet specified by signalSetName to start producing signals for all registered Actions. This method is used to distribute Signals to Actions at times other than during completion. Pre-defined SignalSets, such as Synchronization, cannot be requested to produce signals via this method.

Specified by:
broadcast in interface javax.activity.UserActivity
Parameters:
signalSetName - - the name of the SignalSet that is to produce the signals.
Returns:
The Outcome returned is both set by and given meaning by the SignalSet. A null Outcome object reference may be returned if the SignalSet does not produce an Outcome.
Throws:
NoActivityException- - Thrown if there is no Activity associated with the calling thread of execution.
javax.activity.SignalSetUnknownException
javax.activity.ServiceNotRegisteredException - - Thrown if no ServiceManager has been registered.
javax.activity.InvalidActivityException - Thrown if an attempt is made to use the Synchronization or ChildLifetime SignalSets, or if the Activity is in the process of completion.
javax.activity.ActivityNotProcessedException
javax.activity.SystemException
javax.activity.NoActivityException

getCoordinator

public javax.activity.ActivityCoordinator getCoordinator()
                                                  throws javax.activity.ServiceNotRegisteredException,
                                                         javax.activity.NoImplementException,
                                                         javax.activity.SystemException
Returns the ActivityCoordinator of the active Activity, or null if there is no Activity associated with the calling thread.

Specified by:
getCoordinator in interface javax.activity.UserActivity
Returns:
ActivityCoordinator of the active Activity
Throws:
javax.activity.ServiceNotRegisteredException
javax.activity.NoImplementException
javax.activity.SystemException

getParentCoordinator

public javax.activity.ActivityCoordinator getParentCoordinator()
                                                        throws javax.activity.ServiceNotRegisteredException,
                                                               javax.activity.NoImplementException,
                                                               javax.activity.SystemException
Returns the ActivityCoordinator of the parent of the active Activity, or null if the active Activity is a top-level Activity. In some execution environments, such as a J2EE client, this method need not be implemented and calling it may result in a NoImplementationException.

Specified by:
getParentCoordinator in interface javax.activity.UserActivity
Returns:
The ActivityCoordinator of the active Activity. If there is no Activity associated with the calling thread then a null object reference is returned.
Throws:
javax.activity.ServiceNotRegisteredException - - Thrown if no ServiceManager has been registered.
javax.activity.NoImplementException - - Thrown if the Activity service does not provide an implementation of this method in the calling environment, for example if a J2EE client calls this method.
javax.activity.SystemException

getPropertyGroup

public javax.activity.propertygroup.PropertyGroup getPropertyGroup(java.lang.String name)
                                                            throws javax.activity.PropertyGroupUnknownException,
                                                                   javax.activity.ServiceNotRegisteredException,
                                                                   javax.activity.NoActivityException,
                                                                   javax.activity.SystemException
NOT YET IMPLEMENTED

Specified by:
getPropertyGroup in interface javax.activity.UserActivity
Throws:
javax.activity.PropertyGroupUnknownException
javax.activity.ServiceNotRegisteredException
javax.activity.NoActivityException
javax.activity.SystemException

registerService

public void registerService(javax.activity.coordination.ServiceManager service)
                     throws javax.activity.PropertyGroupUnknownException,
                            javax.activity.ServiceAlreadyRegisteredException,
                            javax.activity.SystemException
Registers a ServiceManager for the type of high-level service (HLS) whose activities are to be demarcated through the target UserActivity instance. The Activity service uses the properties of the registered ServiceManager to create and operate on Activities specific to that service. The UserActivity (or specialised ActivityManager) instance requires a ServiceManager to be registered with it before it may be used to begin new Activities.

Specified by:
registerService in interface javax.activity.UserActivity
Parameters:
service - - the ServiceManager for the HLS whose activities are to be demarcated through the target UserActivity instance.
Throws:
javax.activity.PropertyGroupUnknownException - - Thrown if the ServiceManager cannot obtain a PropertyGroupManager for one or more of the PropertyGroups it uses.
javax.activity.ServiceAlreadyRegisteredException - - Thrown if a ServiceManager has already been registered with the UserActivity instance.
javax.activity.SystemException

getService

public javax.activity.coordination.ServiceManager getService()
                                                      throws javax.activity.SystemException
Returns the registered ServiceManager for this UserActivity instance.

Specified by:
getService in interface javax.activity.UserActivity
Returns:
The ServiceManager for this UserActivity instance, or null if none has been registered.
Throws:
javax.activity.SystemException

recreate

public javax.activity.ActivityCoordinator recreate(javax.activity.GlobalId activity,
                                                   javax.activity.GlobalId parent,
                                                   boolean resume)
                                            throws javax.activity.ServiceNotRegisteredException,
                                                   javax.activity.ActivityCompletedException,
                                                   java.lang.IllegalArgumentException,
                                                   javax.activity.SystemException
NOT YET IMPLEMENTED

Specified by:
recreate in interface javax.activity.UserActivity
Throws:
javax.activity.ServiceNotRegisteredException
javax.activity.ActivityCompletedException
java.lang.IllegalArgumentException
javax.activity.SystemException

recover

public javax.activity.GlobalId[] recover()
                                  throws javax.activity.ServiceNotRegisteredException,
                                         javax.activity.SystemException
NOT YET IMPLEMENTED

Specified by:
recover in interface javax.activity.UserActivity
Throws:
javax.activity.ServiceNotRegisteredException
javax.activity.SystemException

forget

public void forget(javax.activity.GlobalId globalId)
            throws javax.activity.ServiceNotRegisteredException,
                   javax.activity.SystemException
NOT YET IMPLEMENTED

Specified by:
forget in interface javax.activity.UserActivity
Throws:
javax.activity.ServiceNotRegisteredException
javax.activity.SystemException

setActivityIdGenerator

public static void setActivityIdGenerator(ActivityIdGenerator generator)
Sets the Activity Id Generator for all Activity Service instances.

Parameters:
generator - - A reference to the unique ActivityIdGenerator

getNumberOfActivities

public int getNumberOfActivities()
Return the number of activities in the activities HashMap.

Returns:
Number of activities currently in the HashMap.

getInstances

public static int getInstances()