Package org.jacorb.orb.portableInterceptor

Examples of org.jacorb.orb.portableInterceptor.ServerInterceptorIterator


                    }
                }

                info.setArguments (params);

                ServerInterceptorIterator intercept_iter =
                    orb.getInterceptorManager().getServerIterator();

                try
                {
                    intercept_iter.iterate(info, ServerInterceptorIterator.RECEIVE_REQUEST);
                }
                catch (ForwardRequest e)
                {
                    setLocationForward(new org.omg.PortableServer.ForwardRequest(e.forward));
                }
View Full Code Here


    private boolean invokeInterceptors( ServerRequestInfoImpl info,
                                        short op )
    {

        ServerInterceptorIterator intercept_iter =
            controller.getORB().getInterceptorManager().getServerIterator();

        try
        {
            intercept_iter.iterate(info, op);
        }
        catch(org.omg.CORBA.UserException ue)
        {
            if (ue instanceof org.omg.PortableInterceptor.ForwardRequest)
            {
View Full Code Here

                    }
                }

                info.setArguments (params);

                ServerInterceptorIterator intercept_iter =
                    orb.getInterceptorManager().getServerIterator();

                try
                {
                    intercept_iter.iterate(info, ServerInterceptorIterator.RECEIVE_REQUEST);
                }
                catch(org.omg.CORBA.UserException ue)
                {
                    if (ue instanceof org.omg.PortableInterceptor.
                        ForwardRequest)
View Full Code Here

    private boolean invokeInterceptors( ServerRequestInfoImpl info,
                                        short op )
    {

        ServerInterceptorIterator intercept_iter =
            controller.getORB().getInterceptorManager().getServerIterator();

        try
        {
            intercept_iter.iterate(info, op);
        }
        catch(org.omg.CORBA.UserException ue)
        {
            if (ue instanceof org.omg.PortableInterceptor.ForwardRequest)
            {
View Full Code Here

                    }
                }

                info.setArguments (params);

                ServerInterceptorIterator intercept_iter =
                    orb.getInterceptorManager().getServerIterator();

                try
                {
                    intercept_iter.iterate(info, ServerInterceptorIterator.RECEIVE_REQUEST);
                }
                catch (ForwardRequest e)
                {
                    setLocationForward(new org.omg.PortableServer.ForwardRequest(e.forward));
                }
View Full Code Here

    private boolean invokeInterceptors( ServerRequestInfoImpl info,
                                        short op )
    {

        ServerInterceptorIterator intercept_iter =
            controller.getORB().getInterceptorManager().getServerIterator();

        try
        {
            intercept_iter.iterate(info, op);
        }
        catch(org.omg.CORBA.UserException ue)
        {
            if (ue instanceof org.omg.PortableInterceptor.ForwardRequest)
            {
View Full Code Here

                    }
                }

                info.setArguments (params);

                ServerInterceptorIterator intercept_iter =
                    orb.getInterceptorManager().getServerIterator();

                try
                {
                    intercept_iter.iterate(info, ServerInterceptorIterator.RECEIVE_REQUEST);
                }
                catch (ForwardRequest e)
                {
                    setLocationForward(new org.omg.PortableServer.ForwardRequest(e.forward));
                }
View Full Code Here

                    }
                }

                info.setArguments (params);

                ServerInterceptorIterator intercept_iter =
                    orb.getInterceptorManager().getServerIterator();

                try
                {
                    intercept_iter.iterate(info, ServerInterceptorIterator.RECEIVE_REQUEST);
                }
                catch (ForwardRequest e)
                {
                    setLocationForward(new org.omg.PortableServer.ForwardRequest(e.forward));
                }
View Full Code Here

    public ServantObject servant_preinvoke( org.omg.CORBA.Object self,
                                            String operation,
                                            @SuppressWarnings("rawtypes") Class expectedType )
    {
        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());
                            return null;
                        }
                    }

                    throw ex;
                }

                /**
                 * If this is an internal ORB call from is_a or non_existent then we need
                 * to complete the interception point SEND_REPLY.  In other situations this will
                 * happen in the stub via the normalCompletion call but this will not be
                 * the case for internal ORB Calls
                 */
                if (operation.equals ("_is_a") || operation.equals ("_non_existent") ||
                    operation.equals("_interface") || operation.equals ("_get_component"))
                {
                    interceptorIterator.iterate
                    (
                        sinfo,
                        ServerInterceptorIterator.SEND_REPLY
                    );
                }
View Full Code Here

    private boolean invokeInterceptors( ServerRequestInfoImpl info,
                                        short op )
    {

        ServerInterceptorIterator intercept_iter =
            controller.getORB().getInterceptorManager().getServerIterator();

        try
        {
            intercept_iter.iterate(info, op);
        }
        catch(org.omg.CORBA.UserException ue)
        {
            if (ue instanceof org.omg.PortableInterceptor.ForwardRequest)
            {
View Full Code Here

TOP

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

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.