Search in sources :

Example 1 with HLS

use of com.arjuna.mw.wsas.activity.HLS 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 HLS

use of com.arjuna.mw.wsas.activity.HLS in project narayana by jbosstm.

the class HLSManager method removeHLS.

public static final void removeHLS(HLS service) throws InvalidHLSException, SystemException {
    if (service == null)
        throw new InvalidHLSException();
    else {
        String key = service.identity();
        HLS oldValue;
        synchronized (_hlsMap) {
            oldValue = _hlsMap.remove(key);
        }
        if (oldValue == null) {
            throw new InvalidHLSException(wsasLogger.i18NLogger.get_activity_HLSManager_1());
        }
    }
}
Also used : InvalidHLSException(com.arjuna.mw.wsas.exceptions.InvalidHLSException) HLS(com.arjuna.mw.wsas.activity.HLS)

Example 3 with HLS

use of com.arjuna.mw.wsas.activity.HLS 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)

Example 4 with HLS

use of com.arjuna.mw.wsas.activity.HLS 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;
    }
}
Also used : SystemException(com.arjuna.mw.wsas.exceptions.SystemException) ActivityImple(com.arjuna.mwlabs.wsas.activity.ActivityImple) ActivityHierarchyImple(com.arjuna.mwlabs.wsas.activity.ActivityHierarchyImple) HLS(com.arjuna.mw.wsas.activity.HLS)

Example 5 with HLS

use of com.arjuna.mw.wsas.activity.HLS 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;
    }
}
Also used : InvalidTimeoutException(com.arjuna.mw.wsas.exceptions.InvalidTimeoutException) SystemException(com.arjuna.mw.wsas.exceptions.SystemException) ActivityImple(com.arjuna.mwlabs.wsas.activity.ActivityImple) HLS(com.arjuna.mw.wsas.activity.HLS) 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)

Aggregations

HLS (com.arjuna.mw.wsas.activity.HLS)11 NoActivityException (com.arjuna.mw.wsas.exceptions.NoActivityException)6 SystemException (com.arjuna.mw.wsas.exceptions.SystemException)6 InvalidActivityException (com.arjuna.mw.wsas.exceptions.InvalidActivityException)5 InvalidTimeoutException (com.arjuna.mw.wsas.exceptions.InvalidTimeoutException)5 NoPermissionException (com.arjuna.mw.wsas.exceptions.NoPermissionException)5 ProtocolViolationException (com.arjuna.mw.wsas.exceptions.ProtocolViolationException)5 WrongStateException (com.arjuna.mw.wsas.exceptions.WrongStateException)5 ActivityImple (com.arjuna.mwlabs.wsas.activity.ActivityImple)5 ActiveChildException (com.arjuna.mw.wsas.exceptions.ActiveChildException)4 EmptyStackException (java.util.EmptyStackException)4 UserActivity (com.arjuna.mw.wsas.UserActivity)3 Outcome (com.arjuna.mw.wsas.activity.Outcome)3 ContextManager (com.arjuna.mw.wsas.context.ContextManager)3 Test (org.junit.Test)3 Context (com.arjuna.mw.wsas.context.Context)2 SOAPContext (com.arjuna.mw.wsas.context.soap.SOAPContext)2 ActivityHierarchyImple (com.arjuna.mwlabs.wsas.activity.ActivityHierarchyImple)2 DemoHLS (com.arjuna.wsas.tests.DemoHLS)2 DemoSOAPContextImple (com.arjuna.wsas.tests.DemoSOAPContextImple)2