Search in sources :

Example 1 with ServiceRegistry

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

the class TerminationCoordinatorRPCInitialisation method startup.

public static void startup() {
    final ServiceRegistry serviceRegistry = PrivilegedServiceRegistryFactory.getInstance().getServiceRegistry();
    WSCEnvironmentBean wscEnvironmentBean = XTSPropertyManager.getWSCEnvironmentBean();
    String bindAddress = wscEnvironmentBean.getBindAddress11();
    int bindPort = wscEnvironmentBean.getBindPort11();
    int secureBindPort = wscEnvironmentBean.getBindPortSecure11();
    WSTEnvironmentBean wstEnvironmentBean = XTSPropertyManager.getWSTEnvironmentBean();
    String coordinatorServiceURLPath = wstEnvironmentBean.getCoordinatorServiceURLPath();
    if (coordinatorServiceURLPath == null) {
        coordinatorServiceURLPath = "/ws-t11-coordinator";
    }
    if (bindAddress == null) {
        bindAddress = "localhost";
    }
    if (bindPort == 0) {
        bindPort = 8080;
    }
    if (secureBindPort == 0) {
        secureBindPort = 8443;
    }
    final String baseUri = "http://" + bindAddress + ":" + bindPort + coordinatorServiceURLPath;
    final String uri = baseUri + "/" + ArjunaTX11Constants.TERMINATION_COORDINATOR_RPC_SERVICE_NAME;
    final String secureBaseUri = "https://" + bindAddress + ":" + secureBindPort + coordinatorServiceURLPath;
    final String secureUri = secureBaseUri + "/" + ArjunaTX11Constants.TERMINATION_COORDINATOR_RPC_SERVICE_NAME;
    serviceRegistry.registerServiceProvider(ArjunaTX11Constants.TERMINATION_COORDINATOR_RPC_SERVICE_NAME, uri);
    serviceRegistry.registerSecureServiceProvider(ArjunaTX11Constants.TERMINATION_COORDINATOR_RPC_SERVICE_NAME, secureUri);
}
Also used : WSTEnvironmentBean(org.jboss.jbossts.xts.environment.WSTEnvironmentBean) WSCEnvironmentBean(org.jboss.jbossts.xts.environment.WSCEnvironmentBean) ServiceRegistry(com.arjuna.webservices11.ServiceRegistry)

Example 2 with ServiceRegistry

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

the class RegistrationCoordinatorFaultInitialisation method startup.

/**
 * The context has been initialized.
 */
public static void startup() {
    // TODO work out how to configure the endpoint name here
    final ServiceRegistry serviceRegistry = PrivilegedServiceRegistryFactory.getInstance().getServiceRegistry();
    WSCEnvironmentBean wscEnvironmentBean = XTSPropertyManager.getWSCEnvironmentBean();
    String bindAddress = wscEnvironmentBean.getBindAddress11();
    int bindPort = wscEnvironmentBean.getBindPort11();
    int secureBindPort = wscEnvironmentBean.getBindPortSecure11();
    String serviceURLPath = wscEnvironmentBean.getServiceURLPath();
    if (serviceURLPath == null) {
        serviceURLPath = "/ws-c11";
    }
    if (bindAddress == null) {
        bindAddress = "localhost";
    }
    if (bindPort == 0) {
        bindPort = 8080;
    }
    if (secureBindPort == 0) {
        secureBindPort = 8443;
    }
    final String baseUri = "http://" + bindAddress + ":" + bindPort + serviceURLPath;
    final String uri = baseUri + "/CoordinationFaultService";
    final String secureBaseUri = "https://" + bindAddress + ":" + secureBindPort + serviceURLPath;
    final String secureUri = secureBaseUri + "/CoordinationFaultService";
    serviceRegistry.registerServiceProvider(CoordinationConstants.COORDINATION_SOAP_FAULT_SERVICE_NAME, uri);
    serviceRegistry.registerSecureServiceProvider(CoordinationConstants.COORDINATION_SOAP_FAULT_SERVICE_NAME, secureUri);
    ;
}
Also used : WSCEnvironmentBean(org.jboss.jbossts.xts.environment.WSCEnvironmentBean) ServiceRegistry(com.arjuna.webservices11.ServiceRegistry)

Example 3 with ServiceRegistry

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

the class RegistrationCoordinatorResponseInitialisation method startup.

/**
 * The context has been initialized.
 */
