Java Code Examples for com.sun.corba.se.spi.protocol.CorbaMessageMediator#getConnection()

The following examples show how to use com.sun.corba.se.spi.protocol.CorbaMessageMediator#getConnection() . 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: CDROutputObject.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private CDROutputObject(
    ORB orb, GIOPVersion giopVersion, Message header,
    BufferManagerWrite manager, byte streamFormatVersion,
    CorbaMessageMediator mediator)
{
    super(orb, giopVersion, header.getEncodingVersion(),
          false, manager, streamFormatVersion,
          ((mediator != null && mediator.getConnection() != null) ?
           ((CorbaConnection)mediator.getConnection()).
                 shouldUseDirectByteBuffers() : false));

    this.header = header;
    this.orb = orb;
    this.wrapper = ORBUtilSystemException.get( orb, CORBALogDomains.RPC_ENCODING ) ;
    this.omgWrapper = OMGSystemException.get( orb, CORBALogDomains.RPC_ENCODING ) ;

    getBufferManager().setOutputObject(this);
    this.corbaMessageMediator = mediator;
}
 
Example 2
Source File: CDROutputObject.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private CDROutputObject(
    ORB orb, GIOPVersion giopVersion, Message header,
    BufferManagerWrite manager, byte streamFormatVersion,
    CorbaMessageMediator mediator)
{
    super(orb, giopVersion, header.getEncodingVersion(),
          false, manager, streamFormatVersion,
          ((mediator != null && mediator.getConnection() != null) ?
           ((CorbaConnection)mediator.getConnection()).
                 shouldUseDirectByteBuffers() : false));

    this.header = header;
    this.orb = orb;
    this.wrapper = ORBUtilSystemException.get( orb, CORBALogDomains.RPC_ENCODING ) ;
    this.omgWrapper = OMGSystemException.get( orb, CORBALogDomains.RPC_ENCODING ) ;

    getBufferManager().setOutputObject(this);
    this.corbaMessageMediator = mediator;
}
 
Example 3
Source File: CDROutputObject.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private CDROutputObject(
    ORB orb, GIOPVersion giopVersion, Message header,
    BufferManagerWrite manager, byte streamFormatVersion,
    CorbaMessageMediator mediator)
{
    super(orb, giopVersion, header.getEncodingVersion(),
          false, manager, streamFormatVersion,
          ((mediator != null && mediator.getConnection() != null) ?
           ((CorbaConnection)mediator.getConnection()).
                 shouldUseDirectByteBuffers() : false));

    this.header = header;
    this.orb = orb;
    this.wrapper = ORBUtilSystemException.get( orb, CORBALogDomains.RPC_ENCODING ) ;
    this.omgWrapper = OMGSystemException.get( orb, CORBALogDomains.RPC_ENCODING ) ;

    getBufferManager().setOutputObject(this);
    this.corbaMessageMediator = mediator;
}
 
Example 4
Source File: CDROutputObject.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private CDROutputObject(
    ORB orb, GIOPVersion giopVersion, Message header,
    BufferManagerWrite manager, byte streamFormatVersion,
    CorbaMessageMediator mediator)
{
    super(orb, giopVersion, header.getEncodingVersion(),
          false, manager, streamFormatVersion,
          ((mediator != null && mediator.getConnection() != null) ?
           ((CorbaConnection)mediator.getConnection()).
                 shouldUseDirectByteBuffers() : false));

    this.header = header;
    this.orb = orb;
    this.wrapper = ORBUtilSystemException.get( orb, CORBALogDomains.RPC_ENCODING ) ;
    this.omgWrapper = OMGSystemException.get( orb, CORBALogDomains.RPC_ENCODING ) ;

    getBufferManager().setOutputObject(this);
    this.corbaMessageMediator = mediator;
}
 
