Java Code Examples for com.sun.corba.se.pept.protocol.MessageMediator#getInputObject()

The following examples show how to use com.sun.corba.se.pept.protocol.MessageMediator#getInputObject() . 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 hottub with GNU General Public License v2.0 4 votes vote down vote up
public void handleInput(FragmentMessage_1_2 header) throws IOException
{
    try {
        try {
            messageHeader = header;

            // Note:  We know it's a 1.2 fragment, we have the data, but
            // we need the IIOPInputStream instance to unmarshal the
            // request ID... but we need the request ID to get the
            // IIOPInputStream instance. So we peek at the raw bytes.

            header.unmarshalRequestID(dispatchByteBuffer);

            if (transportDebug()) {
                dprint(".FRAGMENT 1.2->: id/"
                       + header.getRequestId()
                       + ": more?: " + header.moreFragmentsToFollow()
                       + ": " + header);
            }

            MessageMediator mediator = null;
            InputObject inputObject = null;

            if (connection.isServer()) {
                mediator =
                    connection.serverRequestMapGet(header.getRequestId());
            } else {
                mediator =
                    connection.clientRequestMapGet(header.getRequestId());
            }
            if (mediator != null) {
                inputObject = mediator.getInputObject();
            }
            // See 1.1 comments.
            if (inputObject == null) {
                if (transportDebug()) {
                    dprint(".FRAGMENT 1.2: id/"
                           + header.getRequestId()
                           + ": ++++DISCARDING++++: "
                           + header);
                }
                // need to release dispatchByteBuffer to pool if
                // we are discarding
                releaseByteBufferToPool();
                return;
            }
            ((CDRInputObject)inputObject)
                .getBufferManager().processFragment(
                                 dispatchByteBuffer, header);

            // REVISIT: but if it is a server don't you have to remove the
            // stream from the map?
            if (! connection.isServer()) {
                /* REVISIT
                 * No need to do anything.
                 * Should we mark that last was received?
                 if (! header.moreFragmentsToFollow()) {
                 // Last fragment.
                 }
                */
            }
        } finally {
            // NOTE: This *must* come after queing the fragment
            // when using the selector to ensure fragments stay in order.
            setWorkThenReadOrResumeSelect(header);
        }
    } catch (Throwable t) {
        if (transportDebug())
            dprint(".FRAGMENT 1.2: id/"
                   + header.getRequestId()
                   + ": !!ERROR!!: "
                   + header, t);
        // Mask the exception from thread.;
    } finally {
        if (transportDebug()) dprint(".FRAGMENT 1.2<-: id/"
                                     + header.getRequestId()
                                     + ": "
                                     + header);
    }
}
 
Example 2
Source File: CorbaMessageMediatorImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public void handleInput(FragmentMessage_1_2 header) throws IOException
{
    try {
        try {
            messageHeader = header;

            // Note:  We know it's a 1.2 fragment, we have the data, but
            // we need the IIOPInputStream instance to unmarshal the
            // request ID... but we need the request ID to get the
            // IIOPInputStream instance. So we peek at the raw bytes.

            header.unmarshalRequestID(dispatchByteBuffer);

            if (transportDebug()) {
                dprint(".FRAGMENT 1.2->: id/"
                       + header.getRequestId()
                       + ": more?: " + header.moreFragmentsToFollow()
                       + ": " + header);
            }

            MessageMediator mediator = null;
            InputObject inputObject = null;

            if (connection.isServer()) {
                mediator =
                    connection.serverRequestMapGet(header.getRequestId());
            } else {
                mediator =
                    connection.clientRequestMapGet(header.getRequestId());
            }
            if (mediator != null) {
                inputObject = mediator.getInputObject();
            }
            // See 1.1 comments.
            if (inputObject == null) {
                if (transportDebug()) {
                    dprint(".FRAGMENT 1.2: id/"
                           + header.getRequestId()
                           + ": ++++DISCARDING++++: "
                           + header);
                }
                // need to release dispatchByteBuffer to pool if
                // we are discarding
                releaseByteBufferToPool();
                return;
            }
            ((CDRInputObject)inputObject)
                .getBufferManager().processFragment(
                                 dispatchByteBuffer, header);

            // REVISIT: but if it is a server don't you have to remove the
            // stream from the map?
            if (! connection.isServer()) {
                /* REVISIT
                 * No need to do anything.
                 * Should we mark that last was received?
                 if (! header.moreFragmentsToFollow()) {
                 // Last fragment.
                 }
                */
            }
        } finally {
            // NOTE: This *must* come after queing the fragment
            // when using the selector to ensure fragments stay in order.
            setWorkThenReadOrResumeSelect(header);
        }
    } catch (Throwable t) {
        if (transportDebug())
            dprint(".FRAGMENT 1.2: id/"
                   + header.getRequestId()
                   + ": !!ERROR!!: "
                   + header, t);
        // Mask the exception from thread.;
    } finally {
        if (transportDebug()) dprint(".FRAGMENT 1.2<-: id/"
                                     + header.getRequestId()
                                     + ": "
                                     + header);
    }
}
 
