use of org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext in project narayana by jbosstm.
the class UserBusinessActivityImple method startTransaction.
private final Context startTransaction(int timeout, TxContextImple current) throws InvalidCreateParametersException, SystemException {
try {
final Long expires = (timeout > 0 ? new Long(timeout) : null);
final String messageId = MessageId.getMessageId();
final CoordinationContext currentContext = (current != null ? getContext(current) : null);
final CoordinationContextType coordinationContext = ActivationCoordinator.createCoordinationContext(_activationCoordinatorService, messageId, BusinessActivityConstants.WSBA_PROTOCOL_ATOMIC_OUTCOME, expires, currentContext);
if (coordinationContext == null) {
throw new SystemException(wstxLogger.i18NLogger.get_mwlabs_wst11_ba_remote_UserBusinessActivityImple_2());
}
return new ContextImple(coordinationContext);
} catch (final InvalidCreateParametersException icpe) {
throw icpe;
} catch (final SoapFault sf) {
throw new SystemException(sf.getMessage());
} catch (final Exception ex) {
throw new SystemException(ex.toString());
}
}
use of org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext in project narayana by jbosstm.
the class JaxBaseHeaderContextProcessor method handleOutboundMessage.
/**
* Handle the request.
*
* @param soapMessage The current message context.
* @param mustUnderstand Value of MustUnderstand attribute.
* @return whether the message was handled
*/
public boolean handleOutboundMessage(final SOAPMessage soapMessage, boolean mustUnderstand) {
if (soapMessage == null) {
return true;
}
try {
/*
* There should either be an Atomic Transaction *or* a Business Activity
* associated with the thread.
*/
final TransactionManager transactionManager = TransactionManagerFactory.transactionManager();
final com.arjuna.mw.wst11.BusinessActivityManager businessActivityManager = BusinessActivityManagerFactory.businessActivityManager();
final Context atContext;
if (transactionManager != null) {
final TxContextImple txContext = (TxContextImple) transactionManager.currentTransaction();
atContext = (txContext == null ? null : txContext.context());
} else {
atContext = null;
}
final Context baContext;
if (businessActivityManager != null) {
final com.arjuna.mwlabs.wst11.ba.context.TxContextImple txContext = (com.arjuna.mwlabs.wst11.ba.context.TxContextImple) businessActivityManager.currentTransaction();
baContext = (txContext == null ? null : txContext.context());
} else {
baContext = null;
}
final CoordinationContextType coordinationContext;
if (baContext != null) {
coordinationContext = baContext.getCoordinationContext();
} else if (atContext != null) {
coordinationContext = atContext.getCoordinationContext();
} else {
coordinationContext = null;
}
if (coordinationContext != null) {
final SOAPEnvelope env = soapMessage.getSOAPPart().getEnvelope();
SOAPHeader header = env.getHeader();
if (header == null) {
header = env.addHeader();
}
final Name name = env.createName(CoordinationConstants.WSCOOR_ELEMENT_COORDINATION_CONTEXT, CoordinationConstants.WSCOOR_PREFIX, CoordinationConstants.WSCOOR_NAMESPACE);
final SOAPHeaderElement headerElement = header.addHeaderElement(name);
headerElement.addNamespaceDeclaration(CoordinationConstants.WSCOOR_PREFIX, CoordinationConstants.WSCOOR_NAMESPACE);
headerElement.setMustUnderstand(mustUnderstand);
CoordinationContextHelper.serialise(coordinationContext, headerElement);
}
} catch (final Throwable th) {
wstxLogger.i18NLogger.warn_mw_wst11_client_JaxHC11P_1("com.arjuna.mw.wst11.client.JaxBaseHeaderContextProcessor.handleRequest()", th);
}
return true;
}
use of org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext 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;
}
use of org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext 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());
}
}
use of org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext in project narayana by jbosstm.
the class CoordinationContextHandler method handlemessageInbound.
/**
* check for an arjuna instance identifier element embedded in the soap message headesr and, if found, use it to
* label an arjuna context attached to the message context
* @param context
* @return
* @throws ProtocolException
*/
private boolean handlemessageInbound(SOAPMessageContext context) throws ProtocolException {
try {
final SOAPMessage soapMessage = context.getMessage();
final SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope();
Iterator<SOAPHeaderElement> iterator = soapEnvelope.getHeader().examineAllHeaderElements();
while (iterator.hasNext()) {
final SOAPHeaderElement headerElement = iterator.next();
if (CoordinationConstants.WSCOOR_ELEMENT_COORDINATION_CONTEXT_QNAME.equals(headerElement.getElementQName())) {
// found it - clear the must understand flag, retrieve the value and store an arjuna
// context in the message context
headerElement.setMustUnderstand(false);
final JAXBContext jaxbCtx = getJaxbContext();
final JAXBElement<CoordinationContextType> elt = jaxbCtx.createUnmarshaller().unmarshal(headerElement, CoordinationContextType.class);
final CoordinationContextType coordinationContext = elt.getValue();
CoordinationContextManager.setContext(context, coordinationContext);
}
}
} catch (Exception se) {
throw new ProtocolException(se);
}
return true;
}
Aggregations