Example 5
Source File: CDROutputObject.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
private CDROutputObject(
    ORB orb, GIOPVersion giopVersion, Message header,
    BufferManagerWrite manager, byte streamFormatVersion,
    CorbaMessageMediator mediator)
{
    super(orb, giopVersion, header.getEncodingVersion(),
          false, manager, streamFormatVersion,
          ((mediator != null && mediator.getConnection() != null) ?
           ((CorbaConnection)mediator.getConnection()).
                 shouldUseDirectByteBuffers() : false));

    this.header = header;
    this.orb = orb;
    this.wrapper = ORBUtilSystemException.get( orb, CORBALogDomains.RPC_ENCODING ) ;
    this.omgWrapper = OMGSystemException.get( orb, CORBALogDomains.RPC_ENCODING ) ;

    getBufferManager().setOutputObject(this);
    this.corbaMessageMediator = mediator;
}
 
Example 6
Source File: CorbaClientRequestDispatcherImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
protected void addServiceContexts(CorbaMessageMediator messageMediator)
{
    ORB orb = (ORB)messageMediator.getBroker();
    CorbaConnection c = (CorbaConnection) messageMediator.getConnection();
    GIOPVersion giopVersion = messageMediator.getGIOPVersion();

    ServiceContexts contexts = messageMediator.getRequestServiceContexts();

    addCodeSetServiceContext(c, contexts, giopVersion);

    // Add the RMI-IIOP max stream format version
    // service context to every request.  Once we have GIOP 1.3,
    // we could skip it since we now support version 2, but
    // probably safer to always send it.
    contexts.put(MaxStreamFormatVersionServiceContext.singleton);

    // ORBVersion servicecontext needs to be sent
    ORBVersionServiceContext ovsc = new ORBVersionServiceContext(
                    ORBVersionFactory.getORBVersion() ) ;
    contexts.put( ovsc ) ;

    // NOTE : We only want to send the runtime context the first time
    if ((c != null) && !c.isPostInitialContexts()) {
        // Do not do c.setPostInitialContexts() here.
        // If a client interceptor send_request does a ForwardRequest
        // which ends up using the same connection then the service
        // context would not be sent.
        SendingContextServiceContext scsc =
            new SendingContextServiceContext( orb.getFVDCodeBaseIOR() ) ; //d11638
        contexts.put( scsc ) ;
    }
}
 
Example 7
Source File: CorbaClientRequestDispatcherImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
protected void addServiceContexts(CorbaMessageMediator messageMediator)
{
    ORB orb = (ORB)messageMediator.getBroker();
    CorbaConnection c = (CorbaConnection) messageMediator.getConnection();
    GIOPVersion giopVersion = messageMediator.getGIOPVersion();

    ServiceContexts contexts = messageMediator.getRequestServiceContexts();

    addCodeSetServiceContext(c, contexts, giopVersion);

    // Add the RMI-IIOP max stream format version
    // service context to every request.  Once we have GIOP 1.3,
    // we could skip it since we now support version 2, but
    // probably safer to always send it.
    contexts.put(MaxStreamFormatVersionServiceContext.singleton);

    // ORBVersion servicecontext needs to be sent
    ORBVersionServiceContext ovsc = new ORBVersionServiceContext(
                    ORBVersionFactory.getORBVersion() ) ;
    contexts.put( ovsc ) ;

    // NOTE : We only want to send the runtime context the first time
    if ((c != null) && !c.isPostInitialContexts()) {
        // Do not do c.setPostInitialContexts() here.
        // If a client interceptor send_request does a ForwardRequest
        // which ends up using the same connection then the service
        // context would not be sent.
        SendingContextServiceContext scsc =
            new SendingContextServiceContext( orb.getFVDCodeBaseIOR() ) ; //d11638
        contexts.put( scsc ) ;
    }
}
 
Example 8
Source File: ServerRequestInfoImpl.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Stores the various sources of information used for this info object.
 */
protected void setInfo( CorbaMessageMediator request, ObjectAdapter oa,
    byte[] objectId, ObjectKeyTemplate oktemp )
{
    this.request = request;
    this.objectId = objectId;
    this.oktemp = oktemp;
    this.objectAdapter = oa ;
    this.connection = (com.sun.corba.se.spi.legacy.connection.Connection)
        request.getConnection();
}
 
