use of org.omg.CORBA.BAD_OPERATION in project narayana by jbosstm.
the class ContextServerRequestInterceptorImpl method suspendContext.
/*
* If there is a thread id associated with PICurrent then it will
* have been placed there by a server-side thread which executed in
* the application object and needed to associate an imported
* transaction with itself. In which case we need to do the
* equivalent of a suspend to remove the thread from Current and
* from the current transaction.
*/
private void suspendContext(ServerRequestInfo request_info) throws SystemException, InvalidSlot {
if (jtsLogger.logger.isTraceEnabled()) {
jtsLogger.logger.trace("ContextServerRequestInterceptorImpl.suspendContext ( " + request_info.operation() + " )");
}
Any data = request_info.get_slot(_dataSlot);
if ((data != null) && (data.type().kind().value() != TCKind._tk_null)) {
String threadId = null;
try {
if ((threadId = data.extract_string()) != null) {
ControlWrapper ctx = OTSImpleManager.current().contextManager().popAction(threadId);
OTSImpleManager.current().contextManager().purgeActions(threadId);
if (ctx != null) {
try {
OTSManager.destroyControl(ctx.getControl());
ctx = null;
} catch (Exception e) {
jtsLogger.i18NLogger.warn_orbspecific_jacorb_interceptors_context_srie("ContextServerRequestInterceptorImpl.suspendContext", e);
throw new UNKNOWN(e.toString());
}
}
}
} catch (BAD_OPERATION be) {
// not a string, so still a pgctx
}
request_info.set_slot(_dataSlot, null);
}
}
use of org.omg.CORBA.BAD_OPERATION in project narayana by jbosstm.
the class ServerNestedActionUnitTest method test.
@Test
public void test() throws Exception {
ControlImple cont = new ControlImple(null, null);
Control theControl = cont.getControl();
ArjunaTransactionImple tx = cont.getImplHandle();
ServerControl sc = new ServerControl(tx.get_uid(), theControl, tx, theControl.get_coordinator(), theControl.get_terminator());
ServerNestedAction act = new ServerNestedAction(sc);
try {
act.prepare();
fail();
} catch (final BAD_OPERATION ex) {
}
act.commit();
act.rollback();
act.commit_one_phase();
assertTrue(act.theResource() != null);
}
use of org.omg.CORBA.BAD_OPERATION in project narayana by jbosstm.
the class POABase method destroyPOA.
public void destroyPOA(String adapterName) throws SystemException {
if (adapterName == null)
throw new BAD_PARAM();
org.omg.PortableServer.POA childPoa = (org.omg.PortableServer.POA) _poas.remove(adapterName);
if (childPoa != null) {
childPoa.destroy(true, true);
childPoa = null;
} else
throw new BAD_OPERATION();
}
use of org.omg.CORBA.BAD_OPERATION in project narayana by jbosstm.
the class Client04 method main.
public static void main(String[] args) {
try {
ORBInterface.initORB(args, null);
OAInterface.initOA();
TransactionFactory transactionFactory = null;
String[] transactionFactoryParams = new String[1];
transactionFactoryParams[0] = ORBServices.otsKind;
transactionFactory = TransactionFactoryHelper.narrow(ORBServices.getService(ORBServices.transactionService, transactionFactoryParams));
boolean correct;
Control control = transactionFactory.create(4);
Thread.sleep(8000);
try {
control.get_terminator().commit(true);
correct = false;
} catch (INVALID_TRANSACTION invalidTransaction) {
correct = true;
} catch (BAD_OPERATION badOperation) {
correct = true;
} catch (org.omg.CORBA.OBJECT_NOT_EXIST object_not_exist_exception) {
// This test creates a transaction with timeout period of 4 seconds then
// sleeps for 8 seconds.
// When the timeout goes off at the transaction service, the transaction is
// rolled back and destroyed.
// The subsequent call to commit on the transaction results in an
// org.omg.CORBA.OBJECT_NOT_EXIST exception being thrown.
// The JTS specification appears to be quite vague in this area, however our
// implementation is compliant with this vagueness.
// Hence, For the purposes of this test, org.omg.CORBA.OBJECT_NOT_EXIST being thrown
// does not indicate a failure - BD 20/06/01
correct = true;
} catch (Exception exception) {
System.err.println("Client04.main: commit exception = " + exception);
correct = false;
}
if (correct) {
System.out.println("Passed");
} else {
System.out.println("Failed");
}
} catch (Exception exception) {
System.out.println("Failed");
System.err.println("Client04.main: " + exception);
exception.printStackTrace(System.err);
}
try {
OAInterface.shutdownOA();
ORBInterface.shutdownORB();
} catch (Exception exception) {
System.err.println("Client04.main: " + exception);
exception.printStackTrace(System.err);
}
}
use of org.omg.CORBA.BAD_OPERATION in project narayana by jbosstm.
the class Client06 method main.
public static void main(String[] args) {
try {
ORBInterface.initORB(args, null);
OAInterface.initOA();
TransactionFactory transactionFactory = null;
String[] transactionFactoryParams = new String[1];
transactionFactoryParams[0] = ORBServices.otsKind;
transactionFactory = TransactionFactoryHelper.narrow(ORBServices.getService(ORBServices.transactionService, transactionFactoryParams));
boolean correct;
Control control = transactionFactory.create(4);
Thread.sleep(8000);
try {
control.get_terminator().rollback();
correct = false;
} catch (INVALID_TRANSACTION invalidTransaction) {
correct = true;
} catch (BAD_OPERATION badOperation) {
correct = true;
} catch (org.omg.CORBA.OBJECT_NOT_EXIST object_not_exist_exception) {
// This test creates a transaction with timeout period of 4 seconds then
// sleeps for 8 seconds.
// When the timeout goes off at the transaction service, the transaction is
// rolled back and destroyed.
// The subsequent call to rollback the transaction results in an
// org.omg.CORBA.OBJECT_NOT_EXIST exception being thrown.
// The JTS specification appears to be quite vague in this area, however our
// implementation is compliant with this vagueness.
// Hence, For the purposes of this test, org.omg.CORBA.OBJECT_NOT_EXIST being thrown
// does not indicate a failure - BD 20/06/01
correct = true;
} catch (Exception exception) {
System.err.println("Client06.main: rollback exception = " + exception);
correct = false;
}
if (correct) {
System.out.println("Passed");
} else {
System.out.println("Failed");
}
} catch (Exception exception) {
System.out.println("Failed");
System.err.println("Client06.main: " + exception);
exception.printStackTrace(System.err);
}
try {
OAInterface.shutdownOA();
ORBInterface.shutdownORB();
} catch (Exception exception) {
System.err.println("Client06.main: " + exception);
exception.printStackTrace(System.err);
}
}
Aggregations