use of com.arjuna.mwlabs.wst11.ba.context.TxContextImple in project narayana by jbosstm.
the class UserBusinessActivityStandaloneImple method complete.
public void complete() throws UnknownTransactionException, SystemException, WrongStateException {
try {
final TxContextImple ctx = ((TxContextImple) _ctxManager.currentTransaction());
if (ctx == null) {
throw new WrongStateException();
}
final String id = ctx.identifier();
final W3CEndpointReference terminatorCoordinatorRPC = getTerminationCoordinatorRPC(ctx);
BusinessActivityTerminatorRPCStub terminatorRPCStub = new BusinessActivityTerminatorRPCStub(id, terminatorCoordinatorRPC);
terminatorRPCStub.complete();
} catch (SystemException ex) {
throw ex;
} catch (UnknownTransactionException ex) {
throw ex;
} catch (WrongStateException ex) {
throw ex;
} catch (Exception ex) {
throw new SystemException(ex.toString());
}
}
use of com.arjuna.mwlabs.wst11.ba.context.TxContextImple in project narayana by jbosstm.
the class UserBusinessActivityStandaloneImple method begin.
public void begin(int timeout) throws WrongStateException, SystemException {
try {
if (_ctxManager.currentTransaction() != null)
throw new WrongStateException();
Context ctx = startTransaction(timeout, null);
_ctxManager.resume(new TxContextImple(ctx));
} catch (InvalidCreateParametersException ex) {
tidyup();
throw new SystemException(ex.toString());
} catch (UnknownTransactionException ex) {
tidyup();
throw new SystemException(ex.toString());
} catch (SystemException ex) {
tidyup();
throw ex;
}
}
use of com.arjuna.mwlabs.wst11.ba.context.TxContextImple in project narayana by jbosstm.
the class UserBusinessActivityStandaloneImple 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 com.arjuna.mwlabs.wst11.ba.context.TxContextImple in project narayana by jbosstm.
the class BridgeWrapper method create.
/**
* create an AT 1.1 subordinate transaction, associate it with the AT 1.1. registry then return a
* BridgedTransaction wrapper allowing the transaction to be driven through prepare, commit
* and/or rollback and providing access to the transaction id and a context which can be used to
* resume the transaction.
* @param subordinateType a unique string which groups subordinates for the benefit of their parent
* tx/app and allows them to be identified and retrieved as a group during recovery. this must differ
* from the string {@link SUBORDINATE_TX_TYPE_AT_AT}
* @param expires the timeout for the bridged-to transaction or 0 if no timeout is required
* @param isSecure true if AT 1.1. protocol messages for the bridged-to transaction should employ
* secure communications, otherwise false
* @return a wrapper for the bridged-to transaction
* @throws SystemException
*/
public static BridgeWrapper create(String subordinateType, long expires, boolean isSecure) {
// the AT 1.1 context factory provides us with a means to create the required data.
ContextFactoryImple.BridgeTxData bridgeTxData = contextFactory.createBridgedTransaction(subordinateType, expires, isSecure);
if (bridgeTxData != null) {
BridgeWrapper bridgeWrapper = new BridgeWrapper();
bridgeWrapper.context = new TxContextImple(bridgeTxData.context);
bridgeWrapper.coordinator = bridgeTxData.coordinator;
bridgeWrapper.id = bridgeTxData.identifier;
bridgeWrapper.subordinateType = subordinateType;
return bridgeWrapper;
} else {
return null;
}
}
use of com.arjuna.mwlabs.wst11.ba.context.TxContextImple in project narayana by jbosstm.
the class UserTransactionImple method beginSubordinate.
/**
* method provided for the benefit of UserSubordinateTransactionImple to allow it
* to begin a subordinate transaction which requires an existing context to be
* installed on the thread before it will start and instal la new transaction
*
* @param timeout
* @throws WrongStateException
* @throws SystemException
*/
public void beginSubordinate(int timeout) throws WrongStateException, SystemException {
try {
TxContext current = _ctxManager.currentTransaction();
if ((current == null) || !(current instanceof TxContextImple))
throw new WrongStateException();
TxContextImple currentImple = (TxContextImple) current;
Context ctx = startTransaction(timeout, currentImple);
_ctxManager.resume(new TxContextImple(ctx));
// n.b. we don't enlist the subordinate transaction for completion
// that ensures that any attempt to commit or rollback will fail
} catch (com.arjuna.wsc.InvalidCreateParametersException ex) {
tidyup();
throw new SystemException(ex.toString());
} catch (com.arjuna.wst.UnknownTransactionException ex) {
tidyup();
throw new SystemException(ex.toString());
} catch (SystemException ex) {
tidyup();
throw ex;
}
}
Aggregations