Search in sources :

Example 1 with ActivityImple

use of com.arjuna.mwlabs.wsas.activity.ActivityImple in project narayana by jbosstm.

the class UserActivityImple method end.

/**
 * Complete the activity with the completion status provided.
 *
 * @param cs The CompletionStatus to use.
 *
 * @exception InvalidActivityException Thrown if the current activity is
 * invalid in the execution environment.
 * @exception ActiveChildException Thrown if the current activity is a
 * @exception 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.
 * @exception ProtocolViolationException Thrown if the a violation of the
 * activity service or HLS protocol occurs.
 * @exception NoActivityException Thrown if there is no activity
 * associated with the invoking thread or none with the given type of coordinator.
 * @exception NoPermissionException Thrown if the invoking thread does
 * not have permission to terminate the transaction.
 * @exception SystemException Thrown if some other error occurred.
 *
 * @return the result of completing the activity. Null is valid and must
 * be interpreted within the context of any HLS that may exist.
 *
 * @see com.arjuna.mw.wsas.Outcome
 */
public Outcome end(CompletionStatus cs) throws InvalidActivityException, WrongStateException, ProtocolViolationException, SystemException, NoActivityException, NoPermissionException, ActiveChildException {
    ActivityImple currentActivity = current();
    if (currentActivity == null) {
        throw new NoActivityException();
    }
    /*
	if (currentActivity.parent() != null)
	    throw new ActiveChildException();
	*/
    Outcome res = null;
    String serviceType = currentActivity.serviceType();
    try {
        res = currentActivity.end(cs);
    } catch (Exception ex) {
        wsasLogger.i18NLogger.warn_UserActivityImple_2(ex);
    }
    HLS hls = HLSManager.getHighLevelService(serviceType);
    if (hls != null) {
        try {
            hls.completed();
        } catch (SystemException ex) {
            wsasLogger.i18NLogger.warn_UserActivityImple_3(ex);
        }
    }
    pop();
    return res;
}
Also used : SystemException(com.arjuna.mw.wsas.exceptions.SystemException) ActivityImple(com.arjuna.mwlabs.wsas.activity.ActivityImple) Outcome(com.arjuna.mw.wsas.activity.Outcome) NoActivityException(com.arjuna.mw.wsas.exceptions.NoActivityException) EmptyStackException(java.util.EmptyStackException) SystemException(com.arjuna.mw.wsas.exceptions.SystemException) InvalidTimeoutException(com.arjuna.mw.wsas.exceptions.InvalidTimeoutException) ActiveChildException(com.arjuna.mw.wsas.exceptions.ActiveChildException) NoPermissionException(com.arjuna.mw.wsas.exceptions.NoPermissionException) NoActivityException(com.arjuna.mw.wsas.exceptions.NoActivityException) WrongStateException(com.arjuna.mw.wsas.exceptions.WrongStateException) InvalidActivityException(com.arjuna.mw.wsas.exceptions.InvalidActivityException) ProtocolViolationException(com.arjuna.mw.wsas.exceptions.ProtocolViolationException) HLS(com.arjuna.mw.wsas.activity.HLS)

Example 2 with ActivityImple

use of com.arjuna.mwlabs.wsas.activity.ActivityImple in project narayana by jbosstm.

the class UserActivityImple method setCompletionStatus.

/**
 * Set the termination status for the current activity, if any.
 *
 * @param 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.
 *
 * @exception NoActivityException Thrown if there is no activity
 * associated with the invoking thread.
 * @exception WrongStateException Thrown if the completion status is
 * incompatible with the current state of the activity.
 * @exception SystemException Thrown if any other error occurs.
 */
public void setCompletionStatus(CompletionStatus endStatus) throws NoActivityException, WrongStateException, SystemException {
    ActivityImple curr = current();
    if (curr == null)
        throw new NoActivityException();
    curr.setCompletionStatus(endStatus);
}
Also used : ActivityImple(com.arjuna.mwlabs.wsas.activity.ActivityImple) NoActivityException(com.arjuna.mw.wsas.exceptions.NoActivityException)

Example 3 with ActivityImple

use of com.arjuna.mwlabs.wsas.activity.ActivityImple in project narayana by jbosstm.

the class UserActivityImple method purge.

private final ActivityImple purge() {
    Stack hier = (Stack) _threadAxData.get();
    ActivityImple currentActivity = null;
    if (hier != null) {
        _threadAxData.set(null);
        try {
            currentActivity = (ActivityImple) hier.peek();
        } catch (EmptyStackException ex) {
        }
    }
    return currentActivity;
}
Also used : EmptyStackException(java.util.EmptyStackException) ActivityImple(com.arjuna.mwlabs.wsas.activity.ActivityImple) Stack(java.util.Stack)

Example 4 with ActivityImple

use of com.arjuna.mwlabs.wsas.activity.ActivityImple in project narayana by jbosstm.

the class UserActivityImple method pop.