Example 9
Source File: CorbaMessageMediatorImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
protected CorbaMessageMediator createResponseHelper(
    CorbaMessageMediator messageMediator, ReplyMessage reply, IOR ior)
{
    // REVISIT - these should be invoked from subcontract.
    runServantPostInvoke(messageMediator);
    runInterceptors(messageMediator, reply);
    runRemoveThreadInfo(messageMediator);

    if (((ORB)messageMediator.getBroker()).subcontractDebugFlag) {
        dprint(".createResponseHelper: "
               + opAndId(messageMediator) + ": "
               + reply);
    }

    messageMediator.setReplyHeader(reply);

    OutputObject replyOutputObject;
    // REVISIT = do not use null.
    //
    if (messageMediator.getConnection() == null) {
        replyOutputObject =
            sun.corba.OutputStreamFactory.newCDROutputObject(orb,
                        messageMediator, messageMediator.getReplyHeader(),
                        messageMediator.getStreamFormatVersion(),
                        BufferManagerFactory.GROW);
    } else {
        replyOutputObject = messageMediator.getConnection().getAcceptor()
         .createOutputObject(messageMediator.getBroker(), messageMediator);
    }
    messageMediator.setOutputObject(replyOutputObject);
    messageMediator.getOutputObject().setMessageMediator(messageMediator);

    reply.write((OutputStream) messageMediator.getOutputObject());
    if (reply.getIOR() != null) {
        reply.getIOR().write((OutputStream) messageMediator.getOutputObject());
    }
    // REVISIT - not necessary?
    //messageMediator.this.replyIOR = reply.getIOR();

    // NOTE: The mediator holds onto output object so return value
    // not really necessary.
    return messageMediator;
}
 
Example 10
Source File: CorbaMessageMediatorImpl.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
protected CorbaMessageMediator createResponseHelper(
    CorbaMessageMediator messageMediator, ReplyMessage reply, IOR ior)
{
    // REVISIT - these should be invoked from subcontract.
    runServantPostInvoke(messageMediator);
    runInterceptors(messageMediator, reply);
    runRemoveThreadInfo(messageMediator);

    if (((ORB)messageMediator.getBroker()).subcontractDebugFlag) {
        dprint(".createResponseHelper: "
               + opAndId(messageMediator) + ": "
               + reply);
    }

    messageMediator.setReplyHeader(reply);

    OutputObject replyOutputObject;
    // REVISIT = do not use null.
    //
    if (messageMediator.getConnection() == null) {
        replyOutputObject =
            sun.corba.OutputStreamFactory.newCDROutputObject(orb,
                        messageMediator, messageMediator.getReplyHeader(),
                        messageMediator.getStreamFormatVersion(),
                        BufferManagerFactory.GROW);
    } else {
        replyOutputObject = messageMediator.getConnection().getAcceptor()
         .createOutputObject(messageMediator.getBroker(), messageMediator);
    }
    messageMediator.setOutputObject(replyOutputObject);
    messageMediator.getOutputObject().setMessageMediator(messageMediator);

    reply.write((OutputStream) messageMediator.getOutputObject());
    if (reply.getIOR() != null) {
        reply.getIOR().write((OutputStream) messageMediator.getOutputObject());
    }
    // REVISIT - not necessary?
    //messageMediator.this.replyIOR = reply.getIOR();

    // NOTE: The mediator holds onto output object so return value
    // not really necessary.
    return messageMediator;
}
 
Example 11
Source File: CorbaClientRequestDispatcherImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
protected void registerWaiter(CorbaMessageMediator messageMediator)
{
    if (messageMediator.getConnection() != null) {
        messageMediator.getConnection().registerWaiter(messageMediator);
    }
}
 
