Search in sources :

Example 6 with CoordinationContext

use of org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext in project narayana by jbosstm.

the class SubordinateImporter method importContext.

public static TxContext importContext(CoordinationContextType cc) {
    // get the subordinate transaction manager to install any existing
    // subordinate tx for this one or create and install a new one.
    final String identifier = cc.getIdentifier().getValue();
    TxContext subordinateTxContext = subordinateContextMap.get(identifier);
    if (subordinateTxContext == null) {
        // create a context for a local coordinator
        CoordinationContext context = null;
        try {
            context = atContextFactory.create(AtomicTransactionConstants.WSAT_PROTOCOL, 0L, cc, false);
        } catch (InvalidCreateParametersException e) {
        // should not happen
        }
        subordinateTxContext = new TxContextImple(context);
        subordinateContextMap.put(identifier, subordinateTxContext);
        // register a cleanup callback with the subordinate transactionso that the entry gets removed
        // when the transcation commits or rolls back
        // remove "urn:" prefix
        String subordinateId = context.getIdentifier().getValue().substring(4);
        SubordinateATCoordinator.SubordinateCallback callback = new SubordinateATCoordinator.SubordinateCallback() {

            public String parentId = identifier;

            public void run() {
                subordinateContextMap.remove(parentId);
            }
        };
        SubordinateATCoordinator.addCallback(subordinateId, callback);
    }
    return subordinateTxContext;
}
Also used : SubordinateATCoordinator(com.arjuna.mwlabs.wscf.model.twophase.arjunacore.subordinate.SubordinateATCoordinator) TxContext(com.arjuna.mw.wst.TxContext) TxContextImple(com.arjuna.mwlabs.wst11.at.context.TxContextImple) InvalidCreateParametersException(com.arjuna.wsc.InvalidCreateParametersException) CoordinationContext(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext)

Example 7 with CoordinationContext

use of org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext in project narayana by jbosstm.

the class UserBusinessActivityImple method getTerminationCoordinator.

private W3CEndpointReference getTerminationCoordinator(final TxContextImple ctx) throws SystemException {
    final CoordinationContextType coordinationContext = ctx.context().getCoordinationContext();
    final String messageId = MessageId.getMessageId();
    try {
        return RegistrationCoordinator.register(coordinationContext, messageId, getParticipantProtocolService(ctx.identifier(), ctx.isSecure()), com.arjuna.webservices.wsarjtx.ArjunaTXConstants.WSARJTX_PROTOCOL_TERMINATION);
    } catch (final Throwable th) {
        throw new SystemException(wstxLogger.i18NLogger.get_mwlabs_wst11_ba_remote_UserBusinessActivityImple_3());
    }
}
Also used : SystemException(com.arjuna.wst.SystemException) CoordinationContextType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType)

Example 8 with CoordinationContext

use of org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext in project narayana by jbosstm.

the class UserBusinessActivityImple method getContext.

/**
 * fetch the coordination context type stashed in the current BA context implememtation
 * and use it to construct an instance of the coordination context extension type we need to
 * send down the wire to the activation coordinator
 * @param current the current AT context implememtation
 * @return an instance of the coordination context extension type
 */
private CoordinationContext getContext(TxContextImple current) {
    CoordinationContextType contextType = getContextType(current);
    CoordinationContext context = new CoordinationContext();
    context.setCoordinationType(contextType.getCoordinationType());
    context.setExpires(contextType.getExpires());
    context.setIdentifier(contextType.getIdentifier());
    context.setRegistrationService(contextType.getRegistrationService());
    return context;
}
Also used : CoordinationContextType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType) CoordinationContext(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext)

Example 9 with CoordinationContext

use of org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext in project narayana by jbosstm.

the class ActivationTest method executeRequestTest.

