Java Code Examples for com.sun.corba.se.spi.servicecontext.ServiceContexts#get()

The following examples show how to use com.sun.corba.se.spi.servicecontext.ServiceContexts#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CorbaMessageMediatorImpl.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * If the RMI-IIOP maximum stream format version service context
 * is present, it indicates the maximum stream format version we
 * could use for the reply.  If it isn't present, the default is
 * 2 for GIOP 1.3 or greater, 1 for lower.
 *
 * This is only sent on requests.  Clients can find out the
 * server's maximum by looking for a tagged component in the IOR.
 */
public byte getStreamFormatVersionForReply() {

    // NOTE: The request service contexts may indicate the max.
    ServiceContexts svc = getRequestServiceContexts();

    MaxStreamFormatVersionServiceContext msfvsc
        = (MaxStreamFormatVersionServiceContext)svc.get(
            MaxStreamFormatVersionServiceContext.SERVICE_CONTEXT_ID);

    if (msfvsc != null) {
        byte localMaxVersion = ORBUtility.getMaxStreamFormatVersion();
        byte remoteMaxVersion = msfvsc.getMaximumStreamFormatVersion();

        return (byte)Math.min(localMaxVersion, remoteMaxVersion);
    } else {
        // Defaults to 1 for GIOP 1.2 or less, 2 for
        // GIOP 1.3 or higher.
        if (getGIOPVersion().lessThan(GIOPVersion.V1_3))
            return ORBConstants.STREAM_FORMAT_VERSION_1;
        else
            return ORBConstants.STREAM_FORMAT_VERSION_2;
    }
}
 
Example 2
Source File: CorbaMessageMediatorImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * If the RMI-IIOP maximum stream format version service context
 * is present, it indicates the maximum stream format version we
 * could use for the reply.  If it isn't present, the default is
 * 2 for GIOP 1.3 or greater, 1 for lower.
 *
 * This is only sent on requests.  Clients can find out the
 * server's maximum by looking for a tagged component in the IOR.
 */
public byte getStreamFormatVersionForReply() {

    // NOTE: The request service contexts may indicate the max.
    ServiceContexts svc = getRequestServiceContexts();

    MaxStreamFormatVersionServiceContext msfvsc
        = (MaxStreamFormatVersionServiceContext)svc.get(
            MaxStreamFormatVersionServiceContext.SERVICE_CONTEXT_ID);

    if (msfvsc != null) {
        byte localMaxVersion = ORBUtility.getMaxStreamFormatVersion();
        byte remoteMaxVersion = msfvsc.getMaximumStreamFormatVersion();

        return (byte)Math.min(localMaxVersion, remoteMaxVersion);
    } else {
        // Defaults to 1 for GIOP 1.2 or less, 2 for
        // GIOP 1.3 or higher.
        if (getGIOPVersion().lessThan(GIOPVersion.V1_3))
            return ORBConstants.STREAM_FORMAT_VERSION_1;
        else
            return ORBConstants.STREAM_FORMAT_VERSION_2;
    }
}
 
Example 3
Source File: CorbaMessageMediatorImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * If the RMI-IIOP maximum stream format version service context
 * is present, it indicates the maximum stream format version we
 * could use for the reply.  If it isn't present, the default is
 * 2 for GIOP 1.3 or greater, 1 for lower.
 *
 * This is only sent on requests.  Clients can find out the
 * server's maximum by looking for a tagged component in the IOR.
 */
public byte getStreamFormatVersionForReply() {

    // NOTE: The request service contexts may indicate the max.
    ServiceContexts svc = getRequestServiceContexts();

    MaxStreamFormatVersionServiceContext msfvsc
        = (MaxStreamFormatVersionServiceContext)svc.get(
            MaxStreamFormatVersionServiceContext.SERVICE_CONTEXT_ID);

    if (msfvsc != null) {
        byte localMaxVersion = ORBUtility.getMaxStreamFormatVersion();
        byte remoteMaxVersion = msfvsc.getMaximumStreamFormatVersion();

        return (byte)Math.min(localMaxVersion, remoteMaxVersion);
    } else {
        // Defaults to 1 for GIOP 1.2 or less, 2 for
        // GIOP 1.3 or higher.
        if (getGIOPVersion().lessThan(GIOPVersion.V1_3))
            return ORBConstants.STREAM_FORMAT_VERSION_1;
        else
            return ORBConstants.STREAM_FORMAT_VERSION_2;
    }
}
 
Example 4
Source File: CorbaMessageMediatorImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * If the RMI-IIOP maximum stream format version service context
 * is present, it indicates the maximum stream format version we
 * could use for the reply.  If it isn't present, the default is
 * 2 for GIOP 1.3 or greater, 1 for lower.
 *
 * This is only sent on requests.  Clients can find out the
 * server's maximum by looking for a tagged component in the IOR.
 */