Example 12
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 13
Source File: CorbaClientRequestDispatcherImpl.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
protected void performCodeSetNegotiation(CorbaMessageMediator messageMediator)
{
    CorbaConnection conn =
        (CorbaConnection) messageMediator.getConnection();
    IOR ior =
        ((CorbaContactInfo)messageMediator.getContactInfo())
        .getEffectiveTargetIOR();
    GIOPVersion giopVersion = messageMediator.getGIOPVersion();

    // XXX This seems to be a broken double checked locking idiom: FIX IT!

    // conn.getCodeSetContext() is null when no other requests have
    // been made on this connection to trigger code set negotation.
    if (conn != null &&
        conn.getCodeSetContext() == null &&
        !giopVersion.equals(GIOPVersion.V1_0)) {

        synchronized(conn) {
            // Double checking.  Don't let any other
            // threads use this connection until the
            // code sets are straight.
            if (conn.getCodeSetContext() != null)
                return;

            // This only looks at the first code set component.  If
            // there can be multiple locations with multiple code sets,
            // this requires more work.
            IIOPProfileTemplate temp =
                (IIOPProfileTemplate)ior.getProfile().
                getTaggedProfileTemplate();
            Iterator iter = temp.iteratorById(TAG_CODE_SETS.value);
            if (!iter.hasNext()) {
                // Didn't have a code set component.  The default will
                // be to use ISO8859-1 for char data and throw an
                // exception if wchar data is used.
                return;
            }

            // Get the native and conversion code sets the
            // server specified in its IOR
            CodeSetComponentInfo serverCodeSets
                = ((CodeSetsComponent)iter.next()).getCodeSetComponentInfo();

            // Perform the negotiation between this ORB's code sets and
            // the ones from the IOR
            CodeSetComponentInfo.CodeSetContext result
                = CodeSetConversion.impl().negotiate(
                      conn.getBroker().getORBData().getCodeSetComponentInfo(),
                      serverCodeSets);

            conn.setCodeSetContext(result);
        }
    }
}
 
Example 14
Source File: CorbaMessageMediatorImpl.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public CorbaMessageMediator createSystemExceptionResponse(
    CorbaMessageMediator messageMediator,
    SystemException ex,
    ServiceContexts svc)
{
    if (messageMediator.getConnection() != null) {
        // It is possible that fragments of response have already been
        // sent.  Then an error may occur (e.g. marshaling error like
        // non serializable object).  In that case it is too late
        // to send the exception.  We just return the existing fragmented
        // stream here.  This will cause an incomplete last fragment
        // to be sent.  Then the other side will get a marshaling error
        // when attempting to unmarshal.

        // REVISIT: Impl - make interface method to do the following.
        CorbaMessageMediatorImpl mediator = (CorbaMessageMediatorImpl)
            ((CorbaConnection)messageMediator.getConnection())
            .serverRequestMapGet(messageMediator.getRequestId());

        OutputObject existingOutputObject = null;
        if (mediator != null) {
            existingOutputObject = mediator.getOutputObject();
        }

        // REVISIT: need to think about messageMediator containing correct
        // pointer to output object.
        if (existingOutputObject != null &&
            mediator.sentFragment() &&
            ! mediator.sentFullMessage())
        {
            return mediator;
        }
    }

    // Only do this if interceptors have been initialized on this request
    // and have not completed their lifecycle (otherwise the info stack
    // may be empty or have a different request's entry on top).
    if (messageMediator.executePIInResponseConstructor()) {
        // REVISIT: not necessary in framework now?
        // Inform Portable Interceptors of the SystemException.  This is
        // required to be done here because the ending interception point
        // is called in the when creating the response below
        // but we do not currently write the SystemException into the
        // response until after the ending point is called.
        ((ORB)messageMediator.getBroker()).getPIHandler().setServerPIInfo( ex );
    }

    if (((ORB)messageMediator.getBroker()).subcontractDebugFlag &&
        ex != null)
    {
        dprint(".createSystemExceptionResponse: "
               + opAndId(messageMediator),
               ex);
    }

    ServiceContexts serviceContexts =
        getServiceContextsForReply(messageMediator, svc);

    // NOTE: We MUST add the service context before creating
    // the response since service contexts are written to the
    // stream when the response object is created.

    addExceptionDetailMessage(messageMediator, ex, serviceContexts);

    CorbaMessageMediator response =
        createResponseHelper(messageMediator, serviceContexts, false);

    // NOTE: From here on, it is too late to add more service contexts.
    // They have already been serialized to the stream (and maybe fragments
    // sent).

    ORBUtility.writeSystemException(
        ex, (OutputStream)response.getOutputObject());

    return response;
}
 