private final ActivityImple pop() {
    Stack hier = (Stack) _threadAxData.get();
    ActivityImple currentActivity = null;
    if (hier != null) {
        try {
            currentActivity = (ActivityImple) hier.pop();
            if (hier.size() == 0)
                _threadAxData.set(null);
        } catch (EmptyStackException ex) {
        }
    }
    return currentActivity;
}
Also used : EmptyStackException(java.util.EmptyStackException) ActivityImple(com.arjuna.mwlabs.wsas.activity.ActivityImple) Stack(java.util.Stack)

Example 5 with ActivityImple

use of com.arjuna.mwlabs.wsas.activity.ActivityImple in project narayana by jbosstm.

the class UserActivityImple method end.

/**
 * Complete the activity with the completion status provided.
 *
 * @exception InvalidActivityException Thrown if the current activity is
 * invalid in the execution environment.
 * @exception ActiveChildException Thrown if the current activity is a
 * @exception 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.
 * @exception ProtocolViolationException Thrown if the a violation of the
 * activity service or HLS protocol occurs.
 * @exception NoActivityException Thrown if there is no activity
 * associated with the invoking thread or none with the given type of coordinator.
 * @exception NoPermissionException Thrown if the invoking thread does
 * not have permission to terminate the transaction.
 * @exception SystemException Thrown if some other error occurred.
 *
 * @return the result of completing the activity. Null is valid and must
 * be interpreted within the context of any HLS that may exist.
 *
 * @see com.arjuna.mw.wsas.activity.Outcome
 * @message com.arjuna.mwlabs.wsas.UserActivityImple_2 [com.arjuna.mwlabs.wsas.UserActivityImple_2] - currentActivity.end threw:
 * @message com.arjuna.mwlabs.wsas.UserActivityImple_3 [com.arjuna.mwlabs.wsas.UserActivityImple_3] - Activity.completed caught:
 */
public Outcome end() throws InvalidActivityException, WrongStateException, ProtocolViolationException, SystemException, NoActivityException, SystemException, NoPermissionException, ActiveChildException {
    ActivityImple currentActivity = current();
    if (currentActivity == null) {
        throw new NoActivityException();
    }
    Outcome res = null;
    String serviceType = currentActivity.serviceType();
    try {
        res = currentActivity.end();
    } catch (Exception ex) {
        wsasLogger.i18NLogger.warn_UserActivityImple_1(ex);
    }
    HLS hls = HLSManager.getHighLevelService(serviceType);
    if (hls != null) {
        try {
            hls.completed();
        } catch (SystemException ex) {
            wsasLogger.i18NLogger.warn_UserActivityImple_3(ex);
        }
    }
    pop();
    return res;
}
Also used : SystemException(com.arjuna.mw.wsas.exceptions.SystemException) ActivityImple(com.arjuna.mwlabs.wsas.activity.ActivityImple) Outcome(com.arjuna.mw.wsas.activity.Outcome) NoActivityException(com.arjuna.mw.wsas.exceptions.NoActivityException) EmptyStackException(java.util.EmptyStackException) SystemException(com.arjuna.mw.wsas.exceptions.SystemException) InvalidTimeoutException(com.arjuna.mw.wsas.exceptions.InvalidTimeoutException) ActiveChildException(com.arjuna.mw.wsas.exceptions.ActiveChildException) NoPermissionException(com.arjuna.mw.wsas.exceptions.NoPermissionException) NoActivityException(com.arjuna.mw.wsas.exceptions.NoActivityException) WrongStateException(com.arjuna.mw.wsas.exceptions.WrongStateException) InvalidActivityException(com.arjuna.mw.wsas.exceptions.InvalidActivityException) ProtocolViolationException(com.arjuna.mw.wsas.exceptions.ProtocolViolationException) HLS(com.arjuna.mw.wsas.activity.HLS)

Aggregations

ActivityImple (com.arjuna.mwlabs.wsas.activity.ActivityImple)9 EmptyStackException (java.util.EmptyStackException)7 HLS (com.arjuna.mw.wsas.activity.HLS)5 NoActivityException (com.arjuna.mw.wsas.exceptions.NoActivityException)5 SystemException (com.arjuna.mw.wsas.exceptions.SystemException)5 ActiveChildException (com.arjuna.mw.wsas.exceptions.ActiveChildException)4 InvalidActivityException (com.arjuna.mw.wsas.exceptions.InvalidActivityException)4 InvalidTimeoutException (com.arjuna.mw.wsas.exceptions.InvalidTimeoutException)4 NoPermissionException (com.arjuna.mw.wsas.exceptions.NoPermissionException)4 ProtocolViolationException (com.arjuna.mw.wsas.exceptions.ProtocolViolationException)4 WrongStateException (com.arjuna.mw.wsas.exceptions.WrongStateException)4 Stack (java.util.Stack)3 Outcome (com.arjuna.mw.wsas.activity.Outcome)2 ActivityHierarchyImple (com.arjuna.mwlabs.wsas.activity.ActivityHierarchyImple)2 ActivityHandleImple (com.arjuna.mwlabs.wsas.activity.ActivityHandleImple)1