public byte getStreamFormatVersionForReply() {

    // NOTE: The request service contexts may indicate the max.
    ServiceContexts svc = getRequestServiceContexts();

    MaxStreamFormatVersionServiceContext msfvsc
        = (MaxStreamFormatVersionServiceContext)svc.get(
            MaxStreamFormatVersionServiceContext.SERVICE_CONTEXT_ID);

    if (msfvsc != null) {
        byte localMaxVersion = ORBUtility.getMaxStreamFormatVersion();
        byte remoteMaxVersion = msfvsc.getMaximumStreamFormatVersion();

        return (byte)Math.min(localMaxVersion, remoteMaxVersion);
    } else {
        // Defaults to 1 for GIOP 1.2 or less, 2 for
        // GIOP 1.3 or higher.
        if (getGIOPVersion().lessThan(GIOPVersion.V1_3))
            return ORBConstants.STREAM_FORMAT_VERSION_1;
        else
            return ORBConstants.STREAM_FORMAT_VERSION_2;
    }
}
 
Example 5
Source File: CorbaMessageMediatorImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * If the RMI-IIOP maximum stream format version service context
 * is present, it indicates the maximum stream format version we
 * could use for the reply.  If it isn't present, the default is
 * 2 for GIOP 1.3 or greater, 1 for lower.
 *
 * This is only sent on requests.  Clients can find out the
 * server's maximum by looking for a tagged component in the IOR.
 */
public byte getStreamFormatVersionForReply() {

    // NOTE: The request service contexts may indicate the max.
    ServiceContexts svc = getRequestServiceContexts();

    MaxStreamFormatVersionServiceContext msfvsc
        = (MaxStreamFormatVersionServiceContext)svc.get(
            MaxStreamFormatVersionServiceContext.SERVICE_CONTEXT_ID);

    if (msfvsc != null) {
        byte localMaxVersion = ORBUtility.getMaxStreamFormatVersion();
        byte remoteMaxVersion = msfvsc.getMaximumStreamFormatVersion();

        return (byte)Math.min(localMaxVersion, remoteMaxVersion);
    } else {
        // Defaults to 1 for GIOP 1.2 or less, 2 for
        // GIOP 1.3 or higher.
        if (getGIOPVersion().lessThan(GIOPVersion.V1_3))
            return ORBConstants.STREAM_FORMAT_VERSION_1;
        else
            return ORBConstants.STREAM_FORMAT_VERSION_2;
    }
}
 
Example 6
Source File: CorbaMessageMediatorImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * If the RMI-IIOP maximum stream format version service context
 * is present, it indicates the maximum stream format version we
 * could use for the reply.  If it isn't present, the default is
 * 2 for GIOP 1.3 or greater, 1 for lower.
 *
 * This is only sent on requests.  Clients can find out the
 * server's maximum by looking for a tagged component in the IOR.
 */
public byte getStreamFormatVersionForReply() {

    // NOTE: The request service contexts may indicate the max.
    ServiceContexts svc = getRequestServiceContexts();

    MaxStreamFormatVersionServiceContext msfvsc
        = (MaxStreamFormatVersionServiceContext)svc.get(
            MaxStreamFormatVersionServiceContext.SERVICE_CONTEXT_ID);

    if (msfvsc != null) {
        byte localMaxVersion = ORBUtility.getMaxStreamFormatVersion();
        byte remoteMaxVersion = msfvsc.getMaximumStreamFormatVersion();

        return (byte)Math.min(localMaxVersion, remoteMaxVersion);
    } else {
        // Defaults to 1 for GIOP 1.2 or less, 2 for
        // GIOP 1.3 or higher.
        if (getGIOPVersion().lessThan(GIOPVersion.V1_3))
            return ORBConstants.STREAM_FORMAT_VERSION_1;
        else
            return ORBConstants.STREAM_FORMAT_VERSION_2;
    }
}
 
Example 7
Source File: CorbaMessageMediatorImpl.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * If the RMI-IIOP maximum stream format version service context
 * is present, it indicates the maximum stream format version we
 * could use for the reply.  If it isn't present, the default is
 * 2 for GIOP 1.3 or greater, 1 for lower.
 *
 * This is only sent on requests.  Clients can find out the
 * server's maximum by looking for a tagged component in the IOR.
 */
