Search in sources :

Example 1 with InvalidProtocolException

use of com.arjuna.wsc.InvalidProtocolException in project narayana by jbosstm.

the class ContextFactoryImple method createBridgedTransaction.

/**
 * create a bridged to subordinate WS-AT 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-AT
 * transaction bridge code.
 * @param subordinateType a unique string which groups subordinates for the benefit of their parent tx/app and
 * allows them to be identified and retrieved as a group during recovery
 * @param expires the timeout for the bridged to AT 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(String subordinateType, final Long expires, final boolean isSecure) {
    // we must have a type and it must not be the AT-AT subordinate type
    if (subordinateType == null || SubordinateATCoordinator.SUBORDINATE_TX_TYPE_AT_AT.equals(subordinateType)) {
        return null;
    }
    // we need to create a subordinate transaction and register it as both a durable and volatile
    // participant with the registration service defined in the current context
    SubordinateATCoordinator subTx = null;
    try {
        subTx = (SubordinateATCoordinator) createSubordinate(subordinateType);
    } 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(AtomicTransactionConstants.WSAT_PROTOCOL);
    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) SubordinateATCoordinator(com.arjuna.mwlabs.wscf.model.twophase.arjunacore.subordinate.SubordinateATCoordinator) 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 2 with InvalidProtocolException

use of com.arjuna.wsc.InvalidProtocolException in project narayana by jbosstm.

the class ContextFactoryImple method createSubordinate.

public final Object createSubordinate(String subordinateType) throws NoActivityException, InvalidProtocolException, SystemException {
    try {
        CoordinatorServiceImple coordManager = (CoordinatorServiceImple) _coordManager;
        CoordinatorControl theControl = coordManager.coordinatorControl();
        ATCoordinator subordinateTransaction = theControl.createSubordinate(subordinateType);
        /*
			 * 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.at.participants.CleanupSynchronization) SystemException(com.arjuna.mw.wsas.exceptions.SystemException) SubordinateATCoordinator(com.arjuna.mwlabs.wscf.model.twophase.arjunacore.subordinate.SubordinateATCoordinator) ATCoordinator(com.arjuna.mwlabs.wscf.model.twophase.arjunacore.ATCoordinator) CoordinatorServiceImple(com.arjuna.mwlabs.wscf.model.twophase.arjunacore.CoordinatorServiceImple) CoordinatorControl(com.arjuna.mwlabs.wscf.model.twophase.arjunacore.CoordinatorControl) InvalidProtocolException(com.arjuna.wsc.InvalidProtocolException) InvalidCreateParametersException(com.arjuna.wsc.InvalidCreateParametersException) SystemException(com.arjuna.mw.wsas.exceptions.SystemException) NoActivityException(com.arjuna.mw.wsas.exceptions.NoActivityException)

Example 3 with InvalidProtocolException

use of com.arjuna.wsc.InvalidProtocolException in project narayana by jbosstm.

the class EnduranceTest method doRegisterError.

public void doRegisterError(final String messageId, int count) throws Exception {
    final String protocolIdentifier;
    final W3CEndpointReference participantProtocolService = TestUtil11.getProtocolParticipantEndpoint("participant");
    final CoordinationContextType coordinationContext = new CoordinationContextType();
    CoordinationContextType.Identifier identifierInstance = new CoordinationContextType.Identifier();
    coordinationContext.setCoordinationType(TestUtil.COORDINATION_TYPE);
    coordinationContext.setIdentifier(identifierInstance);
    identifierInstance.setValue("identifier");
    coordinationContext.setRegistrationService(TestUtil11.getRegistrationEndpoint(identifierInstance.getValue()));
    W3CEndpointReference coordinator = null;
    switch(count) {
        case 0:
            protocolIdentifier = TestUtil.INVALID_PROTOCOL_PROTOCOL_IDENTIFIER;
            try {
                coordinator = RegistrationCoordinator.register(coordinationContext, messageId, participantProtocolService, protocolIdentifier);
            } catch (InvalidProtocolException ipe) {
            }
            if (coordinator != null) {
                fail("expected invalid protocol exception");
            }
            break;
        case 1:
            protocolIdentifier = TestUtil.INVALID_STATE_PROTOCOL_IDENTIFIER;
            try {
                coordinator = RegistrationCoordinator.register(coordinationContext, messageId, participantProtocolService, protocolIdentifier);
            } catch (InvalidStateException ise) {
            }
            if (coordinator != null) {
                fail("expected invalid state exception");
            }
            break;
        case 3:
            protocolIdentifier = TestUtil.NO_ACTIVITY_PROTOCOL_IDENTIFIER;
            try {
                coordinator = RegistrationCoordinator.register(coordinationContext, messageId, participantProtocolService, protocolIdentifier);
            } catch (CannotRegisterException cre) {
            }
            if (coordinator != null) {
                fail("expected cannot register exception");
            }
            break;
        default:
            protocolIdentifier = TestUtil.ALREADY_REGISTERED_PROTOCOL_IDENTIFIER;
            try {
                coordinator = RegistrationCoordinator.register(coordinationContext, messageId, participantProtocolService, protocolIdentifier);
            } catch (CannotRegisterException cre) {
            }
            if (coordinator != null) {
                fail("expected cannot register exception");
            }
            break;
    }
    final RegisterDetails details = testRegistrationCoordinatorProcessor.getRegisterDetails(messageId, 10000);
    final RegisterType requestRegister = details.getRegister();
    final MAP requestMap = details.getMAP();
    final ArjunaContext requestArjunaContext = details.getArjunaContext();
    assertEquals(requestMap.getTo(), TestUtil11.registrationCoordinatorService);
    assertEquals(requestMap.getMessageID(), messageId);
    assertNotNull(requestArjunaContext);
    assertEquals(requestArjunaContext.getInstanceIdentifier().getInstanceIdentifier(), identifierInstance.getValue());
    ;
    assertEquals(protocolIdentifier, requestRegister.getProtocolIdentifier());
    assertNotNull(protocolIdentifier, requestRegister.getParticipantProtocolService());
}
Also used : W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) InvalidProtocolException(com.arjuna.wsc.InvalidProtocolException) RegisterDetails(com.arjuna.wsc.tests.arq.TestRegistrationCoordinatorProcessor.RegisterDetails) InvalidStateException(com.arjuna.wsc.InvalidStateException) CreateCoordinationContextType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CreateCoordinationContextType) CoordinationContextType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType) RegisterType(org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterType) ArjunaContext(com.arjuna.webservices11.wsarj.ArjunaContext) MAP(org.jboss.ws.api.addressing.MAP) CannotRegisterException(com.arjuna.wsc.CannotRegisterException)

Example 4 with InvalidProtocolException

use of com.arjuna.wsc.InvalidProtocolException in project narayana by jbosstm.

the class UserTransactionStandaloneImple method enlistCompletionParticipants.

/*
	 * enlist the client for the completiopn protocol so it can commit or ro0ll back the transaction
	 */