Example 3
Source File: CorbaClientRequestDispatcherImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public void endRequest(Broker broker, Object self, InputObject inputObject)
{
    ORB orb = (ORB)broker ;

    try {
        if (orb.subcontractDebugFlag) {
            dprint(".endRequest->");
        }

        // Note: the inputObject may be null if an error occurs
        //       in request or before _invoke returns.
        // Note: self may be null also (e.g., compiler generates null in stub).

        MessageMediator messageMediator =
            orb.getInvocationInfo().getMessageMediator();
        if (messageMediator != null)
        {
            if (messageMediator.getConnection() != null)
            {
                ((CorbaMessageMediator)messageMediator)
                          .sendCancelRequestIfFinalFragmentNotSent();
            }

            // Release any outstanding NIO ByteBuffers to the ByteBufferPool

            InputObject inputObj = messageMediator.getInputObject();
            if (inputObj != null) {
                inputObj.close();
            }

            OutputObject outputObj = messageMediator.getOutputObject();
            if (outputObj != null) {
                outputObj.close();
            }

        }

        // XREVISIT NOTE - Assumes unregistering the waiter for
        // location forwards has already happened somewhere else.
        // The code below is only going to unregister the final successful
        // request.

        // NOTE: In the case of a recursive stack of endRequests in a
        // finally block (because of Remarshal) only the first call to
        // unregisterWaiter will remove the waiter.  The rest will be
        // noops.
        unregisterWaiter(orb);

        // Invoke Portable Interceptors cleanup.  This is done to handle
        // exceptions during stream marshaling.  More generally, exceptions
        // that occur in the ORB after send_request (which includes
        // after returning from _request) before _invoke:
        orb.getPIHandler().cleanupClientPIRequest();

        // REVISIT: Early replies?
    } catch (IOException ex) {
        // See CDRInput/OutputObject.close() for more info.
        // This won't result in a Corba error if an IOException happens.
        if (orb.subcontractDebugFlag)
        {
            dprint(".endRequest: ignoring IOException - " + ex.toString());
        }
    } finally {
        if (orb.subcontractDebugFlag) {
            dprint(".endRequest<-");
        }
    }
}
 
Example 4
Source File: CDROutputStream_1_0.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public void close() throws IOException
{
    // tell BufferManagerWrite to release any ByteBuffers
    getBufferManager().close();

    // It's possible bbwi.byteBuffer is shared between
    // this OutputStream and an InputStream. Thus, we check
    // if the Input/Output streams are using the same ByteBuffer.
    // If they sharing the same ByteBuffer we need to ensure only
    // one of those ByteBuffers are released to the ByteBufferPool.

    if (getByteBufferWithInfo() != null && getByteBuffer() != null)
    {
        MessageMediator messageMediator = parent.getMessageMediator();
        if (messageMediator != null)
        {
            CDRInputObject inputObj =
                           (CDRInputObject)messageMediator.getInputObject();
            if (inputObj != null)
            {
                if (inputObj.isSharing(getByteBuffer()))
                {
                    // Set InputStream's ByteBuffer and bbwi to null
                    // so its ByteBuffer cannot be released to the pool
                    inputObj.setByteBuffer(null);
                    inputObj.setByteBufferWithInfo(null);
                }
            }
        }

        // release this stream's ByteBuffer to the pool
        ByteBufferPool byteBufferPool = orb.getByteBufferPool();
        if (debug)
        {
            // print address of ByteBuffer being released
            int bbAddress = System.identityHashCode(bbwi.byteBuffer);
            StringBuffer sb = new StringBuffer(80);
            sb.append(".close - releasing ByteBuffer id (");
            sb.append(bbAddress).append(") to ByteBufferPool.");
            String msg = sb.toString();
            dprint(msg);
         }
         byteBufferPool.releaseByteBuffer(getByteBuffer());
         bbwi.byteBuffer = null;
         bbwi = null;
    }
}
 
Example 5
Source File: CorbaMessageMediatorImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public void handleInput(FragmentMessage_1_2 header) throws IOException
{
    try {
        try {
            messageHeader = header;

            // Note:  We know it's a 1.2 fragment, we have the data, but
            // we need the IIOPInputStream instance to unmarshal the
            // request ID... but we need the request ID to get the
            // IIOPInputStream instance. So we peek at the raw bytes.

            header.unmarshalRequestID(dispatchByteBuffer);

            if (transportDebug()) {
                dprint(".FRAGMENT 1.2->: id/"
                       + header.getRequestId()
                       + ": more?: " + header.moreFragmentsToFollow()
                       + ": " + header);
            }

            MessageMediator mediator = null;
            InputObject inputObject = null;

            if (connection.isServer()) {
                mediator =
                    connection.serverRequestMapGet(header.getRequestId());
            } else {
                mediator =
                    connection.clientRequestMapGet(header.getRequestId());
            }
            if (mediator != null) {
                inputObject = mediator.getInputObject();
            }
            // See 1.1 comments.
            if (inputObject == null) {
                if (transportDebug()) {
                    dprint(".FRAGMENT 1.2: id/"
                           + header.getRequestId()
                           + ": ++++DISCARDING++++: "
                           + header);
                }
                // need to release dispatchByteBuffer to pool if
                // we are discarding
                releaseByteBufferToPool();
                return;
            }
            ((CDRInputObject)inputObject)
                .getBufferManager().processFragment(
                                 dispatchByteBuffer, header);

            // REVISIT: but if it is a server don't you have to remove the
            // stream from the map?
            if (! connection.isServer()) {
                /* REVISIT
                 * No need to do anything.
                 * Should we mark that last was received?
                 if (! header.moreFragmentsToFollow()) {
                 // Last fragment.
                 }
                */
            }
        } finally {
            // NOTE: This *must* come after queing the fragment
            // when using the selector to ensure fragments stay in order.
            setWorkThenReadOrResumeSelect(header);
        }
    } catch (Throwable t) {
        if (transportDebug())
            dprint(".FRAGMENT 1.2: id/"
                   + header.getRequestId()
                   + ": !!ERROR!!: "
                   + header, t);
        // Mask the exception from thread.;
    } finally {
        if (transportDebug()) dprint(".FRAGMENT 1.2<-: id/"
                                     + header.getRequestId()
                                     + ": "
                                     + header);
    }
}
 
