Search in sources :

Example 21 with BAD_OPERATION

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);
    }
}
Also used : ControlWrapper(com.arjuna.ats.internal.jts.ControlWrapper) UNKNOWN(org.omg.CORBA.UNKNOWN) BAD_OPERATION(org.omg.CORBA.BAD_OPERATION) Any(org.omg.CORBA.Any) SystemException(org.omg.CORBA.SystemException)

Example 22 with BAD_OPERATION

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);
}
Also used : Control(org.omg.CosTransactions.Control) ServerControl(com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl) ServerControl(com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl) ArjunaTransactionImple(com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple) ServerNestedAction(com.arjuna.ats.internal.jts.orbspecific.interposition.resources.arjuna.ServerNestedAction) BAD_OPERATION(org.omg.CORBA.BAD_OPERATION) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple) Test(org.junit.Test)

Example 23 with BAD_OPERATION

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();
}
Also used : BAD_PARAM(org.omg.CORBA.BAD_PARAM) BAD_OPERATION(org.omg.CORBA.BAD_OPERATION)

Example 24 with 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);
    }
}
Also used : Control(org.omg.CosTransactions.Control) INVALID_TRANSACTION(org.omg.CORBA.INVALID_TRANSACTION) TransactionFactory(org.omg.CosTransactions.TransactionFactory) BAD_OPERATION(org.omg.CORBA.BAD_OPERATION)

Example 25 with BAD_OPERATION

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);
    }
}
Also used : Control(org.omg.CosTransactions.Control) INVALID_TRANSACTION(org.omg.CORBA.INVALID_TRANSACTION) TransactionFactory(org.omg.CosTransactions.TransactionFactory) BAD_OPERATION(org.omg.CORBA.BAD_OPERATION)

Aggregations

BAD_OPERATION (org.omg.CORBA.BAD_OPERATION)26 SystemException (org.omg.CORBA.SystemException)11 ControlWrapper (com.arjuna.ats.internal.jts.ControlWrapper)8 Any (org.omg.CORBA.Any)6 UNKNOWN (org.omg.CORBA.UNKNOWN)6 INVALID_TRANSACTION (org.omg.CORBA.INVALID_TRANSACTION)5 Control (org.omg.CosTransactions.Control)4 OutputStream (org.omg.CORBA.portable.OutputStream)3 Coordinator (org.omg.CosTransactions.Coordinator)3 ServerControl (com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl)2 ServerSynchronization (com.arjuna.ats.internal.jts.orbspecific.interposition.resources.ServerSynchronization)2 InterceptorContext (org.jboss.invocation.InterceptorContext)2 BAD_PARAM (org.omg.CORBA.BAD_PARAM)2 NO_IMPLEMENT (org.omg.CORBA.NO_IMPLEMENT)2 InputStream (org.omg.CORBA.portable.InputStream)2 UnknownException (org.omg.CORBA.portable.UnknownException)2 Inactive (org.omg.CosTransactions.Inactive)2 RecoveryCoordinator (org.omg.CosTransactions.RecoveryCoordinator)2 SynchronizationUnavailable (org.omg.CosTransactions.SynchronizationUnavailable)2 TransactionFactory (org.omg.CosTransactions.TransactionFactory)2