public byte getStreamFormatVersionForReply() {

    // NOTE: The request service contexts may indicate the max.
    ServiceContexts svc = getRequestServiceContexts();

    MaxStreamFormatVersionServiceContext msfvsc
        = (MaxStreamFormatVersionServiceContext)svc.get(
            MaxStreamFormatVersionServiceContext.SERVICE_CONTEXT_ID);

    if (msfvsc != null) {
        byte localMaxVersion = ORBUtility.getMaxStreamFormatVersion();
        byte remoteMaxVersion = msfvsc.getMaximumStreamFormatVersion();

        return (byte)Math.min(localMaxVersion, remoteMaxVersion);
    } else {
        // Defaults to 1 for GIOP 1.2 or less, 2 for
        // GIOP 1.3 or higher.
        if (getGIOPVersion().lessThan(GIOPVersion.V1_3))
            return ORBConstants.STREAM_FORMAT_VERSION_1;
        else
            return ORBConstants.STREAM_FORMAT_VERSION_2;
    }
}
 
Example 8
Source File: RequestInfoImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Utility method to look up a service context with the given id and
 * convert it to an IOP.ServiceContext.  Uses the given HashMap as
 * a cache.  If not found in cache, the result is inserted in the cache.
 */
protected org.omg.IOP.ServiceContext
    getServiceContext ( HashMap cachedServiceContexts,
                        ServiceContexts serviceContexts, int id )
{
    org.omg.IOP.ServiceContext result = null;
    Integer integerId = new Integer( id );

    // Search cache first:
    result = (org.omg.IOP.ServiceContext)
        cachedServiceContexts.get( integerId );

    // null could normally mean that either we cached the value null
    // or it's not in the cache.  However, there is no way for us to
    // cache the value null in the following code.
    if( result == null ) {
        // Not in cache.  Find it and put in cache.
        // Get the desired "core" service context.
        com.sun.corba.se.spi.servicecontext.ServiceContext context =
            serviceContexts.get( id );
        if (context == null)
            throw stdWrapper.invalidServiceContextId() ;

        // Convert the "core" service context to an
        // "IOP" ServiceContext by writing it to a
        // CDROutputStream and reading it back.
        EncapsOutputStream out =
            sun.corba.OutputStreamFactory.newEncapsOutputStream(myORB);

        context.write( out, GIOPVersion.V1_2 );
        InputStream inputStream = out.create_input_stream();
        result = ServiceContextHelper.read( inputStream );

        cachedServiceContexts.put( integerId, result );
    }

    // Good citizen: For increased efficiency, we assume that interceptors
    // will not modify the returned ServiceContext.  Otherwise, we would
    // have to make a deep copy.

    return result;
}
 
Example 9
Source File: CorbaClientRequestDispatcherImpl.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
protected void consumeServiceContexts(ORB orb,
                                    CorbaMessageMediator messageMediator)
{
    ServiceContexts ctxts = messageMediator.getReplyServiceContexts();
    ServiceContext sc ;
    ORBUtilSystemException wrapper = ORBUtilSystemException.get( orb,
            CORBALogDomains.RPC_PROTOCOL ) ;

    if (ctxts == null) {
        return; // no service context available, return gracefully.
    }

    sc = ctxts.get( SendingContextServiceContext.SERVICE_CONTEXT_ID ) ;

    if (sc != null) {
        SendingContextServiceContext scsc =
            (SendingContextServiceContext)sc ;
        IOR ior = scsc.getIOR() ;

        try {
            // set the codebase returned by the server
            if (messageMediator.getConnection() != null) {
                ((CorbaConnection)messageMediator.getConnection()).setCodeBaseIOR(ior);
            }
        } catch (ThreadDeath td) {
            throw td ;
        } catch (Throwable t) {
            throw wrapper.badStringifiedIor( t ) ;
        }
    }

    // see if the version subcontract is present, if yes, then set
    // the ORBversion
    sc = ctxts.get( ORBVersionServiceContext.SERVICE_CONTEXT_ID ) ;

    if (sc != null) {
        ORBVersionServiceContext ovsc =
           (ORBVersionServiceContext) sc;

        ORBVersion version = ovsc.getVersion();
        orb.setORBVersion( version ) ;
    }

    getExceptionDetailMessage(messageMediator, wrapper);
}
 
Example 10
Source File: CorbaServerRequestDispatcherImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Handles setting the connection's code sets if required.
 * Returns true if the CodeSetContext was in the request, false
 * otherwise.
 */