private final void enlistCompletionParticipants() throws WrongStateException, UnknownTransactionException, SystemException {
    TransactionManagerImple tm = (TransactionManagerImple) TransactionManager.getTransactionManager();
    final TxContextImple currentTx = (TxContextImple) tm.currentTransaction();
    if (currentTx == null)
        throw new UnknownTransactionException();
    final String id = currentTx.identifier();
    W3CEndpointReference completionCoordinator = null;
    try {
        completionCoordinator = tm.registerParticipant(null, AtomicTransactionConstants.WSAT_SUB_PROTOCOL_COMPLETION_RPC);
    } catch (InvalidProtocolException ex) {
        ex.printStackTrace();
        throw new SystemException(ex.toString());
    } catch (InvalidStateException ex) {
        throw new WrongStateException();
    } catch (CannotRegisterException ex) {
        // cause could actually be no activity or already registered
        throw new UnknownTransactionException();
    }
    _completionCoordinators.put(id, completionCoordinator);
}
Also used : UnknownTransactionException(com.arjuna.wst.UnknownTransactionException) SystemException(com.arjuna.wst.SystemException) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) InvalidProtocolException(com.arjuna.wsc.InvalidProtocolException) WrongStateException(com.arjuna.wst.WrongStateException) InvalidStateException(com.arjuna.wsc.InvalidStateException) TxContextImple(com.arjuna.mwlabs.wst11.at.context.TxContextImple) CannotRegisterException(com.arjuna.wsc.CannotRegisterException)

Example 5 with InvalidProtocolException

use of com.arjuna.wsc.InvalidProtocolException 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)

Aggregations

InvalidProtocolException (com.arjuna.wsc.InvalidProtocolException)6 NoActivityException (com.arjuna.mw.wsas.exceptions.NoActivityException)4 SystemException (com.arjuna.mw.wsas.exceptions.SystemException)4 InvalidCreateParametersException (com.arjuna.wsc.InvalidCreateParametersException)4 W3CEndpointReference (javax.xml.ws.wsaddressing.W3CEndpointReference)4 CoordinationContextType (org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType)3 SubordinateBACoordinator (com.arjuna.mwlabs.wscf.model.sagas.arjunacore.subordinate.SubordinateBACoordinator)2 SubordinateATCoordinator (com.arjuna.mwlabs.wscf.model.twophase.arjunacore.subordinate.SubordinateATCoordinator)2 ServiceRegistry (com.arjuna.webservices11.ServiceRegistry)2 InstanceIdentifier (com.arjuna.webservices11.wsarj.InstanceIdentifier)2 CannotRegisterException (com.arjuna.wsc.CannotRegisterException)2 InvalidStateException (com.arjuna.wsc.InvalidStateException)2 CoordinationContext (org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext)2 Expires (org.oasis_open.docs.ws_tx.wscoor._2006._06.Expires)2 BACoordinator (com.arjuna.mwlabs.wscf.model.sagas.arjunacore.BACoordinator)1 CoordinatorServiceImple (com.arjuna.mwlabs.wscf.model.sagas.arjunacore.CoordinatorServiceImple)1 ATCoordinator (com.arjuna.mwlabs.wscf.model.twophase.arjunacore.ATCoordinator)1 CoordinatorControl (com.arjuna.mwlabs.wscf.model.twophase.arjunacore.CoordinatorControl)1 CoordinatorServiceImple (com.arjuna.mwlabs.wscf.model.twophase.arjunacore.CoordinatorServiceImple)1 TxContextImple (com.arjuna.mwlabs.wst11.at.context.TxContextImple)1