Search in sources :

Example 61 with CoordinationContextType

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

the class CoordinationContextHelper method deserialise.

/**
 * Deserialise a coordination context from a DOM SOAP Header Element.
 * @param headerElement The SOAP header element to deserialise.
 * @return The coordination context.
 * @throws JAXBException for errors during parsing.
 */
public static CoordinationContextType deserialise(final Element headerElement) throws JAXBException {
    ClassLoader loader = getContextClassLoader();
    try {
        // use the XTS module loader so that JAXB can find its factory
        setContextClassLoader(CoordinationContextHelper.class.getClassLoader());
        JAXBContext jaxbContext = getJaxbContext();
        Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
        // the header element is a valid CoordinationContextType node so we can unpack it directly
        // using JAXB. n.b. we will see a mustUnderstand=1 in the otherAttributes which we probably don't
        // want but it will do no harm.
        CoordinationContextType coordinationContextType = unmarshaller.unmarshal(headerElement, CoordinationContextType.class).getValue();
        return coordinationContextType;
    } catch (Exception e) {
        return null;
    } finally {
        // restore the original  loader
        setContextClassLoader(loader);
    }
}
Also used : JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller) CoordinationContextType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType) PrivilegedActionException(java.security.PrivilegedActionException) JAXBException(javax.xml.bind.JAXBException)

Example 62 with CoordinationContextType

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

the class JaxBaseHeaderContextProcessor method handleInboundMessage.

/**
 * Handle the request.
 * @param soapMessage The current message context.
 * @param installSubordinateTx true if a subordinate transaction should be interposed and false
 * if the handler should just resume the incoming transaction. currently only works for AT
 * transactions but will eventually be extended to work for BA transactions too.
 */
protected boolean handleInboundMessage(final SOAPMessage soapMessage, boolean installSubordinateTx) {
    if (soapMessage != null) {
        try {
            final SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope();
            final SOAPHeader soapHeader = soapEnvelope.getHeader();
            final SOAPHeaderElement soapHeaderElement = getHeaderElement(soapHeader, CoordinationConstants.WSCOOR_NAMESPACE, CoordinationConstants.WSCOOR_ELEMENT_COORDINATION_CONTEXT);
            if (soapHeaderElement != null) {
                final CoordinationContextType cc = CoordinationContextHelper.deserialise(soapHeaderElement);
                final String coordinationType = cc.getCoordinationType();
                if (AtomicTransactionConstants.WSAT_PROTOCOL.equals(coordinationType)) {
                    clearMustUnderstand(soapHeader, soapHeaderElement);
                    TxContext txContext = new TxContextImple(cc);
                    if (installSubordinateTx) {
                        txContext = SubordinateImporter.importContext(cc);
                    }
                    TransactionManagerFactory.transactionManager().resume(txContext);
                } else if (BusinessActivityConstants.WSBA_PROTOCOL_ATOMIC_OUTCOME.equals(coordinationType)) {
                    // interposition is not yet implemented for business activities
                    clearMustUnderstand(soapHeader, soapHeaderElement);
                    TxContext txContext = new com.arjuna.mwlabs.wst11.ba.context.TxContextImple(cc);
                    if (installSubordinateTx) {
                        txContext = com.arjuna.mwlabs.wst11.ba.SubordinateImporter.importContext(cc);
                    }
                    BusinessActivityManagerFactory.businessActivityManager().resume(txContext);
                } else {
                    wstxLogger.i18NLogger.warn_mw_wst11_service_JaxHC11P_2("com.arjuna.mw.wst11.service.JaxBaseHeaderContextProcessor.handleRequest(MessageContext context)", coordinationType);
                }
            }
        } catch (final Throwable th) {
            wstxLogger.i18NLogger.warn_mw_wst11_service_JaxHC11P_1("com.arjuna.mw.wst11.service.JaxBaseHeaderContextProcessor.handleRequest(MessageContext context)", th);
        }
    }
    return true;
}
Also used : TxContext(com.arjuna.mw.wst.TxContext) com.arjuna.mw.wst11(com.arjuna.mw.wst11) CoordinationContextType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType) TxContextImple(com.arjuna.mwlabs.wst11.at.context.TxContextImple)

Example 63 with CoordinationContextType

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

the class TxContextImple method isSecure.

public boolean isSecure() {
    if (valid()) {
        CoordinationContextType coordinationContextType = _context.getCoordinationContext();
        W3CEndpointReference epref = coordinationContextType.getRegistrationService();
        NativeEndpointReference nativeRef = EndpointHelper.transform(NativeEndpointReference.class, epref);
        String address = nativeRef.getAddress();
        return address.startsWith("https");
    }
    return false;
}
Also used : W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) NativeEndpointReference(com.arjuna.webservices11.wsaddr.NativeEndpointReference) CoordinationContextType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType)

Example 64 with CoordinationContextType

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

the class UserBusinessActivityStandaloneImple 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 65 with CoordinationContextType

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

the class UserBusinessActivityStandaloneImple method getTerminationCoordinatorRPC.

private W3CEndpointReference getTerminationCoordinatorRPC(final TxContextImple ctx) throws SystemException {
    final CoordinationContextType coordinationContext = ctx.context().getCoordinationContext();
    final String messageId = MessageId.getMessageId();
    try {
        return RegistrationCoordinator.register(coordinationContext, messageId, null, ArjunaTXConstants.WSARJTX_PROTOCOL_TERMINATION_RPC);
    } 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)

Aggregations

CoordinationContextType (org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType)107 SoapFault11 (com.arjuna.webservices11.SoapFault11)43 MAP (org.jboss.ws.api.addressing.MAP)41 Action (javax.xml.ws.Action)38 RequestWrapper (javax.xml.ws.RequestWrapper)38 MessageContext (javax.xml.ws.handler.MessageContext)38 CompletionCoordinatorParticipant (com.arjuna.wst.CompletionCoordinatorParticipant)30 InteropWaitState (com.jboss.transaction.txinterop.interop.states.InteropWaitState)16 CoordinationContext (org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext)13 TransactionRolledBackException (com.arjuna.wst.TransactionRolledBackException)12 InvalidCreateParametersException (com.arjuna.wsc.InvalidCreateParametersException)10 BusinessActivityTerminator (com.arjuna.wst.BusinessActivityTerminator)10 InteropWaitState (com.jboss.transaction.wstf.interop.states.InteropWaitState)10 W3CEndpointReference (javax.xml.ws.wsaddressing.W3CEndpointReference)10 TxContextImple (com.arjuna.mwlabs.wst11.at.context.TxContextImple)7 SoapFault (com.arjuna.webservices.SoapFault)6 SystemException (com.arjuna.wst.SystemException)6 SOAPEnvelope (javax.xml.soap.SOAPEnvelope)6 SOAPHeaderElement (javax.xml.soap.SOAPHeaderElement)6 TxContext (com.arjuna.mw.wst.TxContext)5