Package org.jacorb.orb.portableInterceptor

Examples of org.jacorb.orb.portableInterceptor.DefaultClientInterceptorHandler


        ReplyReceiver       receiver = null;
        final ClientInterceptorHandler interceptors;

        if (orb.hasClientRequestInterceptors())
        {
            interceptors = new DefaultClientInterceptorHandler
            (
                    (DefaultClientInterceptorHandler)localInterceptors.get(),
                    orb,
                    ros,
                    self,
View Full Code Here


        {
            if (orb.hasRequestInterceptors())
            {
                ServerRequestInfoImpl sinfo = ( (ServantObjectImpl) servant).getServerRequestInfo();

                DefaultClientInterceptorHandler interceptors =
                    ( (ServantObjectImpl) servant).getClientInterceptorHandler();

                if (sinfo != null && interceptors != null)
                {
                    Collection<ServiceContext> ctx = sinfo.getReplyServiceContexts();
                    interceptors.getInfo ().setReplyServiceContexts (ctx.toArray (new ServiceContext[ctx.size ()]));
                    orb.getInterceptorManager().removeLocalPICurrent();

                    try
                    {
                        if (sinfo.reply_status() == SUCCESSFUL.value)
                        {
                            interceptors.handle_receive_reply (null);
                        }
                        else if (sinfo.reply_status() == SYSTEM_EXCEPTION.value)
                        {
                            interceptors.handle_receive_exception (
                                SystemExceptionHelper.read (sinfo.sending_exception().create_input_stream()));
                        }
                        else if (sinfo.reply_status() == LOCATION_FORWARD.value)
                        {
                            /**
                             * If the ForwardRequest was thrown at the send_exception interception
                             * point we will not be able to get the forward_reference from the
                             * server info and a BAD_INV_ORDER will be thrown.  In that case handle
                             * as a simple receive_other.
                             */
                            try
                            {
                                interceptors.handle_location_forward (null, sinfo.forward_reference());
                            }
                            catch (BAD_INV_ORDER bio)
                            {
                                interceptors.handle_receive_other(sinfo.reply_status());
                            }
                        }
                        else if (sinfo.reply_status() == USER_EXCEPTION.value)
                        {
                            interceptors.handle_receive_other (sinfo.reply_status());
                        }
                    }
                    catch (ForwardRequest fwd)
                    {
                        throw new RuntimeException (fwd);
View Full Code Here

    {
        InterceptorManager manager = null;
        ServerInterceptorIterator interceptorIterator = null;
        ServerRequestInfoImpl sinfo = null;
        Collection<ServiceContext> contexts = null;
        DefaultClientInterceptorHandler interceptors = null;
        boolean addedContext = false;

        if (poa == null)
        {
            resolvePOA(self);
        }

        if (poa == null)
        {
            if (logger.isWarnEnabled())
            {
                logger.warn("No POA! servant_preinvoke returns null");
            }

            return null;
        }

        Map<INVOCATION_KEY, UtcT> currentContext = new HashMap<INVOCATION_KEY, UtcT>();
        currentContext.put (INVOCATION_KEY.SERVANT_PREINVOKE, null);

        invocationContext.get().push (currentContext);

        // remember that a local request is outstanding. On
        // any exit through an exception, this must be cleared again,
        // otherwise the POA will hangon destruction (bug #400).
        poa.addLocalRequest();

        final ServantObject servantObject = new ServantObjectImpl();

        ( (ServantObjectImpl) servantObject).setORB (orb);

        try
        {
            if (orb.hasClientRequestInterceptors())
            {
                interceptors = new DefaultClientInterceptorHandler(orb,
                                                                   operation,
                                                                   true,
                                                                   SYNC_WITH_TARGET.value,
                                                                   self,
                                                                   this,
                                                                   piorOriginal);
            }

            if (orb.hasRequestInterceptors() && interceptors != null)
            {
                try
                {
                    interceptors.handle_send_request();
                }
                catch (ForwardRequest fwd)
                {
                    ( (ObjectImpl) self)._set_delegate ( ( (ObjectImpl) fwd.forward)._get_delegate());
                    return null;
                }
                catch (RemarshalException re)
                {
                    // Should not happen for a local server invocation.
                }
            }

            if (interceptors != null)
            {
                contexts = interceptors.getInfo().getRequestServiceContexts();
            }

            if (orb.hasServerRequestInterceptors())
            {
                sinfo = new ServerRequestInfoImpl
                (
                    orb,
                    contexts,
                    (org.omg.PortableServer.Servant) servantObject.servant,
                    getObjectId(),
                    operation,
                    true,
                    SYNC_WITH_TARGET.value
                );

                manager = orb.getInterceptorManager();
                sinfo.setCurrent (manager.getEmptyCurrent());
                interceptorIterator = manager.getServerIterator();

                ( (org.jacorb.orb.ServantObjectImpl ) servantObject).setServerRequestInfo (sinfo);

                // Note: this code is very similar to the below hasServerRequestInterceptors try/catch
                try
                {
                   manager.setLocalPICurrent (sinfo.current ());

                   interceptorIterator.iterate
                   (
                       sinfo,
                       ServerInterceptorIterator.RECEIVE_REQUEST_SERVICE_CONTEXTS
                   );
                }
                catch (ForwardRequest fwd)
                {
                    if (interceptors != null)
                    {
                        interceptors.handle_location_forward (null, fwd.forward);
                    }

                    ( (ObjectImpl) self)._set_delegate ( ( (ObjectImpl) fwd.forward)._get_delegate());
                    return null;
                }
                catch (Exception ex)
                {
                    if (interceptors != null && orb.hasRequestInterceptors())
                    {
                        manager.removeLocalPICurrent ();

                        try
                        {
                            if (ex instanceof SystemException)
                            {
                                interceptors.handle_receive_exception ( (SystemException) ex);
                            }
                            else if (ex instanceof ApplicationException)
                            {
                                interceptors.handle_receive_exception ( (ApplicationException) ex, null);
                            }
                        }
                        catch (ForwardRequest fwd)
                        {
                            ( (ObjectImpl) self)._set_delegate ( ( (ObjectImpl) fwd.forward)._get_delegate());
                            return null;
                        }
                    }

                    throw ex;
                }
            }

            try
            {
                if ( ( poa.isRetain() && !poa.isUseServantManager() ) ||
                     poa.useDefaultServant() )
                {
                    // no ServantManagers, but AOM use
                    try
                    {
                       servantObject.servant = poa.reference_to_servant( self );
                    }
                    catch( WrongAdapter e )
                    {
                        throw new OBJ_ADAPTER( "WrongAdapter caught when converting servant to reference. " + e );
                    }
                    catch( WrongPolicy e )
                    {
                        throw new OBJ_ADAPTER("WrongPolicy caught" + e );
                    }
                    catch( ObjectNotActive e )
                    {
                        throw new org.omg.CORBA.OBJECT_NOT_EXIST();
                    }
                }
                else if ( poa.isUseServantManager() )
                {
                    byte [] oid =
                    POAUtil.extractOID( getParsedIOR().get_object_key() );
                    org.omg.PortableServer.ServantManager sm = poa.get_servant_manager();

                    if ( poa.isRetain() )
                    {
                        // ServantManager is a ServantActivator. Use the AOM to
                        // incarnate this or return the servant. It will correctly
                        // synchrnoize the requests.
                        servantObject.servant = poa._incarnateServant(oid, (ServantActivator)sm);
                    }
                    else
                    {
                        // ServantManager is a ServantLocator: locate a servant
                        org.omg.PortableServer.ServantLocator sl =
                            ( org.omg.PortableServer.ServantLocator ) sm;

                        // store this for postinvoke

                        cookie = new org.omg.PortableServer.ServantLocatorPackage.CookieHolder();

                        invokedOperation = operation;

                        servantObject.servant = sl.preinvoke( oid, poa, operation, cookie );
                    }
                    ((org.omg.CORBA_2_3.ORB)orb).set_delegate(servantObject.servant);
                }
                else
                {
                    throw new INTERNAL("Internal error: we should not have got to this piece of code!");
                }
            }
            catch( WrongPolicy e )
            {
                throw new OBJ_ADAPTER( "WrongPolicy caught" + e );
            }
            catch( org.omg.PortableServer.ForwardRequest e )
            {
                if( logger.isDebugEnabled() )
                {
                    logger.debug("Caught forwardrequest to " + e.forward_reference + " from " + self );
                }
                ( (ObjectImpl) self)._set_delegate ( ( (ObjectImpl) e.forward_reference)._get_delegate());

                return null;
            }

            if ( !expectedType.isInstance( servantObject.servant ) )
            {
                if( logger.isWarnEnabled() )
                {
                    logger.warn("Expected " + expectedType +
                                " got " + servantObject.servant.getClass() );
                }

                ignoreNextCallToIsLocal.set(Boolean.TRUE);

                poa.removeLocalRequest();
                return null;
            }


            orb.getPOACurrent()._addContext
            (
                Thread.currentThread(),
                new org.jacorb.poa.LocalInvocationContext
                (
                    orb,
                    poa,
                    getObjectId(),
                    ( org.omg.PortableServer.Servant ) servantObject.servant
                )
            );
            addedContext = true;

            ( (org.jacorb.orb.ServantObjectImpl )servantObject).setClientInterceptorHandler (interceptors);

            if (orb.hasServerRequestInterceptors())
            {
                sinfo =  ( (org.jacorb.orb.ServantObjectImpl ) servantObject).getServerRequestInfo();
                sinfo.setServant((org.omg.PortableServer.Servant) servantObject.servant);

                interceptorIterator = manager.getServerIterator();

                ( (org.jacorb.orb.ServantObjectImpl ) servantObject).setServerRequestInfo (sinfo);

                // Note: this code is very similar to the above hasServerRequestInterceptors try/catch
                try
                {
                   manager.setLocalPICurrent (sinfo.current ());

                   interceptorIterator.iterate
                   (
                       sinfo,
                       ServerInterceptorIterator.RECEIVE_REQUEST
                   );
                }
                catch (ForwardRequest fwd)
                {
                    if (interceptors != null)
                    {
                        interceptors.handle_location_forward (null, fwd.forward);
                    }

                    ( (ObjectImpl) self)._set_delegate ( ( (ObjectImpl) fwd.forward)._get_delegate());
                    return null;
                }
                catch (Exception ex)
                {
                    Collection<ServiceContext> ctx = sinfo.getReplyServiceContexts();
                    interceptors.getInfo ().setReplyServiceContexts (ctx.toArray (new ServiceContext[ctx.size ()]));
                    manager.removeLocalPICurrent ();

                    if (interceptors != null && orb.hasRequestInterceptors())
                    {
                        try
                        {
                            if (ex instanceof SystemException)
                            {
                                interceptors.handle_receive_exception ( (SystemException) ex);
                            }
                            else if (ex instanceof ApplicationException)
                            {
                                interceptors.handle_receive_exception ( (ApplicationException) ex, null);
                            }
                        }
                        catch (ForwardRequest fwd)
                        {
                            ( (ObjectImpl) self)._set_delegate ( ( (ObjectImpl) fwd.forward)._get_delegate());
View Full Code Here

TOP

Related Classes of org.jacorb.orb.portableInterceptor.DefaultClientInterceptorHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.