Example 6
Source File: CorbaClientRequestDispatcherImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public void endRequest(Broker broker, Object self, InputObject inputObject)
{
    ORB orb = (ORB)broker ;

    try {
        if (orb.subcontractDebugFlag) {
            dprint(".endRequest->");
        }

        // Note: the inputObject may be null if an error occurs
        //       in request or before _invoke returns.
        // Note: self may be null also (e.g., compiler generates null in stub).

        MessageMediator messageMediator =
            orb.getInvocationInfo().getMessageMediator();
        if (messageMediator != null)
        {
            if (messageMediator.getConnection() != null)
            {
                ((CorbaMessageMediator)messageMediator)
                          .sendCancelRequestIfFinalFragmentNotSent();
            }

            // Release any outstanding NIO ByteBuffers to the ByteBufferPool

            InputObject inputObj = messageMediator.getInputObject();
            if (inputObj != null) {
                inputObj.close();
            }

            OutputObject outputObj = messageMediator.getOutputObject();
            if (outputObj != null) {
                outputObj.close();
            }

        }

        // XREVISIT NOTE - Assumes unregistering the waiter for
        // location forwards has already happened somewhere else.
        // The code below is only going to unregister the final successful
        // request.

        // NOTE: In the case of a recursive stack of endRequests in a
        // finally block (because of Remarshal) only the first call to
        // unregisterWaiter will remove the waiter.  The rest will be
        // noops.
        unregisterWaiter(orb);

        // Invoke Portable Interceptors cleanup.  This is done to handle
        // exceptions during stream marshaling.  More generally, exceptions
        // that occur in the ORB after send_request (which includes
        // after returning from _request) before _invoke:
        orb.getPIHandler().cleanupClientPIRequest();

        // REVISIT: Early replies?
    } catch (IOException ex) {
        // See CDRInput/OutputObject.close() for more info.
        // This won't result in a Corba error if an IOException happens.
        if (orb.subcontractDebugFlag)
        {
            dprint(".endRequest: ignoring IOException - " + ex.toString());
        }
    } finally {
        if (orb.subcontractDebugFlag) {
            dprint(".endRequest<-");
        }
    }
}
 
Example 7
Source File: CorbaMessageMediatorImpl.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public void handleInput(FragmentMessage_1_2 header) throws IOException
{
    try {
        try {
            messageHeader = header;

            // Note:  We know it's a 1.2 fragment, we have the data, but
            // we need the IIOPInputStream instance to unmarshal the
            // request ID... but we need the request ID to get the
            // IIOPInputStream instance. So we peek at the raw bytes.

            header.unmarshalRequestID(dispatchByteBuffer);

            if (transportDebug()) {
                dprint(".FRAGMENT 1.2->: id/"
                       + header.getRequestId()
                       + ": more?: " + header.moreFragmentsToFollow()
                       + ": " + header);
            }

            MessageMediator mediator = null;
            InputObject inputObject = null;

            if (connection.isServer()) {
                mediator =
                    connection.serverRequestMapGet(header.getRequestId());
            } else {
                mediator =
                    connection.clientRequestMapGet(header.getRequestId());
            }
            if (mediator != null) {
                inputObject = mediator.getInputObject();
            }
            // See 1.1 comments.
            if (inputObject == null) {
                if (transportDebug()) {
                    dprint(".FRAGMENT 1.2: id/"
                           + header.getRequestId()
                           + ": ++++DISCARDING++++: "
                           + header);
                }
                // need to release dispatchByteBuffer to pool if
                // we are discarding
                releaseByteBufferToPool();
                return;
            }
            ((CDRInputObject)inputObject)
                .getBufferManager().processFragment(
                                 dispatchByteBuffer, header);

            // REVISIT: but if it is a server don't you have to remove the
            // stream from the map?
            if (! connection.isServer()) {
                /* REVISIT
                 * No need to do anything.
                 * Should we mark that last was received?
                 if (! header.moreFragmentsToFollow()) {
                 // Last fragment.
                 }
                */
            }
        } finally {
            // NOTE: This *must* come after queing the fragment
            // when using the selector to ensure fragments stay in order.
            setWorkThenReadOrResumeSelect(header);
        }
    } catch (Throwable t) {
        if (transportDebug())
            dprint(".FRAGMENT 1.2: id/"
                   + header.getRequestId()
                   + ": !!ERROR!!: "
                   + header, t);
        // Mask the exception from thread.;
    } finally {
        if (transportDebug()) dprint(".FRAGMENT 1.2<-: id/"
                                     + header.getRequestId()
                                     + ": "
                                     + header);
    }
}
 
