use of org.omg.CosTransactions.Coordinator in project narayana by jbosstm.
the class grid_i method set.
public void set(int n, int m, int value, Control cp) throws SystemException {
try {
Coordinator co = cp.get_coordinator();
if (co != null)
co.register_resource(ref);
else
System.err.println("Error - no transaction coordinator!");
m_a[n][m] = value;
} catch (UserException e) {
throw new UNKNOWN();
} catch (SystemException e) {
throw new UNKNOWN();
}
}
use of org.omg.CosTransactions.Coordinator in project narayana by jbosstm.
the class BaseTransaction method checkTransactionState.
/**
* Called when we want to make sure this thread does not already have a
* transaction associated with it.
*/
final void checkTransactionState() throws IllegalStateException, javax.transaction.SystemException {
try {
Control cont = OTSManager.get_current().get_control();
if (cont != null) {
Coordinator coord = cont.get_coordinator();
if (coord != null) {
if ((coord.get_status() == org.omg.CosTransactions.Status.StatusActive) && (!_supportSubtransactions)) {
throw new IllegalStateException("BaseTransaction.checkTransactionState - " + jtaxLogger.i18NLogger.get_jtax_transaction_jts_alreadyassociated());
}
}
cont = null;
}
} catch (org.omg.CORBA.SystemException e1) {
javax.transaction.SystemException systemException = new javax.transaction.SystemException(e1.toString());
systemException.initCause(e1);
throw systemException;
} catch (org.omg.CosTransactions.Unavailable e2) {
// ok, no transaction currently associated with thread.
} catch (NullPointerException ex) {
// ok, no transaction currently associated with thread.
}
}
use of org.omg.CosTransactions.Coordinator in project narayana by jbosstm.
the class ControlWrapper method register_synchronization.
public final void register_synchronization(Synchronization sync) throws Inactive, SynchronizationUnavailable, SystemException {
try {
if (_controlImpl != null)
_controlImpl.getImplHandle().register_synchronization(sync);
else {
try {
Coordinator coord = _control.get_coordinator();
coord.register_synchronization(sync);
} catch (final Unavailable e2) {
throw new Inactive();
} catch (final Exception e3) {
throw new UNKNOWN();
}
}
} catch (final NullPointerException e1) {
throw new Inactive();
}
}
use of org.omg.CosTransactions.Coordinator in project narayana by jbosstm.
the class CurrentImple method resume.
/**
* To support checked transactions we can only resume if the action is local
* or we received it implicitly.
*
* If the control refers to a nested transaction then we must recreate the
* entire hierarchy, i.e., the effect of a suspend/resume on the same
* control should be the same as never calling suspend in the first place.
*
* If the control is for a local transaction then it is simple to recreate
* the hierarchy. Otherwise we rely upon the PropagationContext to recreate
* it.
*
* If this control is a "proxy" then create a new proxy instance, so we can
* delete proxies whenever suspend is called.
*
* Should check if "new" transaction is not actually the current one anyway.
* If so, just return. The spec. doesn't mention what to do in this case, so
* for now we go to the overhead of the work regardless.
*/
public void resume(Control which) throws InvalidControl, SystemException {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("CurrentImple::resume ( " + which + " )");
}
/*
* We must now "forget" any current transaction information. This is
* because when we end this transaction we must be associated with no
* transaction.
*/
_theManager.purgeActions();
if (// if null then return
which == null) {
ThreadAssociationControl.updateAssociation(null, TX_RESUMED);
return;
}
/*
* Must duplicate because it is an 'in' parameter which we want to keep.
*/
org.omg.CosTransactions.Control cont = which;
boolean invalidControl = false;
try {
Coordinator coord = cont.get_coordinator();
if (!coord.is_top_level_transaction()) {
/*
* Is the Control an ActionControl? If so then it has methods to
* allow us to get the parent directly. Otherwise, rely on the
* PropagationContext.
*/
ActionControl actControl = null;
try {
actControl = com.arjuna.ArjunaOTS.ActionControlHelper.narrow(cont);
if (actControl == null)
throw new BAD_PARAM();
} catch (Exception e) {
/*
* Not an ActionControl.
*/
actControl = null;
}
if (actControl != null) {
invalidControl = _theManager.addActionControlHierarchy(actControl);
} else {
invalidControl = _theManager.addRemoteHierarchy(cont);
}
}
coord = null;
} catch (OBJECT_NOT_EXIST one) {
// throw new InvalidControl();
} catch (// JacORB 1.4.5 bug
UNKNOWN ue) {
} catch (// JacORB 2.0 beta 2 bug
org.omg.CORBA.OBJ_ADAPTER oae) {
} catch (SystemException sysEx) {
throw new InvalidControl();
} catch (UserException usrEx) {
throw new InvalidControl();
} catch (NullPointerException npx) {
throw new InvalidControl();
} catch (Exception ex) {
throw new BAD_OPERATION("CurrentImple.resume: " + ex.toString());
}
try {
if (!invalidControl) {
ControlWrapper wrap = new ControlWrapper(cont);
ThreadAssociationControl.updateAssociation(wrap, TX_RESUMED);
_theManager.pushAction(wrap);
}
} catch (NullPointerException npx) {
invalidControl = true;
}
cont = null;
if (invalidControl)
throw new InvalidControl();
}
use of org.omg.CosTransactions.Coordinator in project narayana by jbosstm.
the class OSIInterposition method createHierarchy.
protected synchronized ControlImple createHierarchy(PropagationContext ctx, Uid currentUid) throws SystemException {
/*
* Start at the parent and work our way down to "current". The current
* transaction is not in the IDL sequence, but sent as separate field
* of the propagation context. This tends to make the code more
* complex than it would be if the entire hierarchy was represented in
* one place.
*/
/*
* We only ever register the current transaction with its parent, and
* as each transaction commits, it registers its parent with the
* "real" parent.
*/
int depth = ctx.parents.length;
ServerResource action = null;
Coordinator tmpCoord = null;
Terminator tmpTerm = null;
if (depth == 0) {
tmpCoord = ctx.current.coord;
tmpTerm = ctx.current.term;
} else {
tmpCoord = ctx.parents[depth - 1].coord;
tmpTerm = ctx.parents[depth - 1].term;
}
if (// terminator may correctly be NULL
tmpCoord == null) {
return null;
}
ServerControl control = ServerFactory.create_transaction(currentUid, null, null, tmpCoord, tmpTerm, ctx.timeout);
action = new ServerOSITopLevelAction(control, ((depth == 0) ? true : false));
if (!action.valid()) {
try {
// does dispose as well!
((ServerOSITopLevelAction) action).rollback();
action = null;
} catch (Exception e) {
}
throw new TRANSACTION_ROLLEDBACK();
}
ServerTopLevelAction newElement = (ServerOSITopLevelAction) action;
_head.add(newElement);
if (// current is a nested transaction
depth > 0) {
/*
* Now deal with any nested transactions.
* As we create, register with the original transactions.
*/
ServerResource nestedAction = null;
for (int i = depth - 2; i >= 0; i--) {
tmpCoord = ctx.parents[i].coord;
tmpTerm = ctx.parents[i].term;
control = ServerFactory.create_subtransaction(OTIDMap.find(ctx.parents[i].otid), tmpCoord, tmpTerm, control);
// not current, so don't register
nestedAction = new ServerOSINestedAction(control, false);
if (!nestedAction.valid()) {
try {
// does dispose as well!
((ServerOSINestedAction) nestedAction).rollback_subtransaction();
nestedAction = null;
} catch (Exception e) {
}
throw new TRANSACTION_ROLLEDBACK();
}
/*
* Add transaction resource to list.
*/
action.addChild((ServerOSINestedAction) nestedAction);
action = nestedAction;
}
/*
* Now deal with current transaction. If there is
* only one transaction we do nothing.
*/
tmpCoord = ctx.current.coord;
tmpTerm = ctx.current.term;
control = ServerFactory.create_subtransaction(OTIDMap.find(ctx.current.otid), tmpCoord, tmpTerm, control);
// current, so register
nestedAction = new ServerOSINestedAction(control, true);
if (!nestedAction.valid()) {
try {
// does dispose as well!
((ServerOSINestedAction) nestedAction).rollback_subtransaction();
nestedAction = null;
} catch (Exception e) {
}
throw new TRANSACTION_ROLLEDBACK();
}
action.addChild((ServerOSINestedAction) nestedAction);
}
if (jtsLogger.logger.isTraceEnabled())
compareHierarchies(ctx, newElement);
return control;
}
Aggregations