protected boolean processCodeSetContext(
    CorbaMessageMediator request, ServiceContexts contexts)
{
    try {
        if (orb.subcontractDebugFlag) {
            dprint(".processCodeSetContext->: " + opAndId(request));
        }

        ServiceContext sc = contexts.get(
            CodeSetServiceContext.SERVICE_CONTEXT_ID);
        if (sc != null) {
            // Somehow a code set service context showed up in the local case.
            if (request.getConnection() == null) {
                return true;
            }

            // If it's GIOP 1.0, it shouldn't have this context at all.  Our legacy
            // ORBs sent it and we need to know if it's here to make ORB versioning
            // decisions, but we don't use the contents.
            if (request.getGIOPVersion().equals(GIOPVersion.V1_0)) {
                return true;
            }

            CodeSetServiceContext cssc = (CodeSetServiceContext)sc ;
            CodeSetComponentInfo.CodeSetContext csctx = cssc.getCodeSetContext();

            // Note on threading:
            //
            // getCodeSetContext and setCodeSetContext are synchronized
            // on the Connection.  At worst, this will result in
            // multiple threads entering this block and calling
            // setCodeSetContext but not actually changing the
            // values on the Connection.
            //
            // Alternative would be to lock the connection for the
            // whole block, but it's fine either way.

            // The connection's codeSetContext is null until we've received a
            // request with a code set context with the negotiated code sets.
            if (((CorbaConnection)request.getConnection())
                .getCodeSetContext() == null)
            {

                // Use these code sets on this connection
                if (orb.subcontractDebugFlag) {
                    dprint(".processCodeSetContext: " + opAndId(request)
                           + ": Setting code sets to: " + csctx);
                }

                ((CorbaConnection)request.getConnection())
                    .setCodeSetContext(csctx);

                // We had to read the method name using ISO 8859-1
                // (which is the default in the CDRInputStream for
                // char data), but now we may have a new char
                // code set.  If it isn't ISO8859-1, we must tell
                // the CDR stream to null any converter references
                // it has created so that it will reacquire
                // the code sets again using the new info.
                //
                // This should probably compare with the stream's
                // char code set rather than assuming it's ISO8859-1.
                // (However, the operation name is almost certainly
                // ISO8859-1 or ASCII.)
                if (csctx.getCharCodeSet() !=
                    OSFCodeSetRegistry.ISO_8859_1.getNumber()) {
                    ((MarshalInputStream)request.getInputObject())
                        .resetCodeSetConverters();
                }
            }
        }

        // If no code set information is ever sent from the client,
        // the server will use ISO8859-1 for char and throw an
        // exception for any wchar transmissions.
        //
        // In the local case, we use ORB provided streams for
        // marshaling and unmarshaling.  Currently, they use
        // ISO8859-1 for char/string and UTF16 for wchar/wstring.
        return sc != null ;
    } finally {
        if (orb.subcontractDebugFlag) {
            dprint(".processCodeSetContext<-: " + opAndId(request));
        }
    }
}
 
Example 11
Source File: CorbaClientRequestDispatcherImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
protected void consumeServiceContexts(ORB orb,
                                    CorbaMessageMediator messageMediator)
{
    ServiceContexts ctxts = messageMediator.getReplyServiceContexts();
    ServiceContext sc ;
    ORBUtilSystemException wrapper = ORBUtilSystemException.get( orb,
            CORBALogDomains.RPC_PROTOCOL ) ;

    if (ctxts == null) {
        return; // no service context available, return gracefully.
    }

    sc = ctxts.get( SendingContextServiceContext.SERVICE_CONTEXT_ID ) ;

    if (sc != null) {
        SendingContextServiceContext scsc =
            (SendingContextServiceContext)sc ;
        IOR ior = scsc.getIOR() ;

        try {
            // set the codebase returned by the server
            if (messageMediator.getConnection() != null) {
                ((CorbaConnection)messageMediator.getConnection()).setCodeBaseIOR(ior);
            }
        } catch (ThreadDeath td) {
            throw td ;
        } catch (Throwable t) {
            throw wrapper.badStringifiedIor( t ) ;
        }
    }

    // see if the version subcontract is present, if yes, then set
    // the ORBversion
    sc = ctxts.get( ORBVersionServiceContext.SERVICE_CONTEXT_ID ) ;

    if (sc != null) {
        ORBVersionServiceContext ovsc =
           (ORBVersionServiceContext) sc;

        ORBVersion version = ovsc.getVersion();
        orb.setORBVersion( version ) ;
    }

    getExceptionDetailMessage(messageMediator, wrapper);
}
 
Example 12
Source File: CorbaServerRequestDispatcherImpl.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * Handles setting the connection's code sets if required.
 * Returns true if the CodeSetContext was in the request, false
 * otherwise.
 */