Example 8
Source File: CorbaMessageMediatorImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public void handleInput(FragmentMessage_1_2 header) throws IOException
{
    try {
        try {
            messageHeader = header;

            // Note:  We know it's a 1.2 fragment, we have the data, but
            // we need the IIOPInputStream instance to unmarshal the
            // request ID... but we need the request ID to get the
            // IIOPInputStream instance. So we peek at the raw bytes.

            header.unmarshalRequestID(dispatchByteBuffer);

            if (transportDebug()) {
                dprint(".FRAGMENT 1.2->: id/"
                       + header.getRequestId()
                       + ": more?: " + header.moreFragmentsToFollow()
                       + ": " + header);
            }

            MessageMediator mediator = null;
            InputObject inputObject = null;

            if (connection.isServer()) {
                mediator =
                    connection.serverRequestMapGet(header.getRequestId());
            } else {
                mediator =
                    connection.clientRequestMapGet(header.getRequestId());
            }
            if (mediator != null) {
                inputObject = mediator.getInputObject();
            }
            // See 1.1 comments.
            if (inputObject == null) {
                if (transportDebug()) {
                    dprint(".FRAGMENT 1.2: id/"
                           + header.getRequestId()
                           + ": ++++DISCARDING++++: "
                           + header);
                }
                // need to release dispatchByteBuffer to pool if
                // we are discarding
                releaseByteBufferToPool();
                return;
            }
            ((CDRInputObject)inputObject)
                .getBufferManager().processFragment(
                                 dispatchByteBuffer, header);

            // REVISIT: but if it is a server don't you have to remove the
            // stream from the map?
            if (! connection.isServer()) {
                /* REVISIT
                 * No need to do anything.
                 * Should we mark that last was received?
                 if (! header.moreFragmentsToFollow()) {
                 // Last fragment.
                 }
                */
            }
        } finally {
            // NOTE: This *must* come after queing the fragment
            // when using the selector to ensure fragments stay in order.
            setWorkThenReadOrResumeSelect(header);
        }
    } catch (Throwable t) {
        if (transportDebug())
            dprint(".FRAGMENT 1.2: id/"
                   + header.getRequestId()
                   + ": !!ERROR!!: "
                   + header, t);
        // Mask the exception from thread.;
    } finally {
        if (transportDebug()) dprint(".FRAGMENT 1.2<-: id/"
                                     + header.getRequestId()
                                     + ": "
                                     + header);
    }
}
 
Example 9
Source File: CorbaMessageMediatorImpl.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public void handleInput(FragmentMessage_1_2 header) throws IOException
{
    try {
        try {
            messageHeader = header;

            // Note:  We know it's a 1.2 fragment, we have the data, but
            // we need the IIOPInputStream instance to unmarshal the
            // request ID... but we need the request ID to get the
            // IIOPInputStream instance. So we peek at the raw bytes.

            header.unmarshalRequestID(dispatchByteBuffer);

            if (transportDebug()) {
                dprint(".FRAGMENT 1.2->: id/"
                       + header.getRequestId()
                       + ": more?: " + header.moreFragmentsToFollow()
                       + ": " + header);
            }

            MessageMediator mediator = null;
            InputObject inputObject = null;

            if (connection.isServer()) {
                mediator =
                    connection.serverRequestMapGet(header.getRequestId());
            } else {
                mediator =
                    connection.clientRequestMapGet(header.getRequestId());
            }
            if (mediator != null) {
                inputObject = mediator.getInputObject();
            }
            // See 1.1 comments.
            if (inputObject == null) {
                if (transportDebug()) {
                    dprint(".FRAGMENT 1.2: id/"
                           + header.getRequestId()
                           + ": ++++DISCARDING++++: "
                           + header);
                }
                // need to release dispatchByteBuffer to pool if
                // we are discarding
                releaseByteBufferToPool();
                return;
            }
            ((CDRInputObject)inputObject)
                .getBufferManager().processFragment(
                                 dispatchByteBuffer, header);

            // REVISIT: but if it is a server don't you have to remove the
            // stream from the map?
            if (! connection.isServer()) {
                /* REVISIT
                 * No need to do anything.
                 * Should we mark that last was received?
                 if (! header.moreFragmentsToFollow()) {
                 // Last fragment.
                 }
                */
            }
        } finally {
            // NOTE: This *must* come after queing the fragment
            // when using the selector to ensure fragments stay in order.
            setWorkThenReadOrResumeSelect(header);
        }
    } catch (Throwable t) {
        if (transportDebug())
            dprint(".FRAGMENT 1.2: id/"
                   + header.getRequestId()
                   + ": !!ERROR!!: "
                   + header, t);
        // Mask the exception from thread.;
    } finally {
        if (transportDebug()) dprint(".FRAGMENT 1.2<-: id/"
                                     + header.getRequestId()
                                     + ": "
                                     + header);
    }
}
 
Example 10
Source File: CDROutputStream_1_0.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
public void close() throws IOException
{
    // tell BufferManagerWrite to release any ByteBuffers
    getBufferManager().close();

    // It's possible bbwi.byteBuffer is shared between
    // this OutputStream and an InputStream. Thus, we check
    // if the Input/Output streams are using the same ByteBuffer.
    // If they sharing the same ByteBuffer we need to ensure only
    // one of those ByteBuffers are released to the ByteBufferPool.

    if (getByteBufferWithInfo() != null && getByteBuffer() != null)
    {
        MessageMediator messageMediator = parent.getMessageMediator();
        if (messageMediator != null)
        {
            CDRInputObject inputObj =
                           (CDRInputObject)messageMediator.getInputObject();
            if (inputObj != null)
            {
                if (inputObj.isSharing(getByteBuffer()))
                {
                    // Set InputStream's ByteBuffer and bbwi to null
                    // so its ByteBuffer cannot be released to the pool
                    inputObj.setByteBuffer(null);
                    inputObj.setByteBufferWithInfo(null);
                }
            }
        }

        // release this stream's ByteBuffer to the pool
        ByteBufferPool byteBufferPool = orb.getByteBufferPool();
        if (debug)
        {
            // print address of ByteBuffer being released
            int bbAddress = System.identityHashCode(bbwi.byteBuffer);
            StringBuffer sb = new StringBuffer(80);
            sb.append(".close - releasing ByteBuffer id (");
            sb.append(bbAddress).append(") to ByteBufferPool.");
            String msg = sb.toString();
            dprint(msg);
         }
         byteBufferPool.releaseByteBuffer(getByteBuffer());
         bbwi.byteBuffer = null;
         bbwi = null;
    }
}
 