public static void startup() {
    // TODO work out how to configure the endpoint name here
    final ServiceRegistry serviceRegistry = PrivilegedServiceRegistryFactory.getInstance().getServiceRegistry();
    WSCEnvironmentBean wscEnvironmentBean = XTSPropertyManager.getWSCEnvironmentBean();
    String bindAddress = wscEnvironmentBean.getBindAddress11();
    int bindPort = wscEnvironmentBean.getBindPort11();
    int secureBindPort = wscEnvironmentBean.getBindPortSecure11();
    String serviceURLPath = wscEnvironmentBean.getServiceURLPath();
    if (serviceURLPath == null) {
        serviceURLPath = "/ws-c11";
    }
    if (bindAddress == null) {
        bindAddress = "localhost";
    }
    if (bindPort == 0) {
        bindPort = 8080;
    }
    if (secureBindPort == 0) {
        secureBindPort = 8443;
    }
    final String baseUri = "http://" + bindAddress + ":" + bindPort + serviceURLPath;
    final String uri = baseUri + "/RegistrationResponseService";
    final String secureBaseUri = "https://" + bindAddress + ":" + secureBindPort + serviceURLPath;
    final String secureUri = secureBaseUri + "/RegistrationResponseService";
    serviceRegistry.registerServiceProvider(CoordinationConstants.REGISTRATION_RESPONSE_SERVICE_NAME, uri);
    serviceRegistry.registerSecureServiceProvider(CoordinationConstants.REGISTRATION_RESPONSE_SERVICE_NAME, secureUri);
    ;
}
Also used : WSCEnvironmentBean(org.jboss.jbossts.xts.environment.WSCEnvironmentBean) ServiceRegistry(com.arjuna.webservices11.ServiceRegistry)

Example 4 with ServiceRegistry

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

the class ContextFactoryImple method create.

/**
 * Creates a coordination context.
 *
 * @param coordinationTypeURI
 *            the coordination type uri
 * @param expires
 *            the expire date/time for the returned context, can be null
 * @param currentContext
 *            the current context, can be null
 *
 * @return the created coordination context
 *
 * @throws com.arjuna.wsc.InvalidCreateParametersException
 *             if a parameter passed is invalid this activity identifier.
 */
