use of com.arjuna.mw.wsas.exceptions.SystemException in project narayana by jbosstm.
the class ArjunaContextImple method initialiseContext.
public void initialiseContext(Object param) {
try {
ATCoordinator currentCoordinator = (ATCoordinator) param;
ActivityHierarchy hier = null;
try {
hier = UserActivityFactory.userActivity().currentActivity();
} catch (SystemException ex) {
ex.printStackTrace();
}
if ((currentCoordinator != null) && (hier != null)) {
/*
* Do the manditory stuff first.
*/
ActionHierarchy txHier = currentCoordinator.getHierarchy();
final int depth = txHier.depth();
_identifierValues = new String[depth];
_expiresValues = new int[depth];
_identifierValues[0] = txHier.getDeepestActionUid().stringForm();
_expiresValues[0] = hier.activity(hier.size() - 1).getTimeout();
/*
* Now let's do the optional stuff.
*/
for (int count = 1, index = 0; count < depth; count++, index++) {
_identifierValues[count] = txHier.getActionUid(index).stringForm();
_expiresValues[count] = hier.activity(index).getTimeout();
}
}
} catch (ClassCastException ex) {
throw new IllegalArgumentException();
}
}
use of com.arjuna.mw.wsas.exceptions.SystemException in project narayana by jbosstm.
the class ATCoordinator method changeParticipantStatus.
private final void changeParticipantStatus(String participantId, int status) throws InvalidParticipantException, SystemException {
/*
* Transaction is active, so we can look at the pendingList only.
*/
// TODO allow transaction status to be changed during commit - exit
// could come in late
boolean found = false;
if (pendingList != null) {
RecordListIterator iter = new RecordListIterator(pendingList);
AbstractRecord absRec = iter.iterate();
try {
while ((absRec != null) && !found) {
if (absRec instanceof ParticipantRecord) {
ParticipantRecord pr = (ParticipantRecord) absRec;
Participant participant = (Participant) pr.value();
if (participantId.equals(participant.id())) {
found = true;
if (status == READONLY)
pr.readonly();
else
pr.rolledback();
}
}
absRec = iter.iterate();
}
} catch (Exception ex) {
throw new SystemException(ex.toString());
}
}
if (!found)
throw new InvalidParticipantException();
}
use of com.arjuna.mw.wsas.exceptions.SystemException in project narayana by jbosstm.
the class CoordinatorManagerFactory method coordinatorManager.
/**
* Obtain a reference to a coordinator that implements the specified
* protocol.
*
* @param protocol The XML definition of the type of
* coordination protocol required.
*
* @exception com.arjuna.mw.wscf.exceptions.ProtocolNotRegisteredException Thrown if the requested
* protocol is not available.
*
* @return the CoordinatorManager implementation to use.
*/
/*
* Have the type specified in XML. More data may be specified, which
* can be passed to the implementation in the same way ObjectName was.
*/
public static CoordinatorManager coordinatorManager(String protocol) throws ProtocolNotRegisteredException, SystemException {
try {
SagasHLS coordHLS;
synchronized (_implementations) {
coordHLS = (SagasHLS) _implementations.get(protocol);
if (coordHLS == null) {
coordHLS = (SagasHLS) _protocolManager.getProtocolImplementation(protocol);
_implementations.put(protocol, coordHLS);
}
}
return coordHLS.coordinatorManager();
} catch (ProtocolNotRegisteredException ex) {
throw ex;
} catch (Exception ex) {
throw new SystemException(ex.toString());
}
}
use of com.arjuna.mw.wsas.exceptions.SystemException in project narayana by jbosstm.
the class CoordinatorManagerFactory method coordinatorManager.
/**
* Obtain a reference to a coordinator that implements the specified
* protocol.
*
* @param protocol The XML definition of the type of
* coordination protocol required.
*
* @exception com.arjuna.mw.wscf.exceptions.ProtocolNotRegisteredException Thrown if the requested
* protocol is not available.
*
* @return the CoordinatorManager implementation to use.
*/
/*
* Have the type specified in XML. More data may be specified, which
* can be passed to the implementation in the same way ObjectName was.
*/
public static CoordinatorManager coordinatorManager(String protocol) throws ProtocolNotRegisteredException, SystemException {
try {
TwoPhaseHLS coordHLS;
synchronized (_implementations) {
coordHLS = (TwoPhaseHLS) _implementations.get(protocol);
if (coordHLS == null) {
coordHLS = (TwoPhaseHLS) _protocolManager.getProtocolImplementation(protocol);
_implementations.put(protocol, coordHLS);
}
return coordHLS.coordinatorManager();
}
} catch (ProtocolNotRegisteredException ex) {
throw ex;
} catch (Exception ex) {
throw new SystemException(ex.toString());
}
}
use of com.arjuna.mw.wsas.exceptions.SystemException in project narayana by jbosstm.
the class CoordinatorControl method parentCoordinator.
private final BACoordinator parentCoordinator() throws SystemException {
try {
ActivityHierarchy hier = UserActivityFactory.userActivity().currentActivity();
ActivityHandleImple parentActivity = null;
BACoordinator parentCoordinator = null;
if (hier.size() > 1) {
parentActivity = (ActivityHandleImple) hier.activity(hier.size() - 2);
parentCoordinator = (BACoordinator) _coordinators.get(parentActivity);
}
return parentCoordinator;
} catch (Exception ex) {
ex.printStackTrace();
return null;
}
}
Aggregations