Example 15
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 16
Source File: CorbaMessageMediatorImpl.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
protected CorbaMessageMediator createResponseHelper(
    CorbaMessageMediator messageMediator, ReplyMessage reply, IOR ior)
{
    // REVISIT - these should be invoked from subcontract.
    runServantPostInvoke(messageMediator);
    runInterceptors(messageMediator, reply);
    runRemoveThreadInfo(messageMediator);

    if (((ORB)messageMediator.getBroker()).subcontractDebugFlag) {
        dprint(".createResponseHelper: "
               + opAndId(messageMediator) + ": "
               + reply);
    }

    messageMediator.setReplyHeader(reply);

    OutputObject replyOutputObject;
    // REVISIT = do not use null.
    //
    if (messageMediator.getConnection() == null) {
        replyOutputObject =
            sun.corba.OutputStreamFactory.newCDROutputObject(orb,
                        messageMediator, messageMediator.getReplyHeader(),
                        messageMediator.getStreamFormatVersion(),
                        BufferManagerFactory.GROW);
    } else {
        replyOutputObject = messageMediator.getConnection().getAcceptor()
         .createOutputObject(messageMediator.getBroker(), messageMediator);
    }
    messageMediator.setOutputObject(replyOutputObject);
    messageMediator.getOutputObject().setMessageMediator(messageMediator);

    reply.write((OutputStream) messageMediator.getOutputObject());
    if (reply.getIOR() != null) {
        reply.getIOR().write((OutputStream) messageMediator.getOutputObject());
    }
    // REVISIT - not necessary?
    //messageMediator.this.replyIOR = reply.getIOR();

    // NOTE: The mediator holds onto output object so return value
    // not really necessary.
    return messageMediator;
}
 
Example 17
Source File: CorbaMessageMediatorImpl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
protected ServiceContexts getServiceContextsForReply(
    CorbaMessageMediator messageMediator, ServiceContexts contexts)
{
    CorbaConnection c = (CorbaConnection) messageMediator.getConnection();

    if (((ORB)messageMediator.getBroker()).subcontractDebugFlag) {
        dprint(".getServiceContextsForReply: "
               + opAndId(messageMediator)
               + ": " + c);
    }

    if (contexts == null) {
        contexts = new ServiceContexts(((ORB)messageMediator.getBroker()));
    }

    // NOTE : We only want to send the runtime context the first time

    if (c != null && !c.isPostInitialContexts()) {
        c.setPostInitialContexts();
        SendingContextServiceContext scsc =
            new SendingContextServiceContext(
                ((ORB)messageMediator.getBroker()).getFVDCodeBaseIOR()) ;

        if (contexts.get( scsc.getId() ) != null)
            throw wrapper.duplicateSendingContextServiceContext() ;

        contexts.put( scsc ) ;

        if ( ((ORB)messageMediator.getBroker()).subcontractDebugFlag)
            dprint(".getServiceContextsForReply: "
                   + opAndId(messageMediator)
                   + ": added SendingContextServiceContext" ) ;
    }

    // send ORBVersion servicecontext as part of the Reply

    ORBVersionServiceContext ovsc
        = new ORBVersionServiceContext(ORBVersionFactory.getORBVersion());

    if (contexts.get( ovsc.getId() ) != null)
        throw wrapper.duplicateOrbVersionServiceContext() ;

    contexts.put( ovsc ) ;

    if ( ((ORB)messageMediator.getBroker()).subcontractDebugFlag)
        dprint(".getServiceContextsForReply: "
               + opAndId(messageMediator)
               + ": added ORB version service context");

    return contexts;
}
 
