Search in sources :

Example 6 with NoActivityException

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

the class NestedActivityTest method testNestedActivity.

@Test
public void testNestedActivity() throws Exception {
    UserActivity ua = UserActivityFactory.userActivity();
    try {
        ua.start("dummy");
        System.out.println("Started: " + ua.activityName());
        ua.start("dummy");
        String nested = ua.activityName();
        System.out.println("Started: " + nested);
        System.out.println("\nEnding: " + nested);
        ua.end();
        String parent = ua.activityName();
        System.out.println("\nCurrent: " + parent);
        System.out.println("\nEnding: " + parent);
        ua.end();
        try {
            if (ua.activityName() != null) {
                fail("activity name should be null but is " + ua.activityName());
            }
        } catch (NoActivityException ex) {
        // ok if we get here
        }
        System.out.println("\nEnded.");
    } catch (Exception ex) {
        WSASTestUtils.cleanup(ua);
        throw ex;
    }
}
Also used : UserActivity(com.arjuna.mw.wsas.UserActivity) NoActivityException(com.arjuna.mw.wsas.exceptions.NoActivityException) NoActivityException(com.arjuna.mw.wsas.exceptions.NoActivityException) Test(org.junit.Test)

Example 7 with NoActivityException

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

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

the class ContextManager method context.

/**
 * message com.arjuna.mw.wsas.context.ContextManager_3 [com.arjuna.mw.wsas.context.ContextManager_3] - getHighLevelServices threw:
 * message com.arjuna.mw.wsas.context.ContextManager_4 [com.arjuna.mw.wsas.context.ContextManager_4] - assembling context and received:
 */
public final Context context(String serviceType) {
    Context ctx = null;
    HLS service = null;
    try {
        // ensure we are in an activity associated with the correct service type
        String currentServiceType = UserActivityFactory.userActivity().serviceType();
        if (currentServiceType.equals(serviceType)) {
            service = _manager.getHighLevelService(serviceType);
        }
    } catch (NoActivityException nae) {
    // ignore
    } catch (Exception ex) {
        wsasLogger.i18NLogger.warn_context_ContextManager_1(ex);
    }
    if (service != null) {
        try {
            ctx = service.context();
        } catch (Exception ex) {
            wsasLogger.i18NLogger.warn_context_ContextManager_2(ex);
            ctx = null;
        }
    }
    return ctx;
}
Also used : NoActivityException(com.arjuna.mw.wsas.exceptions.NoActivityException) HLS(com.arjuna.mw.wsas.activity.HLS) NoActivityException(com.arjuna.mw.wsas.exceptions.NoActivityException)

Example 9 with NoActivityException

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

the class ContextFactoryImple method createBridgedTransaction.

/**
 * create a bridged to subordinate WS-BA 1.1 transaction, associate it with the registrar and create and return
 * a coordination context for it. n.b. this is a private, behind-the-scenes method for use by the JTA-BA
 * transaction bridge code.
 * @param expires the timeout for the bridged to BA transaction
 * @param isSecure true if the registration cooridnator URL should use a secure address, otherwise false.
 * @return a coordination context for the bridged to transaction
 */
public BridgeTxData createBridgedTransaction(final Long expires, final boolean isSecure) {
    // we need to create a subordinate transaction and expose it to the bridge layer so it can
    // be driven to completion
    SubordinateBACoordinator subTx = null;
    try {
        subTx = (SubordinateBACoordinator) createSubordinate();
    } catch (NoActivityException e) {
        // will not happen
        return null;
    } catch (InvalidProtocolException e) {
        // will not happen
        return null;
    } catch (SystemException e) {
        // may happen
        return null;
    }
    // ok now create the context
    final ServiceRegistry serviceRegistry = PrivilegedServiceRegistryFactory.getInstance().getServiceRegistry();
    final String registrationCoordinatorURI = serviceRegistry.getServiceURI(CoordinationConstants.REGISTRATION_SERVICE_NAME, isSecure);
    final CoordinationContext coordinationContext = new CoordinationContext();
    coordinationContext.setCoordinationType(BusinessActivityConstants.WSBA_PROTOCOL_ATOMIC_OUTCOME);
    CoordinationContextType.Identifier identifier = new CoordinationContextType.Identifier();
    String txId = subTx.get_uid().stringForm();
    identifier.setValue("urn:" + txId);
    coordinationContext.setIdentifier(identifier);
    if (expires != null && expires.longValue() > 0) {
        Expires expiresInstance = new Expires();
        expiresInstance.setValue(expires);
        coordinationContext.setExpires(expiresInstance);
    }
    W3CEndpointReference registrationCoordinator = getRegistrationCoordinator(registrationCoordinatorURI, txId);
    coordinationContext.setRegistrationService(registrationCoordinator);
    try {
        _theRegistrar.associate(subTx);
    } catch (Exception e) {
    // will not happen
    }
    BridgeTxData bridgeTxData = new BridgeTxData();
    bridgeTxData.context = coordinationContext;
    bridgeTxData.coordinator = subTx;
    bridgeTxData.identifier = txId;
    return bridgeTxData;
}
Also used : NoActivityException(com.arjuna.mw.wsas.exceptions.NoActivityException) InvalidProtocolException(com.arjuna.wsc.InvalidProtocolException) InvalidCreateParametersException(com.arjuna.wsc.InvalidCreateParametersException) SystemException(com.arjuna.mw.wsas.exceptions.SystemException) NoActivityException(com.arjuna.mw.wsas.exceptions.NoActivityException) CoordinationContext(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext) SubordinateBACoordinator(com.arjuna.mwlabs.wscf.model.sagas.arjunacore.subordinate.SubordinateBACoordinator) InstanceIdentifier(com.arjuna.webservices11.wsarj.InstanceIdentifier) SystemException(com.arjuna.mw.wsas.exceptions.SystemException) InvalidProtocolException(com.arjuna.wsc.InvalidProtocolException) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) ServiceRegistry(com.arjuna.webservices11.ServiceRegistry) Expires(org.oasis_open.docs.ws_tx.wscoor._2006._06.Expires) CoordinationContextType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType)

