use of com.arjuna.mwlabs.wst11.at.context.TxContextImple in project narayana by jbosstm.
the class UserBusinessActivityImple method cancel.
public void cancel() throws UnknownTransactionException, SystemException, WrongStateException {
TxContextImple ctx = null;
try {
ctx = (TxContextImple) _ctxManager.suspend();
if (ctx == null) {
throw new WrongStateException();
}
final String id = ctx.identifier();
final W3CEndpointReference terminatorCoordinator = getTerminationCoordinator(ctx);
BusinessActivityTerminatorStub terminatorStub = new BusinessActivityTerminatorStub(id, terminatorCoordinator);
terminatorStub.cancel();
} catch (SystemException ex) {
throw ex;
} catch (WrongStateException ex) {
throw ex;
} catch (UnknownTransactionException ex) {
throw ex;
} catch (Exception ex) {
ex.printStackTrace();
throw new SystemException(ex.toString());
} finally {
tidyup();
}
}
use of com.arjuna.mwlabs.wst11.at.context.TxContextImple in project narayana by jbosstm.
the class UserTransactionStandaloneImple method commitWithoutAck.
private final void commitWithoutAck() throws TransactionRolledBackException, UnknownTransactionException, SecurityException, SystemException, WrongStateException {
TxContextImple ctx = null;
String id = null;
try {
ctx = (TxContextImple) _ctxManager.suspend();
if (ctx == null) {
throw new WrongStateException();
}
id = ctx.identifier();
/*
* By default the completionParticipantURL won't be set for an interposed (imported)
* bridged transaction. This is fine, because you shouldn't be able to commit that
* transaction from a node in the tree, only from the root. So, we can prevent commit
* or rollback at this stage. The alternative would be to setup the completionParticipantURL
* and throw the exception from the remote coordinator side (see enlistCompletionParticipants
* for how to do this).
*
* The same applies for an interposed subordinate transaction created via beginSubordinate.
*/
final W3CEndpointReference completionCoordinator = (W3CEndpointReference) _completionCoordinators.get(id);
if (completionCoordinator == null)
throw new WrongStateException();
CompletionRPCStub completionStub = new CompletionRPCStub(id, completionCoordinator);
completionStub.commit();
} catch (SystemException ex) {
throw ex;
} catch (TransactionRolledBackException ex) {
throw ex;
} catch (UnknownTransactionException ex) {
throw ex;
} catch (SecurityException ex) {
throw ex;
} catch (WrongStateException ex) {
throw ex;
} catch (Exception ex) {
ex.printStackTrace();
throw new SystemException(ex.toString());
} finally {
try {
if (ctx != null)
_ctxManager.resume(ctx);
} catch (Exception ex) {
ex.printStackTrace();
}
if (id != null)
_completionCoordinators.remove(id);
}
}
use of com.arjuna.mwlabs.wst11.at.context.TxContextImple in project narayana by jbosstm.
the class UserTransactionStandaloneImple method enlistCompletionParticipants.
/*
* enlist the client for the completiopn protocol so it can commit or ro0ll back the transaction
*/
private final void enlistCompletionParticipants() throws WrongStateException, UnknownTransactionException, SystemException {
TransactionManagerImple tm = (TransactionManagerImple) TransactionManager.getTransactionManager();
final TxContextImple currentTx = (TxContextImple) tm.currentTransaction();
if (currentTx == null)
throw new UnknownTransactionException();
final String id = currentTx.identifier();
W3CEndpointReference completionCoordinator = null;
try {
completionCoordinator = tm.registerParticipant(null, AtomicTransactionConstants.WSAT_SUB_PROTOCOL_COMPLETION_RPC);
} catch (InvalidProtocolException ex) {
ex.printStackTrace();
throw new SystemException(ex.toString());
} catch (InvalidStateException ex) {
throw new WrongStateException();
} catch (CannotRegisterException ex) {
// cause could actually be no activity or already registered
throw new UnknownTransactionException();
}
_completionCoordinators.put(id, completionCoordinator);
}
use of com.arjuna.mwlabs.wst11.at.context.TxContextImple in project narayana by jbosstm.
the class UserTransactionStandaloneImple method startTransaction.
protected final Context startTransaction(int timeout, TxContextImple current) throws 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 com.arjuna.mwlabs.wst11.at.context.TxContextImple in project narayana by jbosstm.
the class UserTransactionStandaloneImple method abortWithoutAck.
private final void abortWithoutAck() throws UnknownTransactionException, SecurityException, SystemException, WrongStateException {
TxContextImple ctx = null;
String id = null;
try {
ctx = (TxContextImple) _ctxManager.suspend();
if (ctx == null) {
throw new WrongStateException();
}
id = ctx.identifier();
/*
* By default the completionParticipantURL won't be set for an interposed (imported)
* bridged transaction. This is fine, because you shouldn't be able to commit that
* transaction from a node in the tree, only from the root. So, we can prevent commit
* or rollback at this stage. The alternative would be to setup the completionParticipantURL
* and throw the exception from the remote coordinator side (see enlistCompletionParticipants
* for how to do this).
*
* The same applies for an interposed subordinate transaction created via beginSubordinate.
*/
W3CEndpointReference completionCoordinator = (W3CEndpointReference) _completionCoordinators.get(id);
if (completionCoordinator == null)
throw new WrongStateException();
CompletionRPCStub completionStub = new CompletionRPCStub(id, completionCoordinator);
completionStub.rollback();
} catch (SystemException ex) {
throw ex;
} catch (UnknownTransactionException ex) {
throw ex;
} catch (SecurityException ex) {
throw ex;
} catch (WrongStateException ex) {
throw ex;
} catch (Exception ex) {
throw new SystemException(ex.toString());
} finally {
try {
if (ctx != null)
_ctxManager.resume(ctx);
} catch (Exception ex) {
ex.printStackTrace();
}
if (id != null)
_completionCoordinators.remove(id);
}
}
Aggregations