use of com.arjuna.ArjunaOTS.InterpositionFailed in project narayana by jbosstm.
the class ExplicitInterposition method registerTransaction.
private final synchronized void registerTransaction(PropagationContext ctx) throws InterpositionFailed, SystemException {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ExplicitInterposition::registerTransaction ( PropagationContext ctx )");
}
if (_inUse) {
jtsLogger.i18NLogger.warn_excalledagain("ExplicitInterposition.registerTransaction");
throw new InterpositionFailed();
}
if (// invalid
(ctx == null) || (ctx.current.coord == null))
throw new INVALID_TRANSACTION(ExceptionCodes.INVALID_ACTION, CompletionStatus.COMPLETED_NO);
_inUse = true;
TransactionFactoryImple _localFactory = OTSImpleManager.factory();
try {
ControlImple cont = _localFactory.recreateLocal(ctx);
CurrentImple current = OTSImpleManager.current();
if (_remember) {
try {
_oldControl = current.suspendWrapper();
} catch (Exception e) {
throw new InterpositionFailed();
}
}
current.resumeImple(cont);
// current.resume(cont.getControl());
cont = null;
} catch (InterpositionFailed ex) {
throw ex;
} catch (Exception e) {
jtsLogger.i18NLogger.warn_eicaughtexception("ExplicitInterposition.registerTransaction(PropagationContext)", e);
throw new InterpositionFailed();
}
}
use of com.arjuna.ArjunaOTS.InterpositionFailed in project narayana by jbosstm.
the class ExplicitInterposition method registerTransaction.
/**
* Perform interposition with the specified transaction.
*/
public final synchronized void registerTransaction(Control action) throws InterpositionFailed, SystemException {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ExplicitInterposition::registerTransaction ( Control action )");
}
if (_inUse) {
jtsLogger.i18NLogger.warn_excalledagain("ExplicitInterposition.unregisterTransaction");
throw new InterpositionFailed();
}
boolean registerNull = false;
if (action != null) {
try {
Coordinator coord = action.get_coordinator();
if (coord != null) {
PropagationContext ctx = coord.get_txcontext();
if (ctx != null) {
try {
registerTransaction(ctx);
ctx = null;
} catch (Exception e) {
e.printStackTrace();
ctx = null;
throw new InterpositionFailed(e.toString());
}
} else
registerNull = true;
coord = null;
} else
registerNull = true;
} catch (Exception e) {
e.printStackTrace();
throw new InterpositionFailed(e.toString());
}
} else {
_inUse = true;
registerNull = true;
}
if (registerNull) {
try {
OTSImpleManager.current().resume((Control) null);
} catch (Exception e) {
e.printStackTrace();
throw new InterpositionFailed(e.toString());
}
}
}
use of com.arjuna.ArjunaOTS.InterpositionFailed in project narayana by jbosstm.
the class setget_i method set.
public void set(short n, Control control) throws SystemException {
System.out.println("setget_i.set " + n);
try {
if (control != null) {
ExplicitInterposition manager = new ExplicitInterposition();
manager.registerTransaction(control);
System.out.println("setget_i.set - managed to set up interposition hierarchy");
CurrentImple current = OTSImpleManager.current();
Control cont = current.get_control();
if (cont == null)
System.err.println("setget_i.set error - current returned no control!");
else {
System.out.println("setget_i.set - current returned a control!");
cont = null;
}
System.out.println("setget_i.set - beginning nested action");
current.begin();
cont = current.get_control();
if (cont != null) {
Coordinator coord = cont.get_coordinator();
System.out.println("setget_i.set - registering self");
coord.register_resource(ref);
coord = null;
cont = null;
} else
System.err.println("setget_i.set - current did not return control after begin!");
value = n;
System.out.println("setget_i.set - committing nested action");
current.commit(true);
manager.unregisterTransaction();
manager = null;
} else
System.err.println("setget_i::set error - no control!");
} catch (InterpositionFailed ex) {
System.err.println("setget_i.set - error in setting up hierarchy");
throw new UNKNOWN();
} catch (Throwable e) {
System.err.println("setget_i::set - caught exception: " + e);
}
System.out.println("setget_i.set - finished");
}
Aggregations