protected boolean processCodeSetContext(
    CorbaMessageMediator request, ServiceContexts contexts)
{
    try {
        if (orb.subcontractDebugFlag) {
            dprint(".processCodeSetContext->: " + opAndId(request));
        }

        ServiceContext sc = contexts.get(
            CodeSetServiceContext.SERVICE_CONTEXT_ID);
        if (sc != null) {
            // Somehow a code set service context showed up in the local case.
            if (request.getConnection() == null) {
                return true;
            }

            // If it's GIOP 1.0, it shouldn't have this context at all.  Our legacy
            // ORBs sent it and we need to know if it's here to make ORB versioning
            // decisions, but we don't use the contents.
            if (request.getGIOPVersion().equals(GIOPVersion.V1_0)) {
                return true;
            }

            CodeSetServiceContext cssc = (CodeSetServiceContext)sc ;
            CodeSetComponentInfo.CodeSetContext csctx = cssc.getCodeSetContext();

            // Note on threading:
            //
            // getCodeSetContext and setCodeSetContext are synchronized
            // on the Connection.  At worst, this will result in
            // multiple threads entering this block and calling
            // setCodeSetContext but not actually changing the
            // values on the Connection.
            //
            // Alternative would be to lock the connection for the
            // whole block, but it's fine either way.

            // The connection's codeSetContext is null until we've received a
            // request with a code set context with the negotiated code sets.
            if (((CorbaConnection)request.getConnection())
                .getCodeSetContext() == null)
            {

                // Use these code sets on this connection
                if (orb.subcontractDebugFlag) {
                    dprint(".processCodeSetContext: " + opAndId(request)
                           + ": Setting code sets to: " + csctx);
                }

                ((CorbaConnection)request.getConnection())
                    .setCodeSetContext(csctx);

                // We had to read the method name using ISO 8859-1
                // (which is the default in the CDRInputStream for
                // char data), but now we may have a new char
                // code set.  If it isn't ISO8859-1, we must tell
                // the CDR stream to null any converter references
                // it has created so that it will reacquire
                // the code sets again using the new info.
                //
                // This should probably compare with the stream's
                // char code set rather than assuming it's ISO8859-1.
                // (However, the operation name is almost certainly
                // ISO8859-1 or ASCII.)
                if (csctx.getCharCodeSet() !=
                    OSFCodeSetRegistry.ISO_8859_1.getNumber()) {
                    ((MarshalInputStream)request.getInputObject())
                        .resetCodeSetConverters();
                }
            }
        }

        // If no code set information is ever sent from the client,
        // the server will use ISO8859-1 for char and throw an
        // exception for any wchar transmissions.
        //
        // In the local case, we use ORB provided streams for
        // marshaling and unmarshaling.  Currently, they use
        // ISO8859-1 for char/string and UTF16 for wchar/wstring.
        return sc != null ;
    } finally {
        if (orb.subcontractDebugFlag) {
            dprint(".processCodeSetContext<-: " + opAndId(request));
        }
    }
}
 
Example 13
Source File: CorbaClientRequestDispatcherImpl.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
protected void consumeServiceContexts(ORB orb,
                                    CorbaMessageMediator messageMediator)
{
    ServiceContexts ctxts = messageMediator.getReplyServiceContexts();
    ServiceContext sc ;
    ORBUtilSystemException wrapper = ORBUtilSystemException.get( orb,
            CORBALogDomains.RPC_PROTOCOL ) ;

    if (ctxts == null) {
        return; // no service context available, return gracefully.
    }

    sc = ctxts.get( SendingContextServiceContext.SERVICE_CONTEXT_ID ) ;

    if (sc != null) {
        SendingContextServiceContext scsc =
            (SendingContextServiceContext)sc ;
        IOR ior = scsc.getIOR() ;

        try {
            // set the codebase returned by the server
            if (messageMediator.getConnection() != null) {
                ((CorbaConnection)messageMediator.getConnection()).setCodeBaseIOR(ior);
            }
        } catch (ThreadDeath td) {
            throw td ;
        } catch (Throwable t) {
            throw wrapper.badStringifiedIor( t ) ;
        }
    }

    // see if the version subcontract is present, if yes, then set
    // the ORBversion
    sc = ctxts.get( ORBVersionServiceContext.SERVICE_CONTEXT_ID ) ;

    if (sc != null) {
        ORBVersionServiceContext ovsc =
           (ORBVersionServiceContext) sc;

        ORBVersion version = ovsc.getVersion();
        orb.setORBVersion( version ) ;
    }

    getExceptionDetailMessage(messageMediator, wrapper);
}
 
