Search in sources :

Example 21 with UNKNOWN

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

the class ContextClientRequestInterceptorImpl method send_request.

public void send_request(ClientRequestInfo request_info) throws SystemException {
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("ContextClientRequestInterceptorImpl::send_request ( " + request_info + " )");
    }
    if (systemCall(request_info))
        return;
    final boolean otsAlwaysPropagate = InterceptorInfo.getAlwaysPropagate();
    try {
        if (!otsAlwaysPropagate) {
            TransactionalObject ptr = TransactionalObjectHelper.narrow(request_info.target());
            if (ptr == null)
                throw new BAD_PARAM();
        } else {
            /**
             * If the value is not null then we are currently in use *
             */
            if (_inUse.get() != null) {
                return;
            } else {
                _inUse.set(_inUse);
            }
        }
        try {
            /*
		 * We get back an Any, which contains a key which we must
		 * now use to get the actual transaction context. This
		 * saves use having to pack and unpack the context every
		 * time it changes, even if we don't then make a remote
		 * invocation.
		 */
            Any localData = request_info.get_slot(_localSlot);
            String threadId = null;
            boolean problem = false;
            String stringRef = null;
            if (localData.type().kind().value() != TCKind._tk_null) {
                if ((threadId = localData.extract_string()) == null)
                    throw new UNKNOWN(jtsLogger.i18NLogger.get_orbspecific_javaidl_interceptors_context_invalidparam());
            } else
                threadId = ThreadUtil.getThreadId();
            if (threadId != null) {
                ControlWrapper theControl = OTSImpleManager.current().contextManager().current(threadId);
                if (theControl != null) {
                    try {
                        Coordinator theCoordinator = theControl.get_coordinator();
                        if (theCoordinator != null) {
                            stringRef = ORBManager.getORB().orb().object_to_string(theCoordinator);
                        } else {
                            problem = true;
                        }
                    } catch (Unavailable e) {
                        problem = true;
                    }
                    theControl = null;
                } else
                    problem = true;
            } else
                problem = true;
            if (problem) {
                if (InterceptorInfo.getNeedTranContext())
                    throw new TRANSACTION_REQUIRED();
                else
                    stringRef = null;
            }
            if (stringRef != null) {
                Any data = ORBManager.getORB().orb().create_any();
                data.insert_string(stringRef);
                byte[] octets = _codec.encode_value(data);
                ServiceContext service_context = new ServiceContext(OTSManager.serviceId, octets);
                request_info.add_request_service_context(service_context, true);
            }
        } catch (SystemException e) {
            throw e;
        } catch (Exception ex) {
            jtsLogger.i18NLogger.warn_orbspecific_javaidl_interceptors_context_error(ex);
            throw new UNKNOWN(ex.toString());
        } finally {
            /**
             * If we are set to always propagate then ensure we clear the inuse flag *
             */
            if (otsAlwaysPropagate) {
                _inUse.set(null);
            }
        }
    } catch (BAD_PARAM ex) {
    // narrow failed, so not a transactional object.
    }
}
Also used : ServiceContext(org.omg.IOP.ServiceContext) BAD_PARAM(org.omg.CORBA.BAD_PARAM) Coordinator(org.omg.CosTransactions.Coordinator) Any(org.omg.CORBA.Any) SystemException(org.omg.CORBA.SystemException) Unavailable(org.omg.CosTransactions.Unavailable) SystemException(org.omg.CORBA.SystemException) ControlWrapper(com.arjuna.ats.internal.jts.ControlWrapper) TransactionalObject(org.omg.CosTransactions.TransactionalObject) UNKNOWN(org.omg.CORBA.UNKNOWN) TRANSACTION_REQUIRED(org.omg.CORBA.TRANSACTION_REQUIRED)

Example 22 with UNKNOWN

use of org.omg.CORBA.UNKNOWN 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 23 with UNKNOWN

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

the class ContextClientRequestInterceptorImpl method send_request.