public CoordinationContext create(final String coordinationTypeURI, final Long expires, final CoordinationContextType currentContext, final boolean isSecure) throws InvalidCreateParametersException {
    if (coordinationTypeURI.equals(AtomicTransactionConstants.WSAT_PROTOCOL)) {
        try {
            if (currentContext == null) {
                // make sure no transaction is currently associated
                _coordManager.suspend();
                final int timeout;
                if (expires == null) {
                    timeout = 0;
                } else {
                    final long timeoutVal = expires.longValue();
                    timeout = (timeoutVal > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) timeoutVal);
                }
                _coordManager.begin(ArjunaContextImple.serviceType, timeout);
                final ArjunaContextImple arjunaContext = ArjunaContextImple.getContext();
                final ServiceRegistry serviceRegistry = PrivilegedServiceRegistryFactory.getInstance().getServiceRegistry();
                final String registrationCoordinatorURI = serviceRegistry.getServiceURI(CoordinationConstants.REGISTRATION_SERVICE_NAME, isSecure);
                final CoordinationContext coordinationContext = new CoordinationContext();
                coordinationContext.setCoordinationType(coordinationTypeURI);
                CoordinationContextType.Identifier identifier = new CoordinationContextType.Identifier();
                identifier.setValue("urn:" + arjunaContext.getTransactionIdentifier());
                coordinationContext.setIdentifier(identifier);
                final int transactionExpires = arjunaContext.getTransactionExpires();
                if (transactionExpires > 0) {
                    Expires expiresInstance = new Expires();
                    expiresInstance.setValue(transactionExpires);
                    coordinationContext.setExpires(expiresInstance);
                }
                W3CEndpointReference registrationCoordinator = getRegistrationCoordinator(registrationCoordinatorURI, arjunaContext);
                coordinationContext.setRegistrationService(registrationCoordinator);
                /*
				 * Now add the registrar for this specific coordinator to the
				 * mapper.
				 */
                _coordManager.enlistSynchronization(new CleanupSynchronization(_coordManager.identifier().toString(), _theRegistrar));
                /*
				 * TODO Uughh! This does a suspend for us! Left over from original
				 * WS-AS stuff.
				 *
				 * TODO
				 * REFACTOR, REFACTOR, REFACTOR.
				 */
                _theRegistrar.associate();
                return coordinationContext;
            } else {
                // 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 = (SubordinateATCoordinator) createSubordinate();
                // hmm, need to create wrappers here as the subTx is in WSCF which only knows
                // about WSAS and WS-C and the participant is in WS-T
                String vtppid = subTx.getVolatile2PhaseId();
                String dtppid = subTx.getDurable2PhaseId();
                Volatile2PCParticipant vtpp = new SubordinateVolatile2PCStub(subTx);
                Durable2PCParticipant dtpp = new SubordinateDurable2PCStub(subTx);
                final String messageId = MessageId.getMessageId();
                W3CEndpointReference participant;
                W3CEndpointReference coordinator;
                participant = getParticipant(vtppid, isSecure);
                coordinator = RegistrationCoordinator.register(currentContext, messageId, participant, AtomicTransactionConstants.WSAT_SUB_PROTOCOL_VOLATILE_2PC);
                ParticipantProcessor.getProcessor().activateParticipant(new ParticipantEngine(vtpp, vtppid, coordinator), vtppid);
                participant = getParticipant(dtppid, isSecure);
                coordinator = RegistrationCoordinator.register(currentContext, messageId, participant, AtomicTransactionConstants.WSAT_SUB_PROTOCOL_DURABLE_2PC);
                ParticipantProcessor.getProcessor().activateParticipant(new ParticipantEngine(dtpp, dtppid, coordinator), dtppid);
                // 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(coordinationTypeURI);
                CoordinationContextType.Identifier identifier = new CoordinationContextType.Identifier();
                String txId = subTx.get_uid().stringForm();
                identifier.setValue("urn:" + txId);
                coordinationContext.setIdentifier(identifier);
                Expires expiresInstance = currentContext.getExpires();
                final long transactionExpires = (expiresInstance != null ? expiresInstance.getValue() : 0);
                if (transactionExpires > 0) {
                    expiresInstance = new Expires();
                    expiresInstance.setValue(transactionExpires);
                    coordinationContext.setExpires(expiresInstance);
                }
                W3CEndpointReference registrationCoordinator = getRegistrationCoordinator(registrationCoordinatorURI, txId);
                coordinationContext.setRegistrationService(registrationCoordinator);
                // now associate the tx id with the sub transaction
                _theRegistrar.associate(subTx);
                return coordinationContext;
            }
        } catch (NoActivityException ex) {
            ex.printStackTrace();
            throw new InvalidCreateParametersException();
        } catch (SystemException ex) {
            ex.printStackTrace();
        } catch (com.arjuna.mw.wsas.exceptions.WrongStateException ex) {
            ex.printStackTrace();
            throw new InvalidCreateParametersException();
        } catch (Exception ex) {
            // TODO handle properly
            ex.printStackTrace();
        }
    } else {
        wstxLogger.i18NLogger.warn_mwlabs_wst_at_Context11FactoryImple_1(AtomicTransactionConstants.WSAT_PROTOCOL, coordinationTypeURI);
        throw new InvalidCreateParametersException(wstxLogger.i18NLogger.get_mwlabs_wst_at_Context11FactoryImple_3() + " < " + AtomicTransactionConstants.WSAT_PROTOCOL + ", " + coordinationTypeURI + " >");
    }
    return null;
}
Also used : Durable2PCParticipant(com.arjuna.wst.Durable2PCParticipant) CleanupSynchronization(com.arjuna.mwlabs.wst11.at.participants.CleanupSynchronization) InvalidCreateParametersException(com.arjuna.wsc.InvalidCreateParametersException) InstanceIdentifier(com.arjuna.webservices11.wsarj.InstanceIdentifier) Volatile2PCParticipant(com.arjuna.wst.Volatile2PCParticipant) SystemException(com.arjuna.mw.wsas.exceptions.SystemException) ParticipantEngine(com.arjuna.wst11.messaging.engines.ParticipantEngine) SubordinateVolatile2PCStub(com.arjuna.wst11.stub.SubordinateVolatile2PCStub) CoordinationContextType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType) 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) ArjunaContextImple(com.arjuna.mwlabs.wst11.at.context.ArjunaContextImple) SubordinateATCoordinator(com.arjuna.mwlabs.wscf.model.twophase.arjunacore.subordinate.SubordinateATCoordinator) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) ServiceRegistry(com.arjuna.webservices11.ServiceRegistry) Expires(org.oasis_open.docs.ws_tx.wscoor._2006._06.Expires) SubordinateDurable2PCStub(com.arjuna.wst11.stub.SubordinateDurable2PCStub)

Example 5 with ServiceRegistry

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

the class ContextFactoryImple method getParticipant.

private W3CEndpointReference getParticipant(final String id, final boolean isSecure) {
    final QName serviceName = AtomicTransactionConstants.PARTICIPANT_SERVICE_QNAME;
    final QName endpointName = AtomicTransactionConstants.PARTICIPANT_PORT_QNAME;
    final ServiceRegistry serviceRegistry = PrivilegedServiceRegistryFactory.getInstance().getServiceRegistry();
    final String address = serviceRegistry.getServiceURI(AtomicTransactionConstants.PARTICIPANT_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)

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