use of com.arjuna.mwlabs.wst11.at.context.TxContextImple in project narayana by jbosstm.
the class UserTransactionImple 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();
CompletionStub completionStub = new CompletionStub(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 UserTransactionImple 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));
enlistCompletionParticipants();
} 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;
}
}
use of com.arjuna.mwlabs.wst11.at.context.TxContextImple in project narayana by jbosstm.
the class UserTransactionStandaloneImple 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));
enlistCompletionParticipants();
} 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.at.context.TxContextImple 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 = atContextFactory.create(AtomicTransactionConstants.WSAT_PROTOCOL, 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);
SubordinateATCoordinator.SubordinateCallback callback = new SubordinateATCoordinator.SubordinateCallback() {
public String parentId = identifier;
public void run() {
subordinateContextMap.remove(parentId);
}
};
SubordinateATCoordinator.addCallback(subordinateId, callback);
}
return subordinateTxContext;
}
use of com.arjuna.mwlabs.wst11.at.context.TxContextImple in project narayana by jbosstm.
the class UserBusinessActivityImple method close.
public void close() throws TransactionRolledBackException, 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.close();
} catch (SystemException ex) {
throw ex;
} catch (TransactionRolledBackException 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();
}
}
Aggregations