Search in sources :

Example 6 with BAD_OPERATION

use of org.omg.CORBA.BAD_OPERATION in project narayana by jbosstm.

the class ServerTransaction method register_synchronization.

/**
 * Registering a synchronization with interposition is a bit complicated!
 * Synchronizations must be called prior to prepare; if no
 * interposed-synchronization is used then either synchronizations would be
 * registered locally (and then ignored by the commit protocol) or they
 * would need to be registered remotely, which would mean a cross-address
 * space call for each synchronization!
 *
 * The first time a synchronization is registered locally, we register a
 * proxy back with the real coordinator. When that transaction commits, it
 * will call this proxy, which will then drive the locally registered
 * synchronizations (actually it calls appropriate on the transaction to do
 * this.)
 *
 * However, one-phase commit complicates matters even more since we call
 * commit on the interposed coordinator, which runs through the commit and
 * then the after_completion code before returning to the real coordinator's
 * commit call. Rather than separate commit and synchronization code
 * completely from the transaction (in which case we could just call the
 * commit portion here) we let after_completion get called before returning
 * the commit response, and simply ignore the real coordinator's subsequent
 * call to after_completion.
 */
public synchronized void register_synchronization(Synchronization theSync) throws Inactive, SynchronizationUnavailable, SystemException {
    if (// are we a top-level transaction?
    !is_top_level_transaction()) {
        throw new SynchronizationUnavailable();
    } else {
        if (_interposedSynch) {
            if (_sync == null) {
                _sync = new ServerSynchronization(this);
                Coordinator realCoord = null;
                try {
                    ServerControl control = (ServerControl) super.controlHandle;
                    if (controlHandle != null) {
                        realCoord = control.originalCoordinator();
                        if (realCoord != null) {
                            realCoord.register_synchronization(_sync.getSynchronization());
                        } else
                            throw new BAD_OPERATION(ExceptionCodes.NO_TRANSACTION, CompletionStatus.COMPLETED_NO);
                    } else
                        throw new BAD_OPERATION(ExceptionCodes.NO_TRANSACTION, CompletionStatus.COMPLETED_NO);
                } catch (Inactive e1) {
                    realCoord = null;
                    throw e1;
                } catch (SynchronizationUnavailable e2) {
                    realCoord = null;
                    throw e2;
                } catch (SystemException e3) {
                    realCoord = null;
                    throw e3;
                }
                realCoord = null;
            }
        }
        /*
			 * Now register the synchronization locally.
			 */
        super.register_synchronization(theSync);
    }
}
Also used : ServerControl(com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl) SystemException(org.omg.CORBA.SystemException) ServerSynchronization(com.arjuna.ats.internal.jts.orbspecific.interposition.resources.ServerSynchronization) Inactive(org.omg.CosTransactions.Inactive) BAD_OPERATION(org.omg.CORBA.BAD_OPERATION) Coordinator(org.omg.CosTransactions.Coordinator) RecoveryCoordinator(org.omg.CosTransactions.RecoveryCoordinator) SynchronizationUnavailable(org.omg.CosTransactions.SynchronizationUnavailable)

Example 7 with BAD_OPERATION

use of org.omg.CORBA.BAD_OPERATION in project narayana by jbosstm.

the class ServerTopLevelAction method forget.

public void forget() throws SystemException {
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("ServerTopLevelAction::forget for " + _theUid);
    }
    boolean forgot = true;
    if (_theControl != null)
        forgot = _theControl.forgetHeuristics();
    // causes the removal of the transaction state.
    destroyResource();
    if (!forgot)
        throw new BAD_OPERATION();
}
Also used : BAD_OPERATION(org.omg.CORBA.BAD_OPERATION)

Example 8 with BAD_OPERATION

use of org.omg.CORBA.BAD_OPERATION in project narayana by jbosstm.

the class InterpositionServerRequestInterceptorImpl 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()) {
        trace_request("suspendContext", request_info);
    }
    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);
            }
        } catch (BAD_OPERATION bex) {
        // not a string, so still a pgcts
        }
        request_info.set_slot(_dataSlot, null);
    }
}
Also used : ControlWrapper(com.arjuna.ats.internal.jts.ControlWrapper) BAD_OPERATION(org.omg.CORBA.BAD_OPERATION) Any(org.omg.CORBA.Any)

Example 9 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_javaidl_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 10 with BAD_OPERATION

use of org.omg.CORBA.BAD_OPERATION in project narayana by jbosstm.

the class InterpositionServerRequestInterceptorImpl 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()) {
        trace_request("suspendContext", request_info);
    }
    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);
            }
        } catch (BAD_OPERATION bex) {
        // not a string, so still a pgcts
        }
        request_info.set_slot(_dataSlot, null);
    }
}
Also used : ControlWrapper(com.arjuna.ats.internal.jts.ControlWrapper) BAD_OPERATION(org.omg.CORBA.BAD_OPERATION) Any(org.omg.CORBA.Any)

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