Search in sources :

Example 16 with BAD_OPERATION

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

the class CurrentImple method resume.

/**
 * To support checked transactions we can only resume if the action is local
 * or we received it implicitly.
 *
 * If the control refers to a nested transaction then we must recreate the
 * entire hierarchy, i.e., the effect of a suspend/resume on the same
 * control should be the same as never calling suspend in the first place.
 *
 * If the control is for a local transaction then it is simple to recreate
 * the hierarchy. Otherwise we rely upon the PropagationContext to recreate
 * it.
 *
 * If this control is a "proxy" then create a new proxy instance, so we can
 * delete proxies whenever suspend is called.
 *
 * Should check if "new" transaction is not actually the current one anyway.
 * If so, just return. The spec. doesn't mention what to do in this case, so
 * for now we go to the overhead of the work regardless.
 */
public void resume(Control which) throws InvalidControl, SystemException {
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("CurrentImple::resume ( " + which + " )");
    }
    /*
		 * We must now "forget" any current transaction information. This is
		 * because when we end this transaction we must be associated with no
		 * transaction.
		 */
    _theManager.purgeActions();
    if (// if null then return
    which == null) {
        ThreadAssociationControl.updateAssociation(null, TX_RESUMED);
        return;
    }
    /*
		 * Must duplicate because it is an 'in' parameter which we want to keep.
		 */
    org.omg.CosTransactions.Control cont = which;
    boolean invalidControl = false;
    try {
        Coordinator coord = cont.get_coordinator();
        if (!coord.is_top_level_transaction()) {
            /*
				 * Is the Control an ActionControl? If so then it has methods to
				 * allow us to get the parent directly. Otherwise, rely on the
				 * PropagationContext.
				 */
            ActionControl actControl = null;
            try {
                actControl = com.arjuna.ArjunaOTS.ActionControlHelper.narrow(cont);
                if (actControl == null)
                    throw new BAD_PARAM();
            } catch (Exception e) {
                /*
					 * Not an ActionControl.
					 */
                actControl = null;
            }
            if (actControl != null) {
                invalidControl = _theManager.addActionControlHierarchy(actControl);
            } else {
                invalidControl = _theManager.addRemoteHierarchy(cont);
            }
        }
        coord = null;
    } catch (OBJECT_NOT_EXIST one) {
    // throw new InvalidControl();
    } catch (// JacORB 1.4.5 bug
    UNKNOWN ue) {
    } catch (// JacORB 2.0 beta 2 bug
    org.omg.CORBA.OBJ_ADAPTER oae) {
    } catch (SystemException sysEx) {
        throw new InvalidControl();
    } catch (UserException usrEx) {
        throw new InvalidControl();
    } catch (NullPointerException npx) {
        throw new InvalidControl();
    } catch (Exception ex) {
        throw new BAD_OPERATION("CurrentImple.resume: " + ex.toString());
    }
    try {
        if (!invalidControl) {
            ControlWrapper wrap = new ControlWrapper(cont);
            ThreadAssociationControl.updateAssociation(wrap, TX_RESUMED);
            _theManager.pushAction(wrap);
        }
    } catch (NullPointerException npx) {
        invalidControl = true;
    }
    cont = null;
    if (invalidControl)
        throw new InvalidControl();
}
Also used : Control(org.omg.CosTransactions.Control) BAD_PARAM(org.omg.CORBA.BAD_PARAM) Coordinator(org.omg.CosTransactions.Coordinator) SystemException(org.omg.CORBA.SystemException) UserException(org.omg.CORBA.UserException) InvalidControl(org.omg.CosTransactions.InvalidControl) ActionControl(com.arjuna.ArjunaOTS.ActionControl) OBJECT_NOT_EXIST(org.omg.CORBA.OBJECT_NOT_EXIST) SystemException(org.omg.CORBA.SystemException) ControlWrapper(com.arjuna.ats.internal.jts.ControlWrapper) UNKNOWN(org.omg.CORBA.UNKNOWN) UserException(org.omg.CORBA.UserException) BAD_OPERATION(org.omg.CORBA.BAD_OPERATION)

Example 17 with BAD_OPERATION

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

the class ServerNestedAction method commit_subtransaction.