public void send_request(ClientRequestInfo request_info) throws SystemException {
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("ContextClientRequestInterceptorImpl::send_request ( " + request_info + " )");
    }
    if (systemCall(request_info))
        return;
    final boolean otsAlwaysPropagate = InterceptorInfo.getAlwaysPropagate();
    try {
        if (!otsAlwaysPropagate) {
            TransactionalObject ptr = TransactionalObjectHelper.narrow(request_info.target());
            if (ptr == null)
                throw new BAD_PARAM();
        } else {
            /**
             * If the value is not null then we are currently in use *
             */
            if (_inUse.get() != null) {
                return;
            } else {
                _inUse.set(_inUse);
            }
        }
        try {
            /*
		 * We get back an Any, which contains a key which we must
		 * now use to get the actual transaction context. This
		 * saves use having to pack and unpack the context every
		 * time it changes, even if we don't then make a remote
		 * invocation.
		 */
            Any localData = request_info.get_slot(_localSlot);
            String threadId = null;
            boolean problem = false;
            String stringRef = null;
            if (localData.type().kind().value() != TCKind._tk_null) {
                if ((threadId = localData.extract_string()) == null)
                    throw new UNKNOWN(jtsLogger.i18NLogger.get_orbspecific_javaidl_interceptors_context_invalidparam());
            } else
                threadId = ThreadUtil.getThreadId();
            if (threadId != null) {
                ControlWrapper theControl = OTSImpleManager.current().contextManager().current(threadId);
                if (theControl != null) {
                    try {
                        Coordinator theCoordinator = theControl.get_coordinator();
                        if (theCoordinator != null) {
                            stringRef = ORBManager.getORB().orb().object_to_string(theCoordinator);
                        } else {
                            problem = true;
                        }
                    } catch (Unavailable e) {
                        problem = true;
                    }
                    theControl = null;
                } else
                    problem = true;
            } else
                problem = true;
            if (problem) {
                if (InterceptorInfo.getNeedTranContext())
                    throw new TRANSACTION_REQUIRED();
                else
                    stringRef = null;
            }
            if (stringRef != null) {
                Any data = ORBManager.getORB().orb().create_any();
                data.insert_string(stringRef);
                byte[] octets = _codec.encode_value(data);
                ServiceContext service_context = new ServiceContext(OTSManager.serviceId, octets);
                request_info.add_request_service_context(service_context, true);
            }
        } catch (SystemException e) {
            throw e;
        } catch (Exception ex) {
            jtsLogger.i18NLogger.warn_orbspecific_javaidl_interceptors_context_error(ex);
            throw new UNKNOWN(ex.toString());
        } finally {
            /**
             * If we are set to always propagate then ensure we clear the inuse flag *
             */
            if (otsAlwaysPropagate) {
                _inUse.set(null);
            }
        }
    } catch (BAD_PARAM ex) {
    // narrow failed, so not a transactional object.
    }
}
Also used : ServiceContext(org.omg.IOP.ServiceContext) BAD_PARAM(org.omg.CORBA.BAD_PARAM) Coordinator(org.omg.CosTransactions.Coordinator) Any(org.omg.CORBA.Any) SystemException(org.omg.CORBA.SystemException) Unavailable(org.omg.CosTransactions.Unavailable) SystemException(org.omg.CORBA.SystemException) ControlWrapper(com.arjuna.ats.internal.jts.ControlWrapper) TransactionalObject(org.omg.CosTransactions.TransactionalObject) UNKNOWN(org.omg.CORBA.UNKNOWN) TRANSACTION_REQUIRED(org.omg.CORBA.TRANSACTION_REQUIRED)

Example 24 with UNKNOWN

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

the class ControlWrapper method register_subtran_aware.

public final void register_subtran_aware(SubtransactionAwareResource sr) throws Inactive, NotSubtransaction, SystemException {
    try {
        if (_controlImpl != null)
            _controlImpl.getImplHandle().register_subtran_aware(sr);
        else {
            try {
                Coordinator coord = _control.get_coordinator();
                coord.register_subtran_aware(sr);
            } catch (Unavailable e2) {
                throw new Inactive();
            } catch (SystemException e3) {
                throw new UNKNOWN();
            } catch (final NullPointerException ex) {
                throw new UNKNOWN();
            }
        }
    } catch (NullPointerException e1) {
        throw new Inactive();
    }
}
Also used : SystemException(org.omg.CORBA.SystemException) Inactive(org.omg.CosTransactions.Inactive) UNKNOWN(org.omg.CORBA.UNKNOWN) UidCoordinator(com.arjuna.ArjunaOTS.UidCoordinator) Coordinator(org.omg.CosTransactions.Coordinator) SynchronizationUnavailable(org.omg.CosTransactions.SynchronizationUnavailable) SubtransactionsUnavailable(org.omg.CosTransactions.SubtransactionsUnavailable) Unavailable(org.omg.CosTransactions.Unavailable)

Example 25 with UNKNOWN

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

the class grid_i method set.

public void set(int n, int m, int value, Control cp) throws SystemException {
    try {
        Coordinator co = cp.get_coordinator();
        if (co != null)
            co.register_resource(ref);
        else
            System.err.println("Error - no transaction coordinator!");
        m_a[n][m] = value;
    } catch (UserException e) {
        throw new UNKNOWN();
    } catch (SystemException e) {
        throw new UNKNOWN();
    }
}
Also used : SystemException(org.omg.CORBA.SystemException) UserException(org.omg.CORBA.UserException) UNKNOWN(org.omg.CORBA.UNKNOWN) Coordinator(org.omg.CosTransactions.Coordinator)

Aggregations

UNKNOWN (org.omg.CORBA.UNKNOWN)51 SystemException (org.omg.CORBA.SystemException)32 BAD_PARAM (org.omg.CORBA.BAD_PARAM)27 Coordinator (org.omg.CosTransactions.Coordinator)15 ControlWrapper (com.arjuna.ats.internal.jts.ControlWrapper)14 AcsJNoPermissionEx (alma.maciErrType.wrappers.AcsJNoPermissionEx)13 BadParametersException (com.cosylab.acs.maci.BadParametersException)13 CoreException (com.cosylab.acs.maci.CoreException)13 NoResourcesException (com.cosylab.acs.maci.NoResourcesException)13 NO_RESOURCES (org.omg.CORBA.NO_RESOURCES)12 Unavailable (org.omg.CosTransactions.Unavailable)11 Any (org.omg.CORBA.Any)9 Object (org.omg.CORBA.Object)8 URI (java.net.URI)7 URISyntaxException (java.net.URISyntaxException)7 AcsJCannotGetComponentEx (alma.maciErrType.wrappers.AcsJCannotGetComponentEx)6 BAD_OPERATION (org.omg.CORBA.BAD_OPERATION)6 INVALID_TRANSACTION (org.omg.CORBA.INVALID_TRANSACTION)6 TRANSACTION_REQUIRED (org.omg.CORBA.TRANSACTION_REQUIRED)6 TRANSACTION_ROLLEDBACK (org.omg.CORBA.TRANSACTION_ROLLEDBACK)6