Example 11
Source File: CDROutputStream_1_0.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public void close() throws IOException
{
    // tell BufferManagerWrite to release any ByteBuffers
    getBufferManager().close();

    // It's possible bbwi.byteBuffer is shared between
    // this OutputStream and an InputStream. Thus, we check
    // if the Input/Output streams are using the same ByteBuffer.
    // If they sharing the same ByteBuffer we need to ensure only
    // one of those ByteBuffers are released to the ByteBufferPool.

    if (getByteBufferWithInfo() != null && getByteBuffer() != null)
    {
        MessageMediator messageMediator = parent.getMessageMediator();
        if (messageMediator != null)
        {
            CDRInputObject inputObj =
                           (CDRInputObject)messageMediator.getInputObject();
            if (inputObj != null)
            {
                if (inputObj.isSharing(getByteBuffer()))
                {
                    // Set InputStream's ByteBuffer and bbwi to null
                    // so its ByteBuffer cannot be released to the pool
                    inputObj.setByteBuffer(null);
                    inputObj.setByteBufferWithInfo(null);
                }
            }
        }

        // release this stream's ByteBuffer to the pool
        ByteBufferPool byteBufferPool = orb.getByteBufferPool();
        if (debug)
        {
            // print address of ByteBuffer being released
            int bbAddress = System.identityHashCode(bbwi.byteBuffer);
            StringBuffer sb = new StringBuffer(80);
            sb.append(".close - releasing ByteBuffer id (");
            sb.append(bbAddress).append(") to ByteBufferPool.");
            String msg = sb.toString();
            dprint(msg);
         }
         byteBufferPool.releaseByteBuffer(getByteBuffer());
         bbwi.byteBuffer = null;
         bbwi = null;
    }
}
 
Example 12
Source File: CorbaClientRequestDispatcherImpl.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
public void endRequest(Broker broker, Object self, InputObject inputObject)
{
    ORB orb = (ORB)broker ;

    try {
        if (orb.subcontractDebugFlag) {
            dprint(".endRequest->");
        }

        // Note: the inputObject may be null if an error occurs
        //       in request or before _invoke returns.
        // Note: self may be null also (e.g., compiler generates null in stub).

        MessageMediator messageMediator =
            orb.getInvocationInfo().getMessageMediator();
        if (messageMediator != null)
        {
            if (messageMediator.getConnection() != null)
            {
                ((CorbaMessageMediator)messageMediator)
                          .sendCancelRequestIfFinalFragmentNotSent();
            }

            // Release any outstanding NIO ByteBuffers to the ByteBufferPool

            InputObject inputObj = messageMediator.getInputObject();
            if (inputObj != null) {
                inputObj.close();
            }

            OutputObject outputObj = messageMediator.getOutputObject();
            if (outputObj != null) {
                outputObj.close();
            }

        }

        // XREVISIT NOTE - Assumes unregistering the waiter for
        // location forwards has already happened somewhere else.
        // The code below is only going to unregister the final successful
        // request.

        // NOTE: In the case of a recursive stack of endRequests in a
        // finally block (because of Remarshal) only the first call to
        // unregisterWaiter will remove the waiter.  The rest will be
        // noops.
        unregisterWaiter(orb);

        // Invoke Portable Interceptors cleanup.  This is done to handle
        // exceptions during stream marshaling.  More generally, exceptions
        // that occur in the ORB after send_request (which includes
        // after returning from _request) before _invoke:
        orb.getPIHandler().cleanupClientPIRequest();

        // REVISIT: Early replies?
    } catch (IOException ex) {
        // See CDRInput/OutputObject.close() for more info.
        // This won't result in a Corba error if an IOException happens.
        if (orb.subcontractDebugFlag)
        {
            dprint(".endRequest: ignoring IOException - " + ex.toString());
        }
    } finally {
        if (orb.subcontractDebugFlag) {
            dprint(".endRequest<-");
        }
    }
}
 