public void commit_subtransaction(Coordinator parent) throws SystemException {
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("ServerNestedAction::commit_subtransaction : " + _theUid);
    }
    if (_theControl == null) {
        jtsLogger.i18NLogger.warn_orbspecific_interposition_resources_arjuna_nullcontrol_1("ServerNestedAction.commit_subtransaction");
        throw new INVALID_TRANSACTION(ExceptionCodes.SERVERAA_NO_CONTROL, CompletionStatus.COMPLETED_NO);
    }
    if (_theControl.isWrapper()) {
        destroyResource();
        return;
    }
    ServerTransaction theTransaction = (ServerTransaction) _theControl.getImplHandle();
    try {
        theTransaction.commit(false);
    } catch (TRANSACTION_ROLLEDBACK e1) {
        jtsLogger.i18NLogger.warn_orbspecific_interposition_resources_arjuna_generror_2("ServerNestedAction.commit_subtransaction", e1);
        throw e1;
    } catch (INVALID_TRANSACTION e5) {
        jtsLogger.i18NLogger.warn_orbspecific_interposition_resources_arjuna_generror_2("ServerNestedAction.commit_subtransaction", e5);
        throw e5;
    } catch (HeuristicMixed e2) {
        jtsLogger.i18NLogger.warn_orbspecific_interposition_resources_arjuna_generror_2("ServerNestedAction.commit_subtransaction", e2);
        throw new BAD_OPERATION(ExceptionCodes.HEURISTIC_COMMIT, CompletionStatus.COMPLETED_MAYBE);
    } catch (HeuristicHazard e3) {
        jtsLogger.i18NLogger.warn_orbspecific_interposition_resources_arjuna_generror_2("ServerNestedAction.commit_subtransaction", e3);
        throw new BAD_OPERATION(ExceptionCodes.HEURISTIC_COMMIT, CompletionStatus.COMPLETED_MAYBE);
    } catch (SystemException e4) {
        jtsLogger.i18NLogger.warn_orbspecific_interposition_resources_arjuna_generror_2("ServerNestedAction.commit_subtransaction", e4);
        throw e4;
    } catch (Exception e5) {
        jtsLogger.i18NLogger.warn_orbspecific_interposition_resources_arjuna_generror_2("ServerNestedAction.commit_subtransaction", e5);
        throw new UNKNOWN(e5.toString());
    } finally {
        ThreadActionData.popAction();
        destroyResource();
    }
}
Also used : SystemException(org.omg.CORBA.SystemException) INVALID_TRANSACTION(org.omg.CORBA.INVALID_TRANSACTION) BAD_OPERATION(org.omg.CORBA.BAD_OPERATION) UNKNOWN(org.omg.CORBA.UNKNOWN) ServerTransaction(com.arjuna.ats.internal.jts.orbspecific.interposition.coordinator.ServerTransaction) TRANSACTION_ROLLEDBACK(org.omg.CORBA.TRANSACTION_ROLLEDBACK) HeuristicMixed(org.omg.CosTransactions.HeuristicMixed) HeuristicHazard(org.omg.CosTransactions.HeuristicHazard) SystemException(org.omg.CORBA.SystemException)

Example 18 with BAD_OPERATION

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

the class ServerSynchronization method after_completion.

public void after_completion(org.omg.CosTransactions.Status status) throws SystemException {
    if (_theTransaction == null) {
        destroy();
        throw new BAD_OPERATION(ExceptionCodes.NO_TRANSACTION, CompletionStatus.COMPLETED_NO);
    } else {
        /*
			 * Check that the given status is the same as our status. It should
			 * be!
			 */
        org.omg.CosTransactions.Status myStatus = org.omg.CosTransactions.Status.StatusUnknown;
        try {
            myStatus = _theTransaction.get_status();
        } catch (Exception e) {
            myStatus = org.omg.CosTransactions.Status.StatusUnknown;
        }
        if (myStatus != status) {
            jtsLogger.i18NLogger.warn_orbspecific_interposition_resources_stateerror("ServerSynchronization.after_completion", Utility.stringStatus(myStatus), Utility.stringStatus(status));
            if (myStatus == Status.StatusActive) {
                try {
                    _theTransaction.rollback();
                } catch (Exception e) {
                }
                try {
                    status = _theTransaction.get_status();
                } catch (Exception e) {
                    status = Status.StatusUnknown;
                }
            }
        }
        _theTransaction.doAfterCompletion(status);
    }
    /*
		 * Now dispose of self.
		 */
    destroy();
}
Also used : Status(org.omg.CosTransactions.Status) BAD_OPERATION(org.omg.CORBA.BAD_OPERATION) SystemException(org.omg.CORBA.SystemException)

Example 19 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.systemCurrent().contextManager().popAction(threadId);
                ControlWrapper ctx = OTSImpleManager.current().contextManager().popAction(threadId);
                // OTSImpleManager.systemCurrent().contextManager().purgeActions(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 20 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)

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