use of org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext in project narayana by jbosstm.
the class TransactionManagerImple method registerParticipant.
final W3CEndpointReference registerParticipant(final W3CEndpointReference participant, final String protocol) throws InvalidProtocolException, InvalidStateException, CannotRegisterException, SystemException {
TxContextImple currentTx = null;
try {
currentTx = (TxContextImple) _ctxManager.suspend();
if (currentTx == null)
throw new CannotRegisterException();
final CoordinationContextType coordinationContext = currentTx.context().getCoordinationContext();
final String messageId = MessageId.getMessageId();
return com.arjuna.wsc11.RegistrationCoordinator.register(coordinationContext, messageId, participant, protocol);
} catch (final SoapFault sf) {
throw new SystemException(sf.getMessage());
} catch (final CannotRegisterException cre) {
throw cre;
} catch (final InvalidStateException ise) {
throw ise;
} catch (final InvalidProtocolException ipe) {
throw ipe;
} catch (final Exception ex) {
throw new SystemException(ex.toString());
} finally {
try {
if (currentTx != null)
_ctxManager.resume(currentTx);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
use of org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext in project narayana by jbosstm.
the class UserTransactionImple method startTransaction.
protected final Context startTransaction(int timeout, TxContextImple current) throws com.arjuna.wsc.InvalidCreateParametersException, SystemException {
try {
// TODO: tricks for per app _activationCoordinatorService config, perhaps:
// InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("/foo.properties");
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, AtomicTransactionConstants.WSAT_PROTOCOL, expires, currentContext);
if (coordinationContext == null) {
throw new SystemException(wstxLogger.i18NLogger.get_mwlabs_wst_at_remote_UserTransaction11Imple__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 UserTransactionImple method getContext.
/**
* fetch the coordination context type stashed in the current AT 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 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 = baContextFactory.create(BusinessActivityConstants.WSBA_PROTOCOL_ATOMIC_OUTCOME, 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);
SubordinateBACoordinator.SubordinateCallback callback = new SubordinateBACoordinator.SubordinateCallback() {
public String parentId = identifier;
public void run() {
subordinateContextMap.remove(parentId);
}
};
SubordinateBACoordinator.addCallback(subordinateId, callback);
}
return subordinateTxContext;
}
use of org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext in project narayana by jbosstm.
the class BusinessActivityManagerImple method registerParticipant.
private final W3CEndpointReference registerParticipant(final W3CEndpointReference participant, final String protocol) throws com.arjuna.wsc.InvalidProtocolException, com.arjuna.wsc.InvalidStateException, com.arjuna.wsc.CannotRegisterException, SystemException {
TxContextImple currentTx = null;
try {
currentTx = (TxContextImple) _ctxManager.currentTransaction();
if (currentTx == null)
throw new com.arjuna.wsc.NoActivityException();
final CoordinationContextType coordinationContext = currentTx.context().getCoordinationContext();
final String messageId = MessageId.getMessageId();
return RegistrationCoordinator.register(coordinationContext, messageId, participant, protocol);
} catch (final SoapFault sf) {
throw new SystemException(sf.getMessage());
} catch (CannotRegisterException ex) {
throw ex;
} catch (Exception ex) {
ex.printStackTrace();
throw new SystemException(ex.toString());
} finally {
try {
if (currentTx != null)
_ctxManager.resume(currentTx);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
Aggregations