Example 14
Source File: CorbaClientRequestDispatcherImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
protected void consumeServiceContexts(ORB orb,
                                    CorbaMessageMediator messageMediator)
{
    ServiceContexts ctxts = messageMediator.getReplyServiceContexts();
    ServiceContext sc ;
    ORBUtilSystemException wrapper = ORBUtilSystemException.get( orb,
            CORBALogDomains.RPC_PROTOCOL ) ;

    if (ctxts == null) {
        return; // no service context available, return gracefully.
    }

    sc = ctxts.get( SendingContextServiceContext.SERVICE_CONTEXT_ID ) ;

    if (sc != null) {
        SendingContextServiceContext scsc =
            (SendingContextServiceContext)sc ;
        IOR ior = scsc.getIOR() ;

        try {
            // set the codebase returned by the server
            if (messageMediator.getConnection() != null) {
                ((CorbaConnection)messageMediator.getConnection()).setCodeBaseIOR(ior);
            }
        } catch (ThreadDeath td) {
            throw td ;
        } catch (Throwable t) {
            throw wrapper.badStringifiedIor( t ) ;
        }
    }

    // see if the version subcontract is present, if yes, then set
    // the ORBversion
    sc = ctxts.get( ORBVersionServiceContext.SERVICE_CONTEXT_ID ) ;

    if (sc != null) {
        ORBVersionServiceContext ovsc =
           (ORBVersionServiceContext) sc;

        ORBVersion version = ovsc.getVersion();
        orb.setORBVersion( version ) ;
    }

    getExceptionDetailMessage(messageMediator, wrapper);
}
 
Example 15
Source File: CorbaServerRequestDispatcherImpl.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Handles setting the connection's code sets if required.
 * Returns true if the CodeSetContext was in the request, false
 * otherwise.
 */
protected boolean processCodeSetContext(
    CorbaMessageMediator request, ServiceContexts contexts)
{
    try {
        if (orb.subcontractDebugFlag) {
            dprint(".processCodeSetContext->: " + opAndId(request));
        }

        ServiceContext sc = contexts.get(
            CodeSetServiceContext.SERVICE_CONTEXT_ID);
        if (sc != null) {
            // Somehow a code set service context showed up in the local case.
            if (request.getConnection() == null) {
                return true;
            }

            // If it's GIOP 1.0, it shouldn't have this context at all.  Our legacy
            // ORBs sent it and we need to know if it's here to make ORB versioning
            // decisions, but we don't use the contents.
            if (request.getGIOPVersion().equals(GIOPVersion.V1_0)) {
                return true;
            }

            CodeSetServiceContext cssc = (CodeSetServiceContext)sc ;
            CodeSetComponentInfo.CodeSetContext csctx = cssc.getCodeSetContext();

            // Note on threading:
            //
            // getCodeSetContext and setCodeSetContext are synchronized
            // on the Connection.  At worst, this will result in
            // multiple threads entering this block and calling
            // setCodeSetContext but not actually changing the
            // values on the Connection.
            //
            // Alternative would be to lock the connection for the
            // whole block, but it's fine either way.

            // The connection's codeSetContext is null until we've received a
            // request with a code set context with the negotiated code sets.
            if (((CorbaConnection)request.getConnection())
                .getCodeSetContext() == null)
            {

                // Use these code sets on this connection
                if (orb.subcontractDebugFlag) {
                    dprint(".processCodeSetContext: " + opAndId(request)
                           + ": Setting code sets to: " + csctx);
                }

                ((CorbaConnection)request.getConnection())
                    .setCodeSetContext(csctx);

                // We had to read the method name using ISO 8859-1
                // (which is the default in the CDRInputStream for
                // char data), but now we may have a new char
                // code set.  If it isn't ISO8859-1, we must tell
                // the CDR stream to null any converter references
                // it has created so that it will reacquire
                // the code sets again using the new info.
                //
                // This should probably compare with the stream's
                // char code set rather than assuming it's ISO8859-1.
                // (However, the operation name is almost certainly
                // ISO8859-1 or ASCII.)
                if (csctx.getCharCodeSet() !=
                    OSFCodeSetRegistry.ISO_8859_1.getNumber()) {
                    ((MarshalInputStream)request.getInputObject())
                        .resetCodeSetConverters();
                }
            }
        }

        // If no code set information is ever sent from the client,
        // the server will use ISO8859-1 for char and throw an
        // exception for any wchar transmissions.
        //
        // In the local case, we use ORB provided streams for
        // marshaling and unmarshaling.  Currently, they use
        // ISO8859-1 for char/string and UTF16 for wchar/wstring.
        return sc != null ;
    } finally {
        if (orb.subcontractDebugFlag) {
            dprint(".processCodeSetContext<-: " + opAndId(request));
        }
    }
}
 
