Search in sources :

Example 16 with SystemException

use of com.arjuna.mw.wsas.exceptions.SystemException 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 17 with SystemException

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

Example 18 with SystemException

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

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

Example 20 with SystemException

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

the class UserCoordinatorFactory method userCoordinator.

/**
 * Obtain a reference to a coordinator that implements the specified
 * protocol.
 *
 * @param protocol The XML definition of the type of
 * coordination protocol required.
 *
 * @exception com.arjuna.mw.wscf.exceptions.ProtocolNotRegisteredException Thrown if the requested
 * protocol is not available.
 *
 * @return the CoordinatorManager implementation to use.
 */
public static UserCoordinator userCoordinator(String protocol) throws ProtocolNotRegisteredException, SystemException {
    try {
        TwoPhaseHLS coordHLS;
        synchronized (_implementations) {
            coordHLS = (TwoPhaseHLS) _implementations.get(protocol);
            if (coordHLS == null) {
                coordHLS = (TwoPhaseHLS) _protocolManager.getProtocolImplementation(protocol);
                _implementations.put(protocol, coordHLS);
            }
            return coordHLS.userCoordinator();
        }
    } catch (ProtocolNotRegisteredException ex) {
        throw ex;
    } catch (Exception ex) {
        throw new SystemException(ex.toString());
    }
}
Also used : SystemException(com.arjuna.mw.wsas.exceptions.SystemException) ProtocolNotRegisteredException(com.arjuna.mw.wscf.exceptions.ProtocolNotRegisteredException) TwoPhaseHLS(com.arjuna.mw.wscf.model.twophase.hls.TwoPhaseHLS) SystemException(com.arjuna.mw.wsas.exceptions.SystemException) ProtocolNotRegisteredException(com.arjuna.mw.wscf.exceptions.ProtocolNotRegisteredException)

Aggregations

SystemException (com.arjuna.mw.wsas.exceptions.SystemException)32 NoActivityException (com.arjuna.mw.wsas.exceptions.NoActivityException)16 WrongStateException (com.arjuna.mw.wsas.exceptions.WrongStateException)16 ProtocolViolationException (com.arjuna.mw.wsas.exceptions.ProtocolViolationException)15 SubordinateATCoordinator (com.arjuna.mwlabs.wscf.model.twophase.arjunacore.subordinate.SubordinateATCoordinator)7 ActivityHierarchy (com.arjuna.mw.wsas.activity.ActivityHierarchy)6 HLS (com.arjuna.mw.wsas.activity.HLS)6 ProtocolNotRegisteredException (com.arjuna.mw.wscf.exceptions.ProtocolNotRegisteredException)6 SubordinateBACoordinator (com.arjuna.mwlabs.wscf.model.sagas.arjunacore.subordinate.SubordinateBACoordinator)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 ActivityImple (com.arjuna.mwlabs.wsas.activity.ActivityImple)5 InvalidCreateParametersException (com.arjuna.wsc.InvalidCreateParametersException)5 InvalidProtocolException (com.arjuna.wsc.InvalidProtocolException)5 SOAPContext (com.arjuna.mw.wsas.context.soap.SOAPContext)4 ActiveChildException (com.arjuna.mw.wsas.exceptions.ActiveChildException)4 ServiceRegistry (com.arjuna.webservices11.ServiceRegistry)4 EmptyStackException (java.util.EmptyStackException)4 Outcome (com.arjuna.mw.wsas.activity.Outcome)3