use of com.arjuna.wst.SystemException in project quickstart by wildfly.
the class SetServiceBAImpl method addValueToSet.
/**
* Add an item to a set and enroll a Participant if necessary then pass the call through to the business logic.
*
* @param value the value to add to the set.
* @throws AlreadyInSetException if value is already in the set
* @throws SetServiceException if an error occurred when attempting to add the item to the set.
*/
@WebMethod
public void addValueToSet(String value) throws AlreadyInSetException, SetServiceException {
System.out.println("[SERVICE] invoked addValueToSet('" + value + "')");
BusinessActivityManager activityManager = BusinessActivityManagerFactory.businessActivityManager();
/*
* get the transaction context of this thread:
*/
String transactionId;
try {
transactionId = activityManager.currentTransaction().toString();
} catch (SystemException e) {
throw new SetServiceException("Unable to lookup existing BusinesActivity", e);
}
/*
* Lookup existing participant or register new participant
*/
SetParticipantBA participantBA = SetParticipantBA.getParticipant(transactionId);
if (participantBA == null) {
try {
// enlist the Participant for this service:
SetParticipantBA participant = new SetParticipantBA(transactionId, value);
SetParticipantBA.recordParticipant(transactionId, participant);
System.out.println("[SERVICE] Enlisting a participant into the BA");
activityManager.enlistForBusinessAgreementWithCoordinatorCompletion(participant, "SetServiceBAImpl:" + UUID.randomUUID());
} catch (Exception e) {
System.err.println("Participant enlistment failed");
throw new SetServiceException("Error enlisting participant", e);
}
} else {
System.out.println("[SERVICE] Re-using the existing participant, already registered for this BA");
participantBA.addValue(value);
}
// invoke the back-end business logic
System.out.println("[SERVICE] Invoking the back-end business logic");
MockSetManager.add(value);
}
use of com.arjuna.wst.SystemException in project narayana by jbosstm.
the class HandlerFactory method getCurrentTXID.
private static String getCurrentTXID() throws TXFrameworkException {
String txid;
// Try WS-AT
txid = UserTransactionFactory.userTransaction().transactionIdentifier();
if (!txid.equals("Unknown")) {
return txid;
}
// Try WS-BA
try {
BusinessActivityManager businessActivityManager = BusinessActivityManagerFactory.businessActivityManager();
if (businessActivityManager.currentTransaction() != null) {
txid = businessActivityManager.currentTransaction().toString();
if (!txid.equals("Unknown")) {
return txid;
}
}
} catch (SystemException e) {
throw new TXFrameworkException("Error when looking up Business Activity", e);
}
// Try REST-AT
HttpServletRequest req = ResteasyProviderFactory.getContextData(HttpServletRequest.class);
String enlistUrl = req.getHeader("enlistURL");
if (enlistUrl != null) {
String[] parts = enlistUrl.split("/");
return parts[parts.length - 1];
}
throw new TXFrameworkException("No Transaction detected");
}
use of com.arjuna.wst.SystemException in project narayana by jbosstm.
the class BAParticipantManagerImple method fail.
public void fail(final QName exceptionIdentifier) throws SystemException {
if (wstxLogger.logger.isTraceEnabled()) {
wstxLogger.logger.trace(getClass().getSimpleName() + ".fail. Participant id: " + _participantId + ", exceptionIdentifier: " + exceptionIdentifier);
}
try {
if (_hier == null)
throw new UnknownTransactionException();
_coordManager.resume(_hier);
// fail means faulted as far as the coordinator manager is concerned
_coordManager.participantFaulted(_participantId);
_coordManager.suspend();
} catch (final InvalidActivityException iae) {
throw new SystemException("UnknownTransactionException");
} catch (final UnknownTransactionException ute) {
throw new SystemException("UnknownTransactionException");
} catch (com.arjuna.mw.wscf.exceptions.InvalidParticipantException ex) {
throw new SystemException("UnknownParticipantException");
} catch (com.arjuna.mw.wsas.exceptions.NoActivityException ex) {
throw new SystemException("UnknownTransactionException");
} catch (com.arjuna.mw.wsas.exceptions.SystemException ex) {
throw new SystemException(ex.toString());
}
}
use of com.arjuna.wst.SystemException 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.wst.SystemException 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;
}
}
Aggregations