Package org.jacorb.orb.giop

Examples of org.jacorb.orb.giop.ClientConnection


     */
    @Test
    public void testDefaultCodeSets() throws Exception
    {
        ParsedIOR ior = new ParsedIOR( (ORB) orb, new IOR( "", new TaggedProfile[0] ) );
        ClientConnection connection = createClientConnection( 1, 0, ior );

        assertEquals( "Default codeSet", getORB().getTCSDefault().getId(), connection.getTCS().getId() );
        assertEquals( "Default wide codeset", UTF16_ID, connection.getTCSW().getId() );
    }
View Full Code Here


    @Test
    public void testNoCodeSetSpecified() throws Exception
    {
        ParsedIOR ior = new ParsedIOR( (ORB) orb, new IOR( "", new TaggedProfile[0] ) );

        ClientConnection connection = createClientConnection( 1, 1, ior );

        assertEquals( "Default codeSet", getORB().getTCSDefault().getId(), connection.getTCS().getId() );
        assertEquals( "Default wide codeset", UTF16_ID, connection.getTCSW().getId() );
    }
View Full Code Here

     */
    @Test
    public void testSelectingStandardCodeSetsFor1_1() throws Exception
    {
        ParsedIOR ior = createParsedIOR( ISO8859_1_ID, UTF16_ID );
        ClientConnection connection = createClientConnection( 1, 1, ior );

        assertEquals( "Selected codeSet", ISO8859_1_ID, connection.getTCS().getId() );
        assertEquals( "Selected wide codeset", UTF16_ID, connection.getTCSW().getId() );
    }
View Full Code Here

     */
    @Test
    public void testSelectingUTF8For1_2() throws Exception
    {
        ParsedIOR ior = createParsedIOR( ISO8859_1_ID, UTF8_ID );
        ClientConnection connection = createClientConnection( 1, 2, ior );

        assertEquals( "Selected codeSet",      ISO8859_1_ID, connection.getTCS().getId() );
        assertEquals( "Selected wide codeset", UTF8_ID,      connection.getTCSW().getId() );
    }
View Full Code Here

     */
    @Test
    public void testSelectingConversionCodeSets() throws Exception
    {
        ParsedIOR ior = createParsedIOR( 0x11111, new int[]{ISO8859_1_ID}, 0x12345, new int[]{UTF16_ID} );
        ClientConnection connection = createClientConnection( 1, 2, ior );

        assertEquals( "Selected codeSet", ISO8859_1_ID, connection.getTCS().getId() );
        assertEquals( "Selected wide codeset", UTF16_ID, connection.getTCSW().getId() );
    }
View Full Code Here

    private ClientConnection createClientConnection( int majorVersion, int minorVersion, ParsedIOR ior )
    {
        Profile profile = createMockProfile( majorVersion, minorVersion );
        ClientGIOPConnection giopConnection = new ClientGIOPConnection( null, null, null, null, null );
        ClientConnection connection = new ClientConnection( giopConnection, orb, null, profile, false );
        try
        {
            giopConnection.configure(getORB().getConfiguration());
        }
        catch (ConfigurationException e)
        {
        }

        ior.setProfileSelector( createMockProfileSelector( profile ) );
        connection.setCodeSet( ior );
        return connection;
    }
View Full Code Here

                throw e;
            }
        }

        ClientConnection connectionToUse = null;

        ReplyGroup group = null;
        try
        {
            synchronized (bind_sync)
            {
               if ( ! bound )
               {
                  // Somehow the connection got closed under us
                  throw new COMM_FAILURE("Connection closed");
               }
               else if (ros.getConnection() == connections[currentConnection.ordinal ()])
               {
                  // RequestOutputStream has been created for
                  // exactly this connection
                  connectionToUse = connections[currentConnection.ordinal ()];
               }
               else
               {
                    logger.debug("invoke: RemarshalException");

                    // RequestOutputStream has been created for
                    // another connection, so try again
                    throw new RemarshalException();
                }
            }

            group = getReplyGroup (connectionToUse);
            if ( !ros.response_expected() )  // oneway op
            {
                invoke_oneway (ros, connectionToUse, interceptors, group);
            }
            else
            {
                // response expected, synchronous or asynchronous
                receiver = new ReplyReceiver(this, group,
                                             ros.operation(),
                                             ros.getReplyEndTime(),
                                            interceptors, replyHandler, selectorManager);

                try
                {
                   receiver.configure(configuration);
                }
                catch (ConfigurationException ex)
                {
                   logger.error ("Configuration problem with ReplyReceiver", ex);
                   throw new INTERNAL ("Caught configuration exception setting up ReplyReceiver.");
                }

                group.addHolder (receiver);

                // Use the local copy of the client connection to avoid trouble
                // with something else affecting the real connections[currentConnection].
                connectionToUse.sendRequest(ros, receiver, ros.requestId(), true);
                getParsedIOR ().markLastUsedProfile ();
            }
        }
        catch ( org.omg.CORBA.SystemException cfe )
        {
            logger.debug("invoke[-->]: SystemException", cfe);

            if( !async )
            {
                // Remove ReplyReceiver to break up reference cycle
                // Otherwise gc will not detect this Delegate and
                // will never finalize it.
                if (group != null)
                    group.removeHolder(receiver);
            }

            try
            {
                interceptors.handle_receive_exception ( cfe );
            }
            catch (ForwardRequest fwd)
            {
                // Should not happen for remote requests
            }

            // The exception is a TRANSIENT, so try rebinding.
            if ( cfe instanceof org.omg.CORBA.TRANSIENT && try_rebind (false))
            {
                throw new RemarshalException();
            }

            if (!(cfe instanceof org.omg.CORBA.TIMEOUT))
            {
                if (logger.isDebugEnabled())
                {
                    logger.debug (this.toString() + " : invoke_internal: closing connection due to " + cfe.getMessage());
                }
                disconnect(connectionToUse);
            }

            throw cfe;
        }
        finally
        {
            if (orb.hasRequestInterceptors())
            {
                localInterceptors.set(null);
            }
        }

        try
        {
            if ( !async && receiver != null )
            {
                // Synchronous invocation, response expected.
                // This call blocks until the reply arrives.
                org.omg.CORBA.portable.InputStream is = receiver.getReply();

                ((CDRInputStream)is).updateMutatorConnection (connectionToUse.getGIOPConnection());

                if (clearCurrentContext)
                {
                    clearInvocationContext();
                }
View Full Code Here

        {
            return;
        }

        // ask connection for client_context_id
        ClientConnection connection = ri.getConnection();

        long client_context_id = 0;
        if (useStateful)
            client_context_id = connection.cacheSASContext("css".getBytes());
        if (client_context_id < 0)
        {
            if (logger.isInfoEnabled())
                logger.info("New SAS Context: " + (-client_context_id));
        }
View Full Code Here

            throw new org.omg.CORBA.NO_PERMISSION("SAS Could not parse SAS reply: " + e,
                                                  MinorCodes.SAS_CSS_FAILURE,
                                                  CompletionStatus.COMPLETED_MAYBE);
        }
        ClientConnection connection = ri.getConnection();

        // process CompleteEstablishContext message
        if (contextBody.discriminator() == MTCompleteEstablishContext.value)
        {
            CompleteEstablishContext reply = contextBody.complete_msg();

            // if not stateful, remove from connection
            if (reply.client_context_id > 0 && !reply.context_stateful)
                connection.purgeSASContext(reply.client_context_id);
        }

        // process ContextError message
        if (contextBody.discriminator() == MTContextError.value)
        {
            ContextError reply = contextBody.error_msg();

            // if stateful, remove from connection
            if (reply.client_context_id > 0)
                connection.purgeSASContext(reply.client_context_id);
        }
    }
View Full Code Here

            throw new org.omg.CORBA.NO_PERMISSION("SAS Could not parse SAS reply: " + e,
                                                  MinorCodes.SAS_CSS_FAILURE,
                                                  CompletionStatus.COMPLETED_MAYBE);
        }
        ClientConnection connection = ri.getConnection();

        // process CompleteEstablishContext message
        if (contextBody.discriminator() == MTCompleteEstablishContext.value)
        {
            CompleteEstablishContext reply = contextBody.complete_msg();
            logger.debug("receive_exception MTCompleteEstablishContext: " + reply.client_context_id);

            // if not stateful, remove from connection
            if (reply.client_context_id > 0 && !reply.context_stateful)
                connection.purgeSASContext(reply.client_context_id);
        }

        // process ContextError message
        if (contextBody.discriminator() == MTContextError.value)
        {
            ContextError reply = contextBody.error_msg();
            logger.debug("receive_exception MTContextError: " + reply.client_context_id);

            // if stateful, remove from connection
            if (reply.client_context_id > 0)
                connection.purgeSASContext(reply.client_context_id);

            // if context not found, resend with empty context cache
            if (reply.major_status == 2) throw new org.omg.PortableInterceptor.ForwardRequest(ri.target());
        }
    }
View Full Code Here

TOP

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

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.