Search in sources :

Example 1 with HLSException

use of com.arjuna.mw.wsas.exceptions.HLSException in project narayana by jbosstm.

the class ActivityImple method end.

/**
 * Complete the activity with the completion status provided.
 *
 * @param cs The CompletionStatus to use.
 *
 * @exception InvalidActivityException
 *                Thrown if the current activity is not known about by the
 *                activity system.
 * @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 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(com.arjuna.mw.wsas.completionstatus.CompletionStatus cs) throws InvalidActivityException, WrongStateException, ProtocolViolationException, NoPermissionException, SystemException {
    synchronized (this) {
        if (_status.equals(Active.instance())) {
            if (activeChildren()) {
                throw new InvalidActivityException(wsasLogger.i18NLogger.get_activity_ActivityImple_2() + " " + this);
            }
            Outcome result = null;
            try {
                setCompletionStatus(cs);
            } catch (Exception ex) {
            // ignore and complete with the status we have.
            }
            _status = Completing.instance();
            try {
                HLS hls = HLSManager.getHighLevelService(_serviceType);
                if (hls != null) {
                    result = hls.complete(getCompletionStatus());
                } else {
                    result = new OutcomeImple(Failure.instance());
                }
            } catch (SystemException ex) {
                /*
					 * Currently if an exception occurs and we get here, then we
					 * forget all of the other outcomes and just return the
					 * exception. Does this make sense? How will applications be
					 * able to tell which HLSes have processed the outcome and
					 * which have not?
					 */
                result = new OutcomeImple(new HLSException(ex), Failure.instance());
            }
            if (_parent != null) {
                _parent.removeChild(this);
                _parent = null;
            }
            _status = Completed.instance();
            _result = result;
            return _result;
        } else {
            if (_result != null)
                return _result;
            else {
                throw new WrongStateException(wsasLogger.i18NLogger.get_activity_ActivityImple_3() + " " + _status);
            }
        }
    }
}
Also used : InvalidActivityException(com.arjuna.mw.wsas.exceptions.InvalidActivityException) SystemException(com.arjuna.mw.wsas.exceptions.SystemException) Outcome(com.arjuna.mw.wsas.activity.Outcome) WrongStateException(com.arjuna.mw.wsas.exceptions.WrongStateException) HLSException(com.arjuna.mw.wsas.exceptions.HLSException) SystemException(com.arjuna.mw.wsas.exceptions.SystemException) HLSException(com.arjuna.mw.wsas.exceptions.HLSException) InvalidTimeoutException(com.arjuna.mw.wsas.exceptions.InvalidTimeoutException) 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

HLS (com.arjuna.mw.wsas.activity.HLS)1 Outcome (com.arjuna.mw.wsas.activity.Outcome)1 HLSException (com.arjuna.mw.wsas.exceptions.HLSException)1 InvalidActivityException (com.arjuna.mw.wsas.exceptions.InvalidActivityException)1 InvalidTimeoutException (com.arjuna.mw.wsas.exceptions.InvalidTimeoutException)1 NoActivityException (com.arjuna.mw.wsas.exceptions.NoActivityException)1 NoPermissionException (com.arjuna.mw.wsas.exceptions.NoPermissionException)1 ProtocolViolationException (com.arjuna.mw.wsas.exceptions.ProtocolViolationException)1 SystemException (com.arjuna.mw.wsas.exceptions.SystemException)1 WrongStateException (com.arjuna.mw.wsas.exceptions.WrongStateException)1