Example 10 with NoActivityException

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

the class ContextFactoryImple method createSubordinate.

public final Object createSubordinate() throws NoActivityException, InvalidProtocolException, SystemException {
    try {
        CoordinatorServiceImple coordManager = (CoordinatorServiceImple) _coordManager;
        BACoordinator subordinateTransaction = coordManager.createSubordinate();
        /*
             * Now add the registrar for this specific coordinator to the
             * mapper.
             */
        subordinateTransaction.enlistSynchronization(new CleanupSynchronization(subordinateTransaction.get_uid().stringForm(), _theRegistrar));
        _theRegistrar.associate(subordinateTransaction);
        return subordinateTransaction;
    } catch (Exception ex) {
        throw new SystemException(ex.toString());
    }
}
Also used : CleanupSynchronization(com.arjuna.mwlabs.wst11.ba.participants.CleanupSynchronization) SystemException(com.arjuna.mw.wsas.exceptions.SystemException) CoordinatorServiceImple(com.arjuna.mwlabs.wscf.model.sagas.arjunacore.CoordinatorServiceImple) BACoordinator(com.arjuna.mwlabs.wscf.model.sagas.arjunacore.BACoordinator) SubordinateBACoordinator(com.arjuna.mwlabs.wscf.model.sagas.arjunacore.subordinate.SubordinateBACoordinator) InvalidProtocolException(com.arjuna.wsc.InvalidProtocolException) InvalidCreateParametersException(com.arjuna.wsc.InvalidCreateParametersException) SystemException(com.arjuna.mw.wsas.exceptions.SystemException) NoActivityException(com.arjuna.mw.wsas.exceptions.NoActivityException)

Aggregations

NoActivityException (com.arjuna.mw.wsas.exceptions.NoActivityException)12 SystemException (com.arjuna.mw.wsas.exceptions.SystemException)7 InvalidCreateParametersException (com.arjuna.wsc.InvalidCreateParametersException)5 InvalidProtocolException (com.arjuna.wsc.InvalidProtocolException)5 UserActivity (com.arjuna.mw.wsas.UserActivity)3 HLS (com.arjuna.mw.wsas.activity.HLS)3 ActivityImple (com.arjuna.mwlabs.wsas.activity.ActivityImple)3 SubordinateATCoordinator (com.arjuna.mwlabs.wscf.model.twophase.arjunacore.subordinate.SubordinateATCoordinator)3 ServiceRegistry (com.arjuna.webservices11.ServiceRegistry)3 InstanceIdentifier (com.arjuna.webservices11.wsarj.InstanceIdentifier)3 W3CEndpointReference (javax.xml.ws.wsaddressing.W3CEndpointReference)3 Test (org.junit.Test)3 CoordinationContext (org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext)3 CoordinationContextType (org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType)3 Expires (org.oasis_open.docs.ws_tx.wscoor._2006._06.Expires)3 Outcome (com.arjuna.mw.wsas.activity.Outcome)2 ActiveChildException (com.arjuna.mw.wsas.exceptions.ActiveChildException)2 InvalidActivityException (com.arjuna.mw.wsas.exceptions.InvalidActivityException)2 InvalidTimeoutException (com.arjuna.mw.wsas.exceptions.InvalidTimeoutException)2 NoPermissionException (com.arjuna.mw.wsas.exceptions.NoPermissionException)2