Example 16
Source File: CorbaClientRequestDispatcherImpl.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
protected void consumeServiceContexts(ORB orb,
                                    CorbaMessageMediator messageMediator)
{
    ServiceContexts ctxts = messageMediator.getReplyServiceContexts();
    ServiceContext sc ;
    ORBUtilSystemException wrapper = ORBUtilSystemException.get( orb,
            CORBALogDomains.RPC_PROTOCOL ) ;

    if (ctxts == null) {
        return; // no service context available, return gracefully.
    }

    sc = ctxts.get( SendingContextServiceContext.SERVICE_CONTEXT_ID ) ;

    if (sc != null) {
        SendingContextServiceContext scsc =
            (SendingContextServiceContext)sc ;
        IOR ior = scsc.getIOR() ;

        try {
            // set the codebase returned by the server
            if (messageMediator.getConnection() != null) {
                ((CorbaConnection)messageMediator.getConnection()).setCodeBaseIOR(ior);
            }
        } catch (ThreadDeath td) {
            throw td ;
        } catch (Throwable t) {
            throw wrapper.badStringifiedIor( t ) ;
        }
    }

    // see if the version subcontract is present, if yes, then set
    // the ORBversion
    sc = ctxts.get( ORBVersionServiceContext.SERVICE_CONTEXT_ID ) ;

    if (sc != null) {
        ORBVersionServiceContext ovsc =
           (ORBVersionServiceContext) sc;

        ORBVersion version = ovsc.getVersion();
        orb.setORBVersion( version ) ;
    }

    getExceptionDetailMessage(messageMediator, wrapper);
}
 
Example 17
Source File: RequestInfoImpl.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Utility method to look up a service context with the given id and
 * convert it to an IOP.ServiceContext.  Uses the given HashMap as
 * a cache.  If not found in cache, the result is inserted in the cache.
 */
protected org.omg.IOP.ServiceContext
    getServiceContext ( HashMap cachedServiceContexts,
                        ServiceContexts serviceContexts, int id )
{
    org.omg.IOP.ServiceContext result = null;
    Integer integerId = new Integer( id );

    // Search cache first:
    result = (org.omg.IOP.ServiceContext)
        cachedServiceContexts.get( integerId );

    // null could normally mean that either we cached the value null
    // or it's not in the cache.  However, there is no way for us to
    // cache the value null in the following code.
    if( result == null ) {
        // Not in cache.  Find it and put in cache.
        // Get the desired "core" service context.
        com.sun.corba.se.spi.servicecontext.ServiceContext context =
            serviceContexts.get( id );
        if (context == null)
            throw stdWrapper.invalidServiceContextId() ;

        // Convert the "core" service context to an
        // "IOP" ServiceContext by writing it to a
        // CDROutputStream and reading it back.
        EncapsOutputStream out =
            sun.corba.OutputStreamFactory.newEncapsOutputStream(myORB);

        context.write( out, GIOPVersion.V1_2 );
        InputStream inputStream = out.create_input_stream();
        result = ServiceContextHelper.read( inputStream );

        cachedServiceContexts.put( integerId, result );
    }

    // Good citizen: For increased efficiency, we assume that interceptors
    // will not modify the returned ServiceContext.  Otherwise, we would
    // have to make a deep copy.

    return result;
}
 
Example 18
Source File: RequestInfoImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Utility method to look up a service context with the given id and
 * convert it to an IOP.ServiceContext.  Uses the given HashMap as
 * a cache.  If not found in cache, the result is inserted in the cache.
 */
protected org.omg.IOP.ServiceContext
    getServiceContext ( HashMap cachedServiceContexts,
                        ServiceContexts serviceContexts, int id )
{
    org.omg.IOP.ServiceContext result = null;
    Integer integerId = new Integer( id );

    // Search cache first:
    result = (org.omg.IOP.ServiceContext)
        cachedServiceContexts.get( integerId );

    // null could normally mean that either we cached the value null
    // or it's not in the cache.  However, there is no way for us to
    // cache the value null in the following code.
    if( result == null ) {
        // Not in cache.  Find it and put in cache.
        // Get the desired "core" service context.
        com.sun.corba.se.spi.servicecontext.ServiceContext context =
            serviceContexts.get( id );
        if (context == null)
            throw stdWrapper.invalidServiceContextId() ;

        // Convert the "core" service context to an
        // "IOP" ServiceContext by writing it to a
        // CDROutputStream and reading it back.
        EncapsOutputStream out =
            sun.corba.OutputStreamFactory.newEncapsOutputStream(myORB);

        context.write( out, GIOPVersion.V1_2 );
        InputStream inputStream = out.create_input_stream();
        result = ServiceContextHelper.read( inputStream );

        cachedServiceContexts.put( integerId, result );
    }

    // Good citizen: For increased efficiency, we assume that interceptors
    // will not modify the returned ServiceContext.  Otherwise, we would
    // have to make a deep copy.

    return result;
}
 