Example 13
Source File: CDROutputStream_1_0.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public void close() throws IOException
{
    // tell BufferManagerWrite to release any ByteBuffers
    getBufferManager().close();

    // It's possible bbwi.byteBuffer is shared between
    // this OutputStream and an InputStream. Thus, we check
    // if the Input/Output streams are using the same ByteBuffer.
    // If they sharing the same ByteBuffer we need to ensure only
    // one of those ByteBuffers are released to the ByteBufferPool.

    if (getByteBufferWithInfo() != null && getByteBuffer() != null)
    {
        MessageMediator messageMediator = parent.getMessageMediator();
        if (messageMediator != null)
        {
            CDRInputObject inputObj =
                           (CDRInputObject)messageMediator.getInputObject();
            if (inputObj != null)
            {
                if (inputObj.isSharing(getByteBuffer()))
                {
                    // Set InputStream's ByteBuffer and bbwi to null
                    // so its ByteBuffer cannot be released to the pool
                    inputObj.setByteBuffer(null);
                    inputObj.setByteBufferWithInfo(null);
                }
            }
        }

        // release this stream's ByteBuffer to the pool
        ByteBufferPool byteBufferPool = orb.getByteBufferPool();
        if (debug)
        {
            // print address of ByteBuffer being released
            int bbAddress = System.identityHashCode(bbwi.byteBuffer);
            StringBuffer sb = new StringBuffer(80);
            sb.append(".close - releasing ByteBuffer id (");
            sb.append(bbAddress).append(") to ByteBufferPool.");
            String msg = sb.toString();
            dprint(msg);
         }
         byteBufferPool.releaseByteBuffer(getByteBuffer());
         bbwi.byteBuffer = null;
         bbwi = null;
    }
}
 
Example 14
Source File: CorbaMessageMediatorImpl.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public void handleInput(FragmentMessage_1_2 header) throws IOException
{
    try {
        try {
            messageHeader = header;

            // Note:  We know it's a 1.2 fragment, we have the data, but
            // we need the IIOPInputStream instance to unmarshal the
            // request ID... but we need the request ID to get the
            // IIOPInputStream instance. So we peek at the raw bytes.

            header.unmarshalRequestID(dispatchByteBuffer);

            if (transportDebug()) {
                dprint(".FRAGMENT 1.2->: id/"
                       + header.getRequestId()
                       + ": more?: " + header.moreFragmentsToFollow()
                       + ": " + header);
            }

            MessageMediator mediator = null;
            InputObject inputObject = null;

            if (connection.isServer()) {
                mediator =
                    connection.serverRequestMapGet(header.getRequestId());
            } else {
                mediator =
                    connection.clientRequestMapGet(header.getRequestId());
            }
            if (mediator != null) {
                inputObject = mediator.getInputObject();
            }
            // See 1.1 comments.
            if (inputObject == null) {
                if (transportDebug()) {
                    dprint(".FRAGMENT 1.2: id/"
                           + header.getRequestId()
                           + ": ++++DISCARDING++++: "
                           + header);
                }
                // need to release dispatchByteBuffer to pool if
                // we are discarding
                releaseByteBufferToPool();
                return;
            }
            ((CDRInputObject)inputObject)
                .getBufferManager().processFragment(
                                 dispatchByteBuffer, header);

            // REVISIT: but if it is a server don't you have to remove the
            // stream from the map?
            if (! connection.isServer()) {
                /* REVISIT
                 * No need to do anything.
                 * Should we mark that last was received?
                 if (! header.moreFragmentsToFollow()) {
                 // Last fragment.
                 }
                */
            }
        } finally {
            // NOTE: This *must* come after queing the fragment
            // when using the selector to ensure fragments stay in order.
            setWorkThenReadOrResumeSelect(header);
        }
    } catch (Throwable t) {
        if (transportDebug())
            dprint(".FRAGMENT 1.2: id/"
                   + header.getRequestId()
                   + ": !!ERROR!!: "
                   + header, t);
        // Mask the exception from thread.;
    } finally {
        if (transportDebug()) dprint(".FRAGMENT 1.2<-: id/"
                                     + header.getRequestId()
                                     + ": "
                                     + header);
    }
}
 
Example 15
Source File: CorbaClientRequestDispatcherImpl.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public void endRequest(Broker broker, Object self, InputObject inputObject)
{
    ORB orb = (ORB)broker ;

    try {
        if (orb.subcontractDebugFlag) {
            dprint(".endRequest->");
        }

        // Note: the inputObject may be null if an error occurs
        //       in request or before _invoke returns.
        // Note: self may be null also (e.g., compiler generates null in stub).

        MessageMediator messageMediator =
            orb.getInvocationInfo().getMessageMediator();
        if (messageMediator != null)
        {
            if (messageMediator.getConnection() != null)
            {
                ((CorbaMessageMediator)messageMediator)
                          .sendCancelRequestIfFinalFragmentNotSent();
            }

            // Release any outstanding NIO ByteBuffers to the ByteBufferPool

            InputObject inputObj = messageMediator.getInputObject();
            if (inputObj != null) {
                inputObj.close();
            }

            OutputObject outputObj = messageMediator.getOutputObject();
            if (outputObj != null) {
                outputObj.close();
            }

        }

        // XREVISIT NOTE - Assumes unregistering the waiter for
        // location forwards has already happened somewhere else.
        // The code below is only going to unregister the final successful
        // request.

        // NOTE: In the case of a recursive stack of endRequests in a
        // finally block (because of Remarshal) only the first call to
        // unregisterWaiter will remove the waiter.  The rest will be
        // noops.
        unregisterWaiter(orb);

        // Invoke Portable Interceptors cleanup.  This is done to handle
        // exceptions during stream marshaling.  More generally, exceptions
        // that occur in the ORB after send_request (which includes
        // after returning from _request) before _invoke:
        orb.getPIHandler().cleanupClientPIRequest();

        // REVISIT: Early replies?
    } catch (IOException ex) {
        // See CDRInput/OutputObject.close() for more info.
        // This won't result in a Corba error if an IOException happens.
        if (orb.subcontractDebugFlag)
        {
            dprint(".endRequest: ignoring IOException - " + ex.toString());
        }
    } finally {
        if (orb.subcontractDebugFlag) {
            dprint(".endRequest<-");
        }
    }
}
 
