Package org.jacorb.orb.giop

Examples of org.jacorb.orb.giop.ReplyOutputStream


    public void setLocationForward(org.omg.PortableServer.ForwardRequest request)
    {
        replyStatus = ReplyStatusType_1_2._LOCATION_FORWARD;

        out = new ReplyOutputStream(orb,
                                    requestId(),
                                    ReplyStatusType_1_2.LOCATION_FORWARD,
                                    inputStream.getGIOPMinor(),
                                    inputStream.isLocateRequest(),
                                    logger );
View Full Code Here


     */
    public ReplyOutputStream get_out()
    {
        if (out == null)
        {
            out = new ReplyOutputStream(orb,
                                        requestId(),
                                        status(),
                                        inputStream.getGIOPMinor(),
                                        inputStream.isLocateRequest(),
                                        logger );
View Full Code Here

                                  request_id,
                                  giop_minor );
                return;
            }

            ReplyOutputStream out =
                new ReplyOutputStream( orb,
                                       request_id,
                                       org.omg.GIOP.ReplyStatusType_1_2.LOCATION_FORWARD,
                                       giop_minor,
                                       isLocateRequest,
                                       logger);

            // The typecode is for org.omg.CORBA.Object, but avoiding
            // creation of new ObjectHolder Instance.
            IIOPAddress addr = new IIOPAddress (_poa.host,(short)_poa.port);
            org.omg.IOP.IOR _ior = null;
            try
            {
                addr.configure(configuration);
                IIOPProfile p = new IIOPProfile (addr,object_key,giop_minor);
                p.configure(configuration);
                _ior = ParsedIOR.createObjectIOR ((ORB)orb, p);
            }
            catch(ConfigurationException e)
            {
                logger.error("Error while configuring address/profile", e);
            }

            if( !_old_poa_state )
            {
                // if POA has been reactivated, we have to wait for
                // the requested object to become ready again. This is
                // for avoiding clients to get confused by
                // OBJECT_NOT_EXIST exceptions which they might get
                // when trying to contact the server too early.

                org.omg.CORBA.Object _object =
                    orb.string_to_object(
                        (new ParsedIOR( (org.jacorb.orb.ORB) orb, _ior)).getIORString());

                // Sort of busy waiting here, no other way possible
                for( int _i = 0; _i < object_activation_retries; _i++ )
                {
                    try
                    {
                        Thread.sleep( object_activation_sleep );

                        // This will usually throw an OBJECT_NOT_EXIST
                        if( ! _object._non_existent() ) // "CORBA ping"
                        {
                            break;
                        }
                    }
                    catch(Exception _e)
                    {
                        logger.info("Exception while waiting for object", _e);
                    }
                }
            }

            try
            {
                // write new location to stream
                out.write_IOR(_ior);

                if (logger.isDebugEnabled())
                {
                    logger.debug("ImR: Sending location forward for " +
                                      _server.name);
View Full Code Here

        private void sendSysException( org.omg.CORBA.SystemException sys_ex,
                                       GIOPConnection connection,
                                       int request_id,
                                       int giop_minor )
        {
            ReplyOutputStream out =
                new ReplyOutputStream( orb,
                                       request_id,
                                       org.omg.GIOP.ReplyStatusType_1_2.SYSTEM_EXCEPTION,
                                       giop_minor,
                                       false,
                                       logger);
View Full Code Here

    }

    @Test
    public void testDoesNotLikeWCharWithinReply()
    {
        ReplyOutputStream out = new ReplyOutputStream(orb, 1, ReplyStatusType_1_2.NO_EXCEPTION, 0, false, TestUtils.getLogger());

        out.write_wchar('a');

        ReplyInputStream in = new ReplyInputStream(orb, out.getBufferCopy());

        assertEquals(0, in.getGIOPMinor());

        try
        {
            in.read_wchar();
            fail();
        }
        catch(MARSHAL e)
        {
            assertEquals(6, e.minor);
        }
        finally
        {
            out.close();
            in.close();
        }
    }
View Full Code Here

    }

    @Test
    public void testServerDoesNotLikeWString()
    {
        ReplyOutputStream out = new ReplyOutputStream(orb, 1, ReplyStatusType_1_2.NO_EXCEPTION, 0, false, TestUtils.getLogger());

        out.write_wstring("string");

        ReplyInputStream in = new ReplyInputStream(orb, out.getBufferCopy());

        assertEquals(0, in.getGIOPMinor());

        try
        {
            in.read_wstring();
            fail();
        }
        catch(MARSHAL e)
        {
            assertEquals(6, e.minor);
        }
        finally
        {
            out.close();
            in.close();
        }
    }
View Full Code Here

                                     RECEIVE_REQUEST_SERVICE_CONTEXTS))
            {
                //an interceptor bailed out, so don't continue request
                //processing and return here. The service contexts for
                //the result have to be set, of course.
                ReplyOutputStream out = request.getReplyOutputStream();
                Collection<ServiceContext> ctx = info.getReplyServiceContexts ();

                for (ServiceContext s: ctx)
                {
                    out.addServiceContext(s);
                }

                return;
            }

            manager.setTSCurrent(info.current());
        }

        // TODO: The exception replies below should also trigger interceptors.
        // Requires some re-arranging of the entire method.
        if (Time.hasPassed (request.getRequestEndTime()))
        {
            request.setSystemException
                (new org.omg.CORBA.TIMEOUT ("Request End Time exceeded",
                                            0, CompletionStatus.COMPLETED_NO));
            return;
        }
        if (checkReplyEndTime && Time.hasPassed (request.getReplyEndTime()))
        {
            request.setSystemException
                (new org.omg.CORBA.TIMEOUT ("Reply End Time exceeded",
                                            0, CompletionStatus.COMPLETED_NO));
            return;
        }

        Time.waitFor (request.getRequestStartTime());

        if (servantManager != null)
        {
            if (servantManager instanceof org.omg.PortableServer.ServantActivator)
            {
                invokeIncarnate();
            }
            else
            {
                invokePreInvoke();
            }
            ((org.omg.CORBA_2_3.ORB)orb).set_delegate(servant);
        }

        if (servant != null)
        {
            if (info != null)
            {
                info.setServant(servant);

                if (servant instanceof org.omg.CORBA.portable.InvokeHandler)
                {
                    if(! invokeInterceptors(info,
                                            ServerInterceptorIterator.RECEIVE_REQUEST ))
                    {
                        //an interceptor bailed out, so don't continue
                        //request processing and return here. The
                        //service contexts for the result have to be
                        //set, of course.

                        if( cookieHolder != null )
                        {
                            invokePostInvoke();
                        }

                        ReplyOutputStream out = request.getReplyOutputStream();
                        Collection<ServiceContext> ctx = info.getReplyServiceContexts ();

                        for (ServiceContext s: ctx)
                        {
                            out.addServiceContext(s);
                        }

                        return;
                    }
                }
                else if (servant instanceof org.omg.PortableServer.DynamicImplementation)
                {
                    request.setServerRequestInfo(info);
                }
            }

            invokeOperation();
        }

        // preinvoke and postinvoke are always called in pairs
        // but what happens if the servant is null

        if (cookieHolder != null)
        {
            invokePostInvoke();
        }

        if (checkReplyEndTime && Time.hasPassed (request.getReplyEndTime()))
        {
            request.setSystemException
                (new org.omg.CORBA.TIMEOUT ("Reply End Time exceeded after invocation",
                                            0, CompletionStatus.COMPLETED_YES));
        }

        if (info != null)
        {
            InterceptorManager manager =
                orb.getInterceptorManager();
            info.setCurrent (manager.getCurrent());

            short op = 0;
            switch(request.status().value())
            {
                case ReplyStatusType_1_2._NO_EXCEPTION:
                {
                    op = ServerInterceptorIterator.SEND_REPLY;
                    info.setReplyStatus (SUCCESSFUL.value);
                    break;
                }
                case ReplyStatusType_1_2._USER_EXCEPTION:
                {
                    info.setReplyStatus (USER_EXCEPTION.value);
                    Any sendingException = orb.create_any();
                    SystemExceptionHelper.insert(sendingException, new org.omg.CORBA.UNKNOWN("Stream-based UserExceptions are not available!"));
                    info.sending_exception(sendingException);
                    op = ServerInterceptorIterator.SEND_EXCEPTION;
                    break;
                }
                case ReplyStatusType_1_2._SYSTEM_EXCEPTION:
                {
                    info.setReplyStatus (SYSTEM_EXCEPTION.value);
                    Any sendingException = orb.create_any();
                    SystemExceptionHelper.insert(sendingException, request.getSystemException());
                    info.sending_exception(sendingException);
                    op = ServerInterceptorIterator.SEND_EXCEPTION;
                    break;

                }
                case ReplyStatusType_1_2._LOCATION_FORWARD:
                {
                    info.setReplyStatus (LOCATION_FORWARD.value);
                    op = ServerInterceptorIterator.SEND_OTHER;
                    break;
                }
            }

            invokeInterceptors(info, op);

            ReplyOutputStream out = request.get_out();
            Collection<ServiceContext> ctx = info.getReplyServiceContexts ();

            for (ServiceContext s: ctx)
            {
                out.addServiceContext(s);
            }

            manager.removeTSCurrent();
        }
    }
View Full Code Here

TOP

Related Classes of org.jacorb.orb.giop.ReplyOutputStream

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.