use of com.arjuna.mwlabs.wsas.activity.ActivityImple in project narayana by jbosstm.
the class UserActivityImple method 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.
*
* @exception SystemException Thrown if any error occurs.
*
* @return the token representing the current context, if any, or null
* otherwise.
*/
public ActivityHierarchy suspend() throws SystemException {
ActivityImple currentActivity = current();
if (currentActivity == null) {
return null;
}
String serviceType = currentActivity.serviceType();
HLS hls = HLSManager.getHighLevelService(serviceType);
if (hls != null) {
try {
hls.suspended();
} catch (SystemException ex) {
wsasLogger.i18NLogger.warn_UserActivityImple_4(ex);
}
}
currentActivity = purge();
if (currentActivity != null) {
return new ActivityHierarchyImple(currentActivity);
} else {
return null;
}
}
use of com.arjuna.mwlabs.wsas.activity.ActivityImple in project narayana by jbosstm.
the class UserActivityImple method start.
/**
* Start a new activity. If there is already an activity associated
* with the thread then it will be nested.
*
* @param serviceType specifies the type of coordinator which will be
* instantiated to manage the activity.
* @param timeout The timeout associated with the activity. If the
* activity has not been terminated by the time this period elapses, then
* it will automatically be terminated.
* @exception WrongStateException Thrown if the currently associated
* activity is in a state that does not allow a new activity to be
* enlisted as a child.
* @exception InvalidTimeoutException Thrown if the specified timeout is
* invalid within the current working environment.
* @exception SystemException Thrown in any other situation.
*/
public void start(String serviceType, int timeout) throws WrongStateException, InvalidTimeoutException, SystemException {
if (timeout < 0)
throw new InvalidTimeoutException();
else {
if (timeout == 0)
timeout = getTimeout();
}
ActivityImple currentActivity = new ActivityImple(current(), serviceType);
currentActivity.start(timeout);
push(currentActivity);
HLS hls = HLSManager.getHighLevelService(serviceType);
try {
if (hls != null) {
hls.begun();
}
} catch (SystemException ex) {
try {
setCompletionStatus(FailureOnly.instance());
} catch (Exception e) {
wsasLogger.i18NLogger.warn_UserActivityImple_1(e);
}
throw ex;
}
}
use of com.arjuna.mwlabs.wsas.activity.ActivityImple in project narayana by jbosstm.
the class UserActivityImple method current.
public final ActivityImple current() {
Stack hier = (Stack) _threadAxData.get();
ActivityImple currentActivity = null;
if (hier != null) {
try {
currentActivity = (ActivityImple) hier.peek();
} catch (EmptyStackException ex) {
}
}
return currentActivity;
}
use of com.arjuna.mwlabs.wsas.activity.ActivityImple in project narayana by jbosstm.
the class UserActivityImple method 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.
*
* @param tx The activity to associate with this thread. This
* may be null in which case the current thread becomes associated with
* no activity.
*
* @exception InvalidActivityException Thrown if the activity handle
* is invalid in this context.
* @exception SystemException Thrown if any other error occurs.
*/
public void resume(ActivityHierarchy tx) throws InvalidActivityException, SystemException {
if (tx == null) {
purge();
} else {
if (tx instanceof ActivityHierarchyImple) {
try {
for (int i = 0; i < tx.size(); i++) {
ActivityHandleImple handle = (ActivityHandleImple) tx.activity(i);
push(handle.getActivity());
}
} catch (Exception ex) {
ex.printStackTrace();
purge();
}
} else
throw new InvalidActivityException(wsasLogger.i18NLogger.get_UserActivityImple_51());
}
ActivityImple currentActivity = current();
String serviceType = currentActivity.serviceType();
HLS hls = HLSManager.getHighLevelService(serviceType);
if (hls != null) {
try {
hls.resumed();
} catch (SystemException ex) {
wsasLogger.i18NLogger.warn_UserActivityImple_5(ex);
}
}
}
Aggregations