Example 16
Source File: CorbaClientRequestDispatcherImpl.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public void endRequest(Broker broker, Object self, InputObject inputObject)
{
    ORB orb = (ORB)broker ;

    try {
        if (orb.subcontractDebugFlag) {
            dprint(".endRequest->");
        }

        // Note: the inputObject may be null if an error occurs
        //       in request or before _invoke returns.
        // Note: self may be null also (e.g., compiler generates null in stub).

        MessageMediator messageMediator =
            orb.getInvocationInfo().getMessageMediator();
        if (messageMediator != null)
        {
            if (messageMediator.getConnection() != null)
            {
                ((CorbaMessageMediator)messageMediator)
                          .sendCancelRequestIfFinalFragmentNotSent();
            }

            // Release any outstanding NIO ByteBuffers to the ByteBufferPool

            InputObject inputObj = messageMediator.getInputObject();
            if (inputObj != null) {
                inputObj.close();
            }

            OutputObject outputObj = messageMediator.getOutputObject();
            if (outputObj != null) {
                outputObj.close();
            }

        }

        // XREVISIT NOTE - Assumes unregistering the waiter for
        // location forwards has already happened somewhere else.
        // The code below is only going to unregister the final successful
        // request.

        // NOTE: In the case of a recursive stack of endRequests in a
        // finally block (because of Remarshal) only the first call to
        // unregisterWaiter will remove the waiter.  The rest will be
        // noops.
        unregisterWaiter(orb);

        // Invoke Portable Interceptors cleanup.  This is done to handle
        // exceptions during stream marshaling.  More generally, exceptions
        // that occur in the ORB after send_request (which includes
        // after returning from _request) before _invoke:
        orb.getPIHandler().cleanupClientPIRequest();

        // REVISIT: Early replies?
    } catch (IOException ex) {
        // See CDRInput/OutputObject.close() for more info.
        // This won't result in a Corba error if an IOException happens.
        if (orb.subcontractDebugFlag)
        {
            dprint(".endRequest: ignoring IOException - " + ex.toString());
        }
    } finally {
        if (orb.subcontractDebugFlag) {
            dprint(".endRequest<-");
        }
    }
}
 
Example 17
Source File: CorbaMessageMediatorImpl.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public void handleInput(FragmentMessage_1_2 header) throws IOException
{
    try {
        try {
            messageHeader = header;

            // Note:  We know it's a 1.2 fragment, we have the data, but
            // we need the IIOPInputStream instance to unmarshal the
            // request ID... but we need the request ID to get the
            // IIOPInputStream instance. So we peek at the raw bytes.

            header.unmarshalRequestID(dispatchByteBuffer);

            if (transportDebug()) {
                dprint(".FRAGMENT 1.2->: id/"
                       + header.getRequestId()
                       + ": more?: " + header.moreFragmentsToFollow()
                       + ": " + header);
            }

            MessageMediator mediator = null;
            InputObject inputObject = null;

            if (connection.isServer()) {
                mediator =
                    connection.serverRequestMapGet(header.getRequestId());
            } else {
                mediator =
                    connection.clientRequestMapGet(header.getRequestId());
            }
            if (mediator != null) {
                inputObject = mediator.getInputObject();
            }
            // See 1.1 comments.
            if (inputObject == null) {
                if (transportDebug()) {
                    dprint(".FRAGMENT 1.2: id/"
                           + header.getRequestId()
                           + ": ++++DISCARDING++++: "
                           + header);
                }
                // need to release dispatchByteBuffer to pool if
                // we are discarding
                releaseByteBufferToPool();
                return;
            }
            ((CDRInputObject)inputObject)
                .getBufferManager().processFragment(
                                 dispatchByteBuffer, header);

            // REVISIT: but if it is a server don't you have to remove the
            // stream from the map?
            if (! connection.isServer()) {
                /* REVISIT
                 * No need to do anything.
                 * Should we mark that last was received?
                 if (! header.moreFragmentsToFollow()) {
                 // Last fragment.
                 }
                */
            }
        } finally {
            // NOTE: This *must* come after queing the fragment
            // when using the selector to ensure fragments stay in order.
            setWorkThenReadOrResumeSelect(header);
        }
    } catch (Throwable t) {
        if (transportDebug())
            dprint(".FRAGMENT 1.2: id/"
                   + header.getRequestId()
                   + ": !!ERROR!!: "
                   + header, t);
        // Mask the exception from thread.;
    } finally {
        if (transportDebug()) dprint(".FRAGMENT 1.2<-: id/"
                                     + header.getRequestId()
                                     + ": "
                                     + header);
    }
}
 