Example 18
Source File: CorbaMessageMediatorImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public CorbaMessageMediator createSystemExceptionResponse(
    CorbaMessageMediator messageMediator,
    SystemException ex,
    ServiceContexts svc)
{
    if (messageMediator.getConnection() != null) {
        // It is possible that fragments of response have already been
        // sent.  Then an error may occur (e.g. marshaling error like
        // non serializable object).  In that case it is too late
        // to send the exception.  We just return the existing fragmented
        // stream here.  This will cause an incomplete last fragment
        // to be sent.  Then the other side will get a marshaling error
        // when attempting to unmarshal.

        // REVISIT: Impl - make interface method to do the following.
        CorbaMessageMediatorImpl mediator = (CorbaMessageMediatorImpl)
            ((CorbaConnection)messageMediator.getConnection())
            .serverRequestMapGet(messageMediator.getRequestId());

        OutputObject existingOutputObject = null;
        if (mediator != null) {
            existingOutputObject = mediator.getOutputObject();
        }

        // REVISIT: need to think about messageMediator containing correct
        // pointer to output object.
        if (existingOutputObject != null &&
            mediator.sentFragment() &&
            ! mediator.sentFullMessage())
        {
            return mediator;
        }
    }

    // Only do this if interceptors have been initialized on this request
    // and have not completed their lifecycle (otherwise the info stack
    // may be empty or have a different request's entry on top).
    if (messageMediator.executePIInResponseConstructor()) {
        // REVISIT: not necessary in framework now?
        // Inform Portable Interceptors of the SystemException.  This is
        // required to be done here because the ending interception point
        // is called in the when creating the response below
        // but we do not currently write the SystemException into the
        // response until after the ending point is called.
        ((ORB)messageMediator.getBroker()).getPIHandler().setServerPIInfo( ex );
    }

    if (((ORB)messageMediator.getBroker()).subcontractDebugFlag &&
        ex != null)
    {
        dprint(".createSystemExceptionResponse: "
               + opAndId(messageMediator),
               ex);
    }

    ServiceContexts serviceContexts =
        getServiceContextsForReply(messageMediator, svc);

    // NOTE: We MUST add the service context before creating
    // the response since service contexts are written to the
    // stream when the response object is created.

    addExceptionDetailMessage(messageMediator, ex, serviceContexts);

    CorbaMessageMediator response =
        createResponseHelper(messageMediator, serviceContexts, false);

    // NOTE: From here on, it is too late to add more service contexts.
    // They have already been serialized to the stream (and maybe fragments
    // sent).

    ORBUtility.writeSystemException(
        ex, (OutputStream)response.getOutputObject());

    return response;
}
 
Example 19
Source File: CorbaClientRequestDispatcherImpl.java    From hottub 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: CorbaMessageMediatorImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
protected CorbaMessageMediator createResponseHelper(
    CorbaMessageMediator messageMediator, ReplyMessage reply, IOR ior)
{
    // REVISIT - these should be invoked from subcontract.
    runServantPostInvoke(messageMediator);
    runInterceptors(messageMediator, reply);
    runRemoveThreadInfo(messageMediator);

    if (((ORB)messageMediator.getBroker()).subcontractDebugFlag) {
        dprint(".createResponseHelper: "
               + opAndId(messageMediator) + ": "
               + reply);
    }

    messageMediator.setReplyHeader(reply);

    OutputObject replyOutputObject;
    // REVISIT = do not use null.
    //
    if (messageMediator.getConnection() == null) {
        replyOutputObject =
            sun.corba.OutputStreamFactory.newCDROutputObject(orb,
                        messageMediator, messageMediator.getReplyHeader(),
                        messageMediator.getStreamFormatVersion(),
                        BufferManagerFactory.GROW);
    } else {
        replyOutputObject = messageMediator.getConnection().getAcceptor()
         .createOutputObject(messageMediator.getBroker(), messageMediator);
    }
    messageMediator.setOutputObject(replyOutputObject);
    messageMediator.getOutputObject().setMessageMediator(messageMediator);

    reply.write((OutputStream) messageMediator.getOutputObject());
    if (reply.getIOR() != null) {
        reply.getIOR().write((OutputStream) messageMediator.getOutputObject());
    }
    // REVISIT - not necessary?
    //messageMediator.this.replyIOR = reply.getIOR();

    // NOTE: The mediator holds onto output object so return value
    // not really necessary.
    return messageMediator;
}