private void executeRequestTest(final String messageId, final String coordinationType, final Long expires, final CoordinationContext coordinationContext) throws Exception {
    final MAP map = AddressingHelper.createRequestContext(TestUtil11.activationCoordinatorService, messageId);
    Expires expiresInstance;
    if (expires == null) {
        expiresInstance = null;
    } else {
        expiresInstance = new Expires();
        expiresInstance.setValue(expires.longValue());
    }
    CreateCoordinationContextResponseType createCoordinationContextResponseType;
    createCoordinationContextResponseType = ActivationCoordinatorClient.getClient().sendCreateCoordination(map, coordinationType, expiresInstance, coordinationContext);
    final CreateCoordinationContextDetails details = testActivationCoordinatorProcessor.getCreateCoordinationContextDetails(messageId, 10000);
    final CreateCoordinationContextType requestCreateCoordinationContext = details.getCreateCoordinationContext();
    final MAP requestMAP = details.getMAP();
    assertNotNull(requestMAP.getTo());
    assertEquals(requestMAP.getTo(), TestUtil11.activationCoordinatorService);
    // we don't care about the reply to field --  this is an RPC style message
    // assertNotNull(requestMAP.getReplyTo());
    // assertTrue(AddressingHelper.isNoneReplyTo(requestMAP));
    assertNotNull(requestMAP.getMessageID());
    assertEquals(requestMAP.getMessageID(), messageId);
    if (expires == null) {
        assertNull(requestCreateCoordinationContext.getExpires());
    } else {
        assertNotNull(requestCreateCoordinationContext.getExpires());
        assertEquals(expires.longValue(), requestCreateCoordinationContext.getExpires().getValue());
    }
    if (coordinationContext == null) {
        assertNull(requestCreateCoordinationContext.getCurrentContext());
    } else {
        assertNotNull(requestCreateCoordinationContext.getCurrentContext());
        assertEquals(requestCreateCoordinationContext.getCurrentContext().getIdentifier().getValue(), coordinationContext.getIdentifier().getValue());
        if (coordinationContext.getExpires() == null) {
            assertNull(requestCreateCoordinationContext.getCurrentContext().getExpires());
        } else {
            assertNotNull(requestCreateCoordinationContext.getCurrentContext().getExpires());
            assertEquals(requestCreateCoordinationContext.getCurrentContext().getExpires().getValue(), coordinationContext.getExpires().getValue());
        }
        assertNotNull(requestCreateCoordinationContext.getCurrentContext().getIdentifier());
        assertEquals(requestCreateCoordinationContext.getCurrentContext().getIdentifier().getValue(), coordinationContext.getIdentifier().getValue());
    }
    assertNotNull(requestCreateCoordinationContext.getCoordinationType());
    assertEquals(requestCreateCoordinationContext.getCoordinationType(), coordinationType);
    // make sure we got a sensible response
    checkResponse(coordinationType, expiresInstance, createCoordinationContextResponseType);
}
Also used : CreateCoordinationContextType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CreateCoordinationContextType) CreateCoordinationContextDetails(com.arjuna.wsc.tests.arq.TestActivationCoordinatorProcessor.CreateCoordinationContextDetails) Expires(org.oasis_open.docs.ws_tx.wscoor._2006._06.Expires) MAP(org.jboss.ws.api.addressing.MAP) CreateCoordinationContextResponseType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CreateCoordinationContextResponseType)

Example 10 with CoordinationContext

use of org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext in project narayana by jbosstm.

the class ActivationTest method testRequestWithoutExpiresWithCurrentContextWithoutExpires.

@Test
public void testRequestWithoutExpiresWithCurrentContextWithoutExpires() throws Exception {
    final String messageId = "testRequestWithoutExpiresWithCurrentContextWithoutExpires";
    final String coordinationType = TestUtil.COORDINATION_TYPE;
    final Long expires = null;
    final CoordinationContext coordinationContext = new CoordinationContext();
    coordinationContext.setCoordinationType(coordinationType);
    CoordinationContextType.Identifier identifier = new CoordinationContextType.Identifier();
    identifier.setValue(TestUtil.PROTOCOL_IDENTIFIER);
    coordinationContext.setIdentifier(identifier);
    W3CEndpointReference registrationService = TestUtil11.getRegistrationEndpoint(identifier.getValue());
    coordinationContext.setRegistrationService(registrationService);
    executeRequestTest(messageId, coordinationType, expires, coordinationContext);
}
Also used : W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) CreateCoordinationContextType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CreateCoordinationContextType) CoordinationContextType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType) CoordinationContext(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext) Test(org.junit.Test)

Aggregations

CoordinationContextType (org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType)69 MAP (org.jboss.ws.api.addressing.MAP)43 SoapFault11 (com.arjuna.webservices11.SoapFault11)39 Action (javax.xml.ws.Action)38 RequestWrapper (javax.xml.ws.RequestWrapper)38 MessageContext (javax.xml.ws.handler.MessageContext)38 CoordinationContext (org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext)24 W3CEndpointReference (javax.xml.ws.wsaddressing.W3CEndpointReference)14 InvalidCreateParametersException (com.arjuna.wsc.InvalidCreateParametersException)12 CreateCoordinationContextType (org.oasis_open.docs.ws_tx.wscoor._2006._06.CreateCoordinationContextType)9 Expires (org.oasis_open.docs.ws_tx.wscoor._2006._06.Expires)9 Test (org.junit.Test)7 SoapFault (com.arjuna.webservices.SoapFault)6 InvalidProtocolException (com.arjuna.wsc.InvalidProtocolException)6 SystemException (com.arjuna.wst.SystemException)6 TxContextImple (com.arjuna.mwlabs.wst11.at.context.TxContextImple)5 ServiceRegistry (com.arjuna.webservices11.ServiceRegistry)5 SOAPEnvelope (javax.xml.soap.SOAPEnvelope)5 SOAPHeaderElement (javax.xml.soap.SOAPHeaderElement)5 ProtocolException (javax.xml.ws.ProtocolException)5