Example 18
Source File: CorbaClientRequestDispatcherImpl.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public void endRequest(Broker broker, Object self, InputObject inputObject)
{
    ORB orb = (ORB)broker ;

    try {
        if (orb.subcontractDebugFlag) {
            dprint(".endRequest->");
        }

        // Note: the inputObject may be null if an error occurs
        //       in request or before _invoke returns.
        // Note: self may be null also (e.g., compiler generates null in stub).

        MessageMediator messageMediator =
            orb.getInvocationInfo().getMessageMediator();
        if (messageMediator != null)
        {
            if (messageMediator.getConnection() != null)
            {
                ((CorbaMessageMediator)messageMediator)
                          .sendCancelRequestIfFinalFragmentNotSent();
            }

            // Release any outstanding NIO ByteBuffers to the ByteBufferPool

            InputObject inputObj = messageMediator.getInputObject();
            if (inputObj != null) {
                inputObj.close();
            }

            OutputObject outputObj = messageMediator.getOutputObject();
            if (outputObj != null) {
                outputObj.close();
            }

        }

        // XREVISIT NOTE - Assumes unregistering the waiter for
        // location forwards has already happened somewhere else.
        // The code below is only going to unregister the final successful
        // request.

        // NOTE: In the case of a recursive stack of endRequests in a
        // finally block (because of Remarshal) only the first call to
        // unregisterWaiter will remove the waiter.  The rest will be
        // noops.
        unregisterWaiter(orb);

        // Invoke Portable Interceptors cleanup.  This is done to handle
        // exceptions during stream marshaling.  More generally, exceptions
        // that occur in the ORB after send_request (which includes
        // after returning from _request) before _invoke:
        orb.getPIHandler().cleanupClientPIRequest();

        // REVISIT: Early replies?
    } catch (IOException ex) {
        // See CDRInput/OutputObject.close() for more info.
        // This won't result in a Corba error if an IOException happens.
        if (orb.subcontractDebugFlag)
        {
            dprint(".endRequest: ignoring IOException - " + ex.toString());
        }
    } finally {
        if (orb.subcontractDebugFlag) {
            dprint(".endRequest<-");
        }
    }
}
 
Example 19
Source File: CDROutputStream_1_0.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
public void close() throws IOException
{
    // tell BufferManagerWrite to release any ByteBuffers
    getBufferManager().close();

    // It's possible bbwi.byteBuffer is shared between
    // this OutputStream and an InputStream. Thus, we check
    // if the Input/Output streams are using the same ByteBuffer.
    // If they sharing the same ByteBuffer we need to ensure only
    // one of those ByteBuffers are released to the ByteBufferPool.

    if (getByteBufferWithInfo() != null && getByteBuffer() != null)
    {
        MessageMediator messageMediator = parent.getMessageMediator();
        if (messageMediator != null)
        {
            CDRInputObject inputObj =
                           (CDRInputObject)messageMediator.getInputObject();
            if (inputObj != null)
            {
                if (inputObj.isSharing(getByteBuffer()))
                {
                    // Set InputStream's ByteBuffer and bbwi to null
                    // so its ByteBuffer cannot be released to the pool
                    inputObj.setByteBuffer(null);
                    inputObj.setByteBufferWithInfo(null);
                }
            }
        }

        // release this stream's ByteBuffer to the pool
        ByteBufferPool byteBufferPool = orb.getByteBufferPool();
        if (debug)
        {
            // print address of ByteBuffer being released
            int bbAddress = System.identityHashCode(bbwi.byteBuffer);
            StringBuffer sb = new StringBuffer(80);
            sb.append(".close - releasing ByteBuffer id (");
            sb.append(bbAddress).append(") to ByteBufferPool.");
            String msg = sb.toString();
            dprint(msg);
         }
         byteBufferPool.releaseByteBuffer(getByteBuffer());
         bbwi.byteBuffer = null;
         bbwi = null;
    }
}
 
Example 20
Source File: CorbaMessageMediatorImpl.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
public void handleInput(FragmentMessage_1_2 header) throws IOException
{
    try {
        try {
            messageHeader = header;

            // Note:  We know it's a 1.2 fragment, we have the data, but
            // we need the IIOPInputStream instance to unmarshal the
            // request ID... but we need the request ID to get the
            // IIOPInputStream instance. So we peek at the raw bytes.

            header.unmarshalRequestID(dispatchByteBuffer);

            if (transportDebug()) {
                dprint(".FRAGMENT 1.2->: id/"
                       + header.getRequestId()
                       + ": more?: " + header.moreFragmentsToFollow()
                       + ": " + header);
            }

            MessageMediator mediator = null;
            InputObject inputObject = null;

            if (connection.isServer()) {
                mediator =
                    connection.serverRequestMapGet(header.getRequestId());
            } else {
                mediator =
                    connection.clientRequestMapGet(header.getRequestId());
            }
            if (mediator != null) {
                inputObject = mediator.getInputObject();
            }
            // See 1.1 comments.
            if (inputObject == null) {
                if (transportDebug()) {
                    dprint(".FRAGMENT 1.2: id/"
                           + header.getRequestId()
                           + ": ++++DISCARDING++++: "
                           + header);
                }
                // need to release dispatchByteBuffer to pool if
                // we are discarding
                releaseByteBufferToPool();
                return;
            }
            ((CDRInputObject)inputObject)
                .getBufferManager().processFragment(
                                 dispatchByteBuffer, header);

            // REVISIT: but if it is a server don't you have to remove the
            // stream from the map?
            if (! connection.isServer()) {
                /* REVISIT
                 * No need to do anything.
                 * Should we mark that last was received?
                 if (! header.moreFragmentsToFollow()) {
                 // Last fragment.
                 }
                */
            }
        } finally {
            // NOTE: This *must* come after queing the fragment
            // when using the selector to ensure fragments stay in order.
            setWorkThenReadOrResumeSelect(header);
        }
    } catch (Throwable t) {
        if (transportDebug())
            dprint(".FRAGMENT 1.2: id/"
                   + header.getRequestId()
                   + ": !!ERROR!!: "
                   + header, t);
        // Mask the exception from thread.;
    } finally {
        if (transportDebug()) dprint(".FRAGMENT 1.2<-: id/"
                                     + header.getRequestId()
                                     + ": "
                                     + header);
    }
}