Example 19
Source File: CorbaClientRequestDispatcherImpl.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
protected void consumeServiceContexts(ORB orb,
                                    CorbaMessageMediator messageMediator)
{
    ServiceContexts ctxts = messageMediator.getReplyServiceContexts();
    ServiceContext sc ;
    ORBUtilSystemException wrapper = ORBUtilSystemException.get( orb,
            CORBALogDomains.RPC_PROTOCOL ) ;

    if (ctxts == null) {
        return; // no service context available, return gracefully.
    }

    sc = ctxts.get( SendingContextServiceContext.SERVICE_CONTEXT_ID ) ;

    if (sc != null) {
        SendingContextServiceContext scsc =
            (SendingContextServiceContext)sc ;
        IOR ior = scsc.getIOR() ;

        try {
            // set the codebase returned by the server
            if (messageMediator.getConnection() != null) {
                ((CorbaConnection)messageMediator.getConnection()).setCodeBaseIOR(ior);
            }
        } catch (ThreadDeath td) {
            throw td ;
        } catch (Throwable t) {
            throw wrapper.badStringifiedIor( t ) ;
        }
    }

    // see if the version subcontract is present, if yes, then set
    // the ORBversion
    sc = ctxts.get( ORBVersionServiceContext.SERVICE_CONTEXT_ID ) ;

    if (sc != null) {
        ORBVersionServiceContext ovsc =
           (ORBVersionServiceContext) sc;

        ORBVersion version = ovsc.getVersion();
        orb.setORBVersion( version ) ;
    }

    getExceptionDetailMessage(messageMediator, wrapper);
}
 
Example 20
Source File: CorbaServerRequestDispatcherImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Handles setting the connection's code sets if required.
 * Returns true if the CodeSetContext was in the request, false
 * otherwise.
 */
protected boolean processCodeSetContext(
    CorbaMessageMediator request, ServiceContexts contexts)
{
    try {
        if (orb.subcontractDebugFlag) {
            dprint(".processCodeSetContext->: " + opAndId(request));
        }

        ServiceContext sc = contexts.get(
            CodeSetServiceContext.SERVICE_CONTEXT_ID);
        if (sc != null) {
            // Somehow a code set service context showed up in the local case.
            if (request.getConnection() == null) {
                return true;
            }

            // If it's GIOP 1.0, it shouldn't have this context at all.  Our legacy
            // ORBs sent it and we need to know if it's here to make ORB versioning
            // decisions, but we don't use the contents.
            if (request.getGIOPVersion().equals(GIOPVersion.V1_0)) {
                return true;
            }

            CodeSetServiceContext cssc = (CodeSetServiceContext)sc ;
            CodeSetComponentInfo.CodeSetContext csctx = cssc.getCodeSetContext();

            // Note on threading:
            //
            // getCodeSetContext and setCodeSetContext are synchronized
            // on the Connection.  At worst, this will result in
            // multiple threads entering this block and calling
            // setCodeSetContext but not actually changing the
            // values on the Connection.
            //
            // Alternative would be to lock the connection for the
            // whole block, but it's fine either way.

            // The connection's codeSetContext is null until we've received a
            // request with a code set context with the negotiated code sets.
            if (((CorbaConnection)request.getConnection())
                .getCodeSetContext() == null)
            {

                // Use these code sets on this connection
                if (orb.subcontractDebugFlag) {
                    dprint(".processCodeSetContext: " + opAndId(request)
                           + ": Setting code sets to: " + csctx);
                }

                ((CorbaConnection)request.getConnection())
                    .setCodeSetContext(csctx);

                // We had to read the method name using ISO 8859-1
                // (which is the default in the CDRInputStream for
                // char data), but now we may have a new char
                // code set.  If it isn't ISO8859-1, we must tell
                // the CDR stream to null any converter references
                // it has created so that it will reacquire
                // the code sets again using the new info.
                //
                // This should probably compare with the stream's
                // char code set rather than assuming it's ISO8859-1.
                // (However, the operation name is almost certainly
                // ISO8859-1 or ASCII.)
                if (csctx.getCharCodeSet() !=
                    OSFCodeSetRegistry.ISO_8859_1.getNumber()) {
                    ((MarshalInputStream)request.getInputObject())
                        .resetCodeSetConverters();
                }
            }
        }

        // If no code set information is ever sent from the client,
        // the server will use ISO8859-1 for char and throw an
        // exception for any wchar transmissions.
        //
        // In the local case, we use ORB provided streams for
        // marshaling and unmarshaling.  Currently, they use
        // ISO8859-1 for char/string and UTF16 for wchar/wstring.
        return sc != null ;
    } finally {
        if (orb.subcontractDebugFlag) {
            dprint(".processCodeSetContext<-: " + opAndId(request));
        }
    }
}