Search in sources :

Example 1 with InterpositionFailed

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();
    }
}
Also used : InterpositionFailed(com.arjuna.ArjunaOTS.InterpositionFailed) INVALID_TRANSACTION(org.omg.CORBA.INVALID_TRANSACTION) TransactionFactoryImple(com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple) CurrentImple(com.arjuna.ats.internal.jts.orbspecific.CurrentImple) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple) SystemException(org.omg.CORBA.SystemException)

Example 2 with 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());
        }
    }
}
Also used : InterpositionFailed(com.arjuna.ArjunaOTS.InterpositionFailed) PropagationContext(org.omg.CosTransactions.PropagationContext) Coordinator(org.omg.CosTransactions.Coordinator) SystemException(org.omg.CORBA.SystemException)

Example 3 with InterpositionFailed

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");
}
Also used : Control(org.omg.CosTransactions.Control) InterpositionFailed(com.arjuna.ArjunaOTS.InterpositionFailed) ExplicitInterposition(com.arjuna.ats.jts.ExplicitInterposition) UNKNOWN(org.omg.CORBA.UNKNOWN) CurrentImple(com.arjuna.ats.internal.jts.orbspecific.CurrentImple) Coordinator(org.omg.CosTransactions.Coordinator)

Aggregations

InterpositionFailed (com.arjuna.ArjunaOTS.InterpositionFailed)3 CurrentImple (com.arjuna.ats.internal.jts.orbspecific.CurrentImple)2 SystemException (org.omg.CORBA.SystemException)2 Coordinator (org.omg.CosTransactions.Coordinator)2 ControlImple (com.arjuna.ats.internal.jts.orbspecific.ControlImple)1 TransactionFactoryImple (com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple)1 ExplicitInterposition (com.arjuna.ats.jts.ExplicitInterposition)1 INVALID_TRANSACTION (org.omg.CORBA.INVALID_TRANSACTION)1 UNKNOWN (org.omg.CORBA.UNKNOWN)1 Control (org.omg.CosTransactions.Control)1 PropagationContext (org.omg.CosTransactions.PropagationContext)1