Search in sources :

Example 6 with ServiceRegistry

use of com.arjuna.webservices11.ServiceRegistry 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 7 with ServiceRegistry

use of com.arjuna.webservices11.ServiceRegistry in project narayana by jbosstm.

the class RegistrarImple method getCompletionCoordinator.

private W3CEndpointReference getCompletionCoordinator(final InstanceIdentifier instanceIdentifier, final boolean isSecure) {
    W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
    ServiceRegistry serviceRegistry = PrivilegedServiceRegistryFactory.getInstance().getServiceRegistry();
    String address = serviceRegistry.getServiceURI(AtomicTransactionConstants.COMPLETION_COORDINATOR_SERVICE_NAME, isSecure);
    builder.serviceName(AtomicTransactionConstants.COMPLETION_COORDINATOR_SERVICE_QNAME);
    builder.endpointName(AtomicTransactionConstants.COMPLETION_COORDINATOR_PORT_QNAME);
    builder.address(address);
    InstanceIdentifier.setEndpointInstanceIdentifier(builder, instanceIdentifier);
    return builder.build();
}
Also used : W3CEndpointReferenceBuilder(javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder) ServiceRegistry(com.arjuna.webservices11.ServiceRegistry)

Example 8 with ServiceRegistry

use of com.arjuna.webservices11.ServiceRegistry in project narayana by jbosstm.

the class RegistrarImple method getCoordinator.

private W3CEndpointReference getCoordinator(final String participantId, final boolean isSecure) {
    W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
    ServiceRegistry serviceRegistry = PrivilegedServiceRegistryFactory.getInstance().getServiceRegistry();
    String address = serviceRegistry.getServiceURI(AtomicTransactionConstants.COORDINATOR_SERVICE_NAME, isSecure);
    builder.serviceName(AtomicTransactionConstants.COORDINATOR_SERVICE_QNAME);
    builder.endpointName(AtomicTransactionConstants.COORDINATOR_PORT_QNAME);
    builder.address(address);
    InstanceIdentifier.setEndpointInstanceIdentifier(builder, participantId);
    return builder.build();
}
Also used : W3CEndpointReferenceBuilder(javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder) ServiceRegistry(com.arjuna.webservices11.ServiceRegistry)

Example 9 with ServiceRegistry

use of com.arjuna.webservices11.ServiceRegistry in project narayana by jbosstm.

the class UserTransactionImple method getCompletionParticipant.

/**
 * Create an endpoint for the local participant service labelled with the current context id which can be passed
 * to the registration service and handed on to the registered coordinator to call back to this transaction
 * @param id the current transaction context identifier
 * @return
 */
private W3CEndpointReference getCompletionParticipant(final String id, final boolean isSecure) {
    final QName serviceName = AtomicTransactionConstants.COMPLETION_INITIATOR_SERVICE_QNAME;
    final QName endpointName = AtomicTransactionConstants.COMPLETION_INITIATOR_PORT_QNAME;
    final ServiceRegistry serviceRegistry = PrivilegedServiceRegistryFactory.getInstance().getServiceRegistry();
    final String address = serviceRegistry.getServiceURI(AtomicTransactionConstants.COMPLETION_INITIATOR_SERVICE_NAME, isSecure);
    W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
    builder.serviceName(serviceName);
    builder.endpointName(endpointName);
    builder.address(address);
    InstanceIdentifier.setEndpointInstanceIdentifier(builder, id);
    return builder.build();
}
Also used : W3CEndpointReferenceBuilder(javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder) QName(javax.xml.namespace.QName) ServiceRegistry(com.arjuna.webservices11.ServiceRegistry)

Example 10 with ServiceRegistry

use of com.arjuna.webservices11.ServiceRegistry in project narayana by jbosstm.

the class TestContextFactory method create.

public CoordinationContext create(final String coordinationTypeURI, final Long expires, final CoordinationContextType currentContext, boolean isSecure) throws InvalidCreateParametersException {
    if (coordinationTypeURI.equals(TestUtil.INVALID_CREATE_PARAMETERS_COORDINATION_TYPE)) {
        throw new InvalidCreateParametersException();
    }
    final ServiceRegistry serviceRegistry = ServiceRegistry.getRegistry();
    final String registrationURI = serviceRegistry.getServiceURI(CoordinationConstants.REGISTRATION_SERVICE_NAME);
    final W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
    builder.serviceName(CoordinationConstants.REGISTRATION_SERVICE_QNAME);
    builder.endpointName(CoordinationConstants.REGISTRATION_ENDPOINT_QNAME);
    builder.address(registrationURI);
    W3CEndpointReference registrationService = builder.build();
    CoordinationContext testCoordinationContext = new CoordinationContext();
    CoordinationContext.Identifier identifier = new CoordinationContext.Identifier();
    identifier.setValue(Integer.toString(nextIdentifier()));
    testCoordinationContext.setIdentifier(identifier);
    if (expires != null && expires.longValue() > 0) {
        Expires expiresInstance = new Expires();
        expiresInstance.setValue(expires);
        testCoordinationContext.setExpires(expiresInstance);
    }
    testCoordinationContext.setCoordinationType(_coordinationType);
    testCoordinationContext.setRegistrationService(registrationService);
    try {
        SOAPFactory factory = SOAPFactory.newInstance();
        SOAPElement element = factory.createElement(TestUtil.TEST_ELEMENT_EXTENSION_VALUE_QNAME);
        element.addTextNode(TestUtil.TEST_EXTENSION_VALUE);
        testCoordinationContext.getAny().add(element);
    } catch (SOAPException e) {
    // TODO log error here
    }
    return testCoordinationContext;
}
Also used : W3CEndpointReferenceBuilder(javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) SOAPException(javax.xml.soap.SOAPException) SOAPElement(javax.xml.soap.SOAPElement) ServiceRegistry(com.arjuna.webservices11.ServiceRegistry) Expires(org.oasis_open.docs.ws_tx.wscoor._2006._06.Expires) InvalidCreateParametersException(com.arjuna.wsc.InvalidCreateParametersException) SOAPFactory(javax.xml.soap.SOAPFactory) CoordinationContext(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext)

Aggregations

ServiceRegistry (com.arjuna.webservices11.ServiceRegistry)53 WSCEnvironmentBean (org.jboss.jbossts.xts.environment.WSCEnvironmentBean)22 W3CEndpointReferenceBuilder (javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder)16 WSTEnvironmentBean (org.jboss.jbossts.xts.environment.WSTEnvironmentBean)12 QName (javax.xml.namespace.QName)7 W3CEndpointReference (javax.xml.ws.wsaddressing.W3CEndpointReference)7 SystemException (com.arjuna.mw.wsas.exceptions.SystemException)6 ServletContext (javax.servlet.ServletContext)6 InvalidCreateParametersException (com.arjuna.wsc.InvalidCreateParametersException)5 CoordinationContext (org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext)5 Expires (org.oasis_open.docs.ws_tx.wscoor._2006._06.Expires)5 NoActivityException (com.arjuna.mw.wsas.exceptions.NoActivityException)4 InstanceIdentifier (com.arjuna.webservices11.wsarj.InstanceIdentifier)4 InvalidProtocolException (com.arjuna.wsc.InvalidProtocolException)4 CoordinationContextType (org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType)4 SubordinateBACoordinator (com.arjuna.mwlabs.wscf.model.sagas.arjunacore.subordinate.SubordinateBACoordinator)3 Uid (com.arjuna.ats.arjuna.common.Uid)2 DuplicateParticipantException (com.arjuna.mw.wscf.exceptions.DuplicateParticipantException)2 ProtocolNotRegisteredException (com.arjuna.mw.wscf.exceptions.ProtocolNotRegisteredException)2 SubordinateATCoordinator (com.arjuna.mwlabs.wscf.model.twophase.arjunacore.subordinate.SubordinateATCoordinator)2