com.sun.corba.se.pept.encoding.OutputObject Java Examples

The following examples show how to use com.sun.corba.se.pept.encoding.OutputObject. 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 Project: jdk1.8-source-analysis   Author: raysonfang   File: BufferManagerWriteStream.java    License: Apache License 2.0 6 votes vote down vote up
private void sendFragment(boolean isLastFragment)
{
    Connection conn = ((OutputObject)outputObject).getMessageMediator().getConnection();

    // REVISIT: need an ORB
    //System.out.println("sendFragment: last?: " + isLastFragment);
    conn.writeLock();

    try {
        // Send the fragment
        conn.sendWithoutLock(((OutputObject)outputObject));

        fragmentCount++;

    } finally {

        conn.writeUnlock();
    }

}
 
Example #2
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: BufferManagerWriteStream.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void sendFragment(boolean isLastFragment)
{
    Connection conn = ((OutputObject)outputObject).getMessageMediator().getConnection();

    // REVISIT: need an ORB
    //System.out.println("sendFragment: last?: " + isLastFragment);
    conn.writeLock();

    try {
        // Send the fragment
        conn.sendWithoutLock(((OutputObject)outputObject));

        fragmentCount++;

    } finally {

        conn.writeUnlock();
    }

}
 
Example #3
Source Project: hottub   Author: dsrg-uoft   File: CorbaContactInfoBase.java    License: GNU General Public License v2.0 5 votes vote down vote up
public OutputObject createOutputObject(MessageMediator messageMediator)
{
    CorbaMessageMediator corbaMessageMediator = (CorbaMessageMediator)
        messageMediator;

    OutputObject outputObject =
        sun.corba.OutputStreamFactory.newCDROutputObject(orb, messageMediator,
                            corbaMessageMediator.getRequestHeader(),
                            corbaMessageMediator.getStreamFormatVersion());

    messageMediator.setOutputObject(outputObject);
    return outputObject;
}
 
Example #4
Source Project: JDKSourceCode1.8   Author: wupeixuan   File: CorbaContactInfoBase.java    License: MIT License 5 votes vote down vote up
public OutputObject createOutputObject(MessageMediator messageMediator)
{
    CorbaMessageMediator corbaMessageMediator = (CorbaMessageMediator)
        messageMediator;

    OutputObject outputObject =
        sun.corba.OutputStreamFactory.newCDROutputObject(orb, messageMediator,
                            corbaMessageMediator.getRequestHeader(),
                            corbaMessageMediator.getStreamFormatVersion());

    messageMediator.setOutputObject(outputObject);
    return outputObject;
}
 
Example #5
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: CorbaContactInfoBase.java    License: Apache License 2.0 5 votes vote down vote up
public OutputObject createOutputObject(MessageMediator messageMediator)
{
    CorbaMessageMediator corbaMessageMediator = (CorbaMessageMediator)
        messageMediator;

    OutputObject outputObject =
        sun.corba.OutputStreamFactory.newCDROutputObject(orb, messageMediator,
                            corbaMessageMediator.getRequestHeader(),
                            corbaMessageMediator.getStreamFormatVersion());

    messageMediator.setOutputObject(outputObject);
    return outputObject;
}
 
Example #6
Source Project: hottub   Author: dsrg-uoft   File: CorbaMessageMediatorImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void endRequest(CorbaMessageMediator messageMediator)
{
    ORB orb = (ORB) messageMediator.getBroker();
    if (orb.subcontractDebugFlag) {
        dprint(".handleRequest<-: " + opAndId(messageMediator));
    }

    // release NIO ByteBuffers to ByteBufferPool

    try {
        OutputObject outputObj = messageMediator.getOutputObject();
        if (outputObj != null) {
            outputObj.close();
        }
        InputObject inputObj = messageMediator.getInputObject();
        if (inputObj != null) {
            inputObj.close();
        }
    } catch (IOException ex) {
        // Given what close() does, this catch shouldn't ever happen.
        // See CDRInput/OutputObject.close() for more info.
        // It also won't result in a Corba error if an IOException happens.
        if (orb.subcontractDebugFlag) {
            dprint(".endRequest: IOException:" + ex.getMessage(), ex);
        }
    } finally {
        ((CorbaConnection)messageMediator.getConnection()).serverRequestProcessingEnds();
    }
}
 
Example #7
Source Project: openjdk-8   Author: bpupadhyaya   File: SharedCDRContactInfoImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
public OutputObject createOutputObject(MessageMediator messageMediator)
{
    CorbaMessageMediator corbaMessageMediator = (CorbaMessageMediator)
        messageMediator;
    // NOTE: GROW.
    OutputObject outputObject =
        sun.corba.OutputStreamFactory.newCDROutputObject(orb, messageMediator,
                            corbaMessageMediator.getRequestHeader(),
                            corbaMessageMediator.getStreamFormatVersion(),
                            BufferManagerFactory.GROW);
    messageMediator.setOutputObject(outputObject);
    return outputObject;
}
 
Example #8
Source Project: TencentKona-8   Author: Tencent   File: CorbaClientDelegateImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
public InputStream invoke(org.omg.CORBA.Object self, OutputStream output)
    throws
        ApplicationException,
        RemarshalException
{
    ClientRequestDispatcher subcontract = getClientRequestDispatcher();
    return (InputStream)
        subcontract.marshalingComplete((Object)self, (OutputObject)output);
}
 
Example #9
Source Project: TencentKona-8   Author: Tencent   File: CorbaMessageMediatorImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void endRequest(CorbaMessageMediator messageMediator)
{
    ORB orb = (ORB) messageMediator.getBroker();
    if (orb.subcontractDebugFlag) {
        dprint(".handleRequest<-: " + opAndId(messageMediator));
    }

    // release NIO ByteBuffers to ByteBufferPool

    try {
        OutputObject outputObj = messageMediator.getOutputObject();
        if (outputObj != null) {
            outputObj.close();
        }
        InputObject inputObj = messageMediator.getInputObject();
        if (inputObj != null) {
            inputObj.close();
        }
    } catch (IOException ex) {
        // Given what close() does, this catch shouldn't ever happen.
        // See CDRInput/OutputObject.close() for more info.
        // It also won't result in a Corba error if an IOException happens.
        if (orb.subcontractDebugFlag) {
            dprint(".endRequest: IOException:" + ex.getMessage(), ex);
        }
    } finally {
        ((CorbaConnection)messageMediator.getConnection()).serverRequestProcessingEnds();
    }
}
 
Example #10
Source Project: TencentKona-8   Author: Tencent   File: SocketOrChannelAcceptorImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
public OutputObject createOutputObject(Broker broker,
                                       MessageMediator messageMediator)
{
    CorbaMessageMediator corbaMessageMediator = (CorbaMessageMediator)
        messageMediator;
    return sun.corba.OutputStreamFactory.newCDROutputObject((ORB) broker,
                   corbaMessageMediator, corbaMessageMediator.getReplyHeader(),
                   corbaMessageMediator.getStreamFormatVersion());
}
 
Example #11
Source Project: TencentKona-8   Author: Tencent   File: SharedCDRContactInfoImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
public OutputObject createOutputObject(MessageMediator messageMediator)
{
    CorbaMessageMediator corbaMessageMediator = (CorbaMessageMediator)
        messageMediator;
    // NOTE: GROW.
    OutputObject outputObject =
        sun.corba.OutputStreamFactory.newCDROutputObject(orb, messageMediator,
                            corbaMessageMediator.getRequestHeader(),
                            corbaMessageMediator.getStreamFormatVersion(),
                            BufferManagerFactory.GROW);
    messageMediator.setOutputObject(outputObject);
    return outputObject;
}
 
Example #12
Source Project: openjdk-8   Author: bpupadhyaya   File: CorbaClientDelegateImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
public InputStream invoke(org.omg.CORBA.Object self, OutputStream output)
    throws
        ApplicationException,
        RemarshalException
{
    ClientRequestDispatcher subcontract = getClientRequestDispatcher();
    return (InputStream)
        subcontract.marshalingComplete((Object)self, (OutputObject)output);
}
 
Example #13
Source Project: jdk8u60   Author: chenghanpeng   File: CorbaClientDelegateImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
public InputStream invoke(org.omg.CORBA.Object self, OutputStream output)
    throws
        ApplicationException,
        RemarshalException
{
    ClientRequestDispatcher subcontract = getClientRequestDispatcher();
    return (InputStream)
        subcontract.marshalingComplete((Object)self, (OutputObject)output);
}
 
Example #14
Source Project: openjdk-8-source   Author: keerath   File: CorbaClientDelegateImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
public InputStream invoke(org.omg.CORBA.Object self, OutputStream output)
    throws
        ApplicationException,
        RemarshalException
{
    ClientRequestDispatcher subcontract = getClientRequestDispatcher();
    return (InputStream)
        subcontract.marshalingComplete((Object)self, (OutputObject)output);
}
 
Example #15
Source Project: jdk8u60   Author: chenghanpeng   File: CorbaContactInfoBase.java    License: GNU General Public License v2.0 5 votes vote down vote up
public OutputObject createOutputObject(MessageMediator messageMediator)
{
    CorbaMessageMediator corbaMessageMediator = (CorbaMessageMediator)
        messageMediator;

    OutputObject outputObject =
        sun.corba.OutputStreamFactory.newCDROutputObject(orb, messageMediator,
                            corbaMessageMediator.getRequestHeader(),
                            corbaMessageMediator.getStreamFormatVersion());

    messageMediator.setOutputObject(outputObject);
    return outputObject;
}
 
Example #16
Source Project: openjdk-8   Author: bpupadhyaya   File: CorbaContactInfoBase.java    License: GNU General Public License v2.0 5 votes vote down vote up
public OutputObject createOutputObject(MessageMediator messageMediator)
{
    CorbaMessageMediator corbaMessageMediator = (CorbaMessageMediator)
        messageMediator;

    OutputObject outputObject =
        sun.corba.OutputStreamFactory.newCDROutputObject(orb, messageMediator,
                            corbaMessageMediator.getRequestHeader(),
                            corbaMessageMediator.getStreamFormatVersion());

    messageMediator.setOutputObject(outputObject);
    return outputObject;
}
 
Example #17
Source Project: jdk8u60   Author: chenghanpeng   File: SocketOrChannelAcceptorImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
public OutputObject createOutputObject(Broker broker,
                                       MessageMediator messageMediator)
{
    CorbaMessageMediator corbaMessageMediator = (CorbaMessageMediator)
        messageMediator;
    return sun.corba.OutputStreamFactory.newCDROutputObject((ORB) broker,
                   corbaMessageMediator, corbaMessageMediator.getReplyHeader(),
                   corbaMessageMediator.getStreamFormatVersion());
}
 
Example #18
Source Project: jdk8u60   Author: chenghanpeng   File: SharedCDRContactInfoImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
public OutputObject createOutputObject(MessageMediator messageMediator)
{
    CorbaMessageMediator corbaMessageMediator = (CorbaMessageMediator)
        messageMediator;
    // NOTE: GROW.
    OutputObject outputObject =
        sun.corba.OutputStreamFactory.newCDROutputObject(orb, messageMediator,
                            corbaMessageMediator.getRequestHeader(),
                            corbaMessageMediator.getStreamFormatVersion(),
                            BufferManagerFactory.GROW);
    messageMediator.setOutputObject(outputObject);
    return outputObject;
}
 
Example #19
Source Project: openjdk-8-source   Author: keerath   File: CorbaMessageMediatorImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void endRequest(CorbaMessageMediator messageMediator)
{
    ORB orb = (ORB) messageMediator.getBroker();
    if (orb.subcontractDebugFlag) {
        dprint(".handleRequest<-: " + opAndId(messageMediator));
    }

    // release NIO ByteBuffers to ByteBufferPool

    try {
        OutputObject outputObj = messageMediator.getOutputObject();
        if (outputObj != null) {
            outputObj.close();
        }
        InputObject inputObj = messageMediator.getInputObject();
        if (inputObj != null) {
            inputObj.close();
        }
    } catch (IOException ex) {
        // Given what close() does, this catch shouldn't ever happen.
        // See CDRInput/OutputObject.close() for more info.
        // It also won't result in a Corba error if an IOException happens.
        if (orb.subcontractDebugFlag) {
            dprint(".endRequest: IOException:" + ex.getMessage(), ex);
        }
    } finally {
        ((CorbaConnection)messageMediator.getConnection()).serverRequestProcessingEnds();
    }
}
 
Example #20
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: CorbaMessageMediatorImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void endRequest(CorbaMessageMediator messageMediator)
{
    ORB orb = (ORB) messageMediator.getBroker();
    if (orb.subcontractDebugFlag) {
        dprint(".handleRequest<-: " + opAndId(messageMediator));
    }

    // release NIO ByteBuffers to ByteBufferPool

    try {
        OutputObject outputObj = messageMediator.getOutputObject();
        if (outputObj != null) {
            outputObj.close();
        }
        InputObject inputObj = messageMediator.getInputObject();
        if (inputObj != null) {
            inputObj.close();
        }
    } catch (IOException ex) {
        // Given what close() does, this catch shouldn't ever happen.
        // See CDRInput/OutputObject.close() for more info.
        // It also won't result in a Corba error if an IOException happens.
        if (orb.subcontractDebugFlag) {
            dprint(".endRequest: IOException:" + ex.getMessage(), ex);
        }
    } finally {
        ((CorbaConnection)messageMediator.getConnection()).serverRequestProcessingEnds();
    }
}
 
Example #21
Source Project: openjdk-8-source   Author: keerath   File: CorbaContactInfoBase.java    License: GNU General Public License v2.0 5 votes vote down vote up
public OutputObject createOutputObject(MessageMediator messageMediator)
{
    CorbaMessageMediator corbaMessageMediator = (CorbaMessageMediator)
        messageMediator;

    OutputObject outputObject =
        sun.corba.OutputStreamFactory.newCDROutputObject(orb, messageMediator,
                            corbaMessageMediator.getRequestHeader(),
                            corbaMessageMediator.getStreamFormatVersion());

    messageMediator.setOutputObject(outputObject);
    return outputObject;
}
 
Example #22
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 #23
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: SocketOrChannelConnectionImpl.java    License: GNU General Public License v2.0 4 votes vote down vote up
public void sendWithoutLock(OutputObject outputObject)
{
    // Don't we need to check for CloseConnection
    // here?  REVISIT

    // XREVISIT - Shouldn't the MessageMediator
    // be the one to handle writing the data here?

    try {

        // Write the fragment/message

        CDROutputObject cdrOutputObject = (CDROutputObject) outputObject;
        cdrOutputObject.writeTo(this);
        // REVISIT - no flush?
        //socket.getOutputStream().flush();

    } catch (IOException e1) {

        /*
         * ADDED(Ram J) 10/13/2000 In the event of an IOException, try
         * sending a CancelRequest for regular requests / locate requests
         */

        // Since IIOPOutputStream's msgheader is set only once, and not
        // altered during sending multiple fragments, the original
        // msgheader will always have the requestId.
        // REVISIT This could be optimized to send a CancelRequest only
        // if any fragments had been sent already.

        /* REVISIT: MOVE TO SUBCONTRACT
        Message msg = os.getMessage();
        if (msg.getType() == Message.GIOPRequest ||
                msg.getType() == Message.GIOPLocateRequest) {
            GIOPVersion requestVersion = msg.getGIOPVersion();
            int requestId = MessageBase.getRequestId(msg);
            try {
                sendCancelRequest(requestVersion, requestId);
            } catch (IOException e2) {
                // most likely an abortive connection closure.
                // ignore, since nothing more can be done.
                if (orb.transportDebugFlag) {

            }
        }
        */

        // REVISIT When a send failure happens, purgeCalls() need to be
        // called to ensure that the connection is properly removed from
        // further usage (ie., cancelling pending requests with COMM_FAILURE
        // with an appropriate minor_code CompletionStatus.MAY_BE).

        // Relying on the IIOPOutputStream (as noted below) is not
        // sufficient as it handles COMM_FAILURE only for the final
        // fragment (during invoke processing). Note that COMM_FAILURE could
        // happen while sending the initial fragments.
        // Also the IIOPOutputStream does not properly close the connection.
        // It simply removes the connection from the table. An orderly
        // closure is needed (ie., cancel pending requests on the connection
        // COMM_FAILURE as well.

        // IIOPOutputStream will cleanup the connection info when it
        // sees this exception.
        SystemException exc = wrapper.writeErrorSend(e1);
        purgeCalls(exc, false, true);
        throw exc;
    }
}
 
Example #24
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: CorbaClientRequestDispatcherImpl.java    License: Apache License 2.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 #25
Source Project: openjdk-8-source   Author: keerath   File: CorbaMessageMediatorImpl.java    License: 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 #26
Source Project: openjdk-8   Author: bpupadhyaya   File: ParserTable.java    License: GNU General Public License v2.0 4 votes vote down vote up
public OutputObject createOutputObject(
Broker broker, MessageMediator messageMediator) { return null; }
 
Example #27
Source Project: JDKSourceCode1.8   Author: wupeixuan   File: CorbaMessageMediatorImpl.java    License: MIT License 4 votes vote down vote up
public OutputObject getOutputObject()
{
    return outputObject;
}
 
Example #28
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: SocketOrChannelConnectionImpl.java    License: Apache License 2.0 4 votes vote down vote up
public void sendWithoutLock(OutputObject outputObject)
{
    // Don't we need to check for CloseConnection
    // here?  REVISIT

    // XREVISIT - Shouldn't the MessageMediator
    // be the one to handle writing the data here?

    try {

        // Write the fragment/message

        CDROutputObject cdrOutputObject = (CDROutputObject) outputObject;
        cdrOutputObject.writeTo(this);
        // REVISIT - no flush?
        //socket.getOutputStream().flush();

    } catch (IOException e1) {

        /*
         * ADDED(Ram J) 10/13/2000 In the event of an IOException, try
         * sending a CancelRequest for regular requests / locate requests
         */

        // Since IIOPOutputStream's msgheader is set only once, and not
        // altered during sending multiple fragments, the original
        // msgheader will always have the requestId.
        // REVISIT This could be optimized to send a CancelRequest only
        // if any fragments had been sent already.

        /* REVISIT: MOVE TO SUBCONTRACT
        Message msg = os.getMessage();
        if (msg.getType() == Message.GIOPRequest ||
                msg.getType() == Message.GIOPLocateRequest) {
            GIOPVersion requestVersion = msg.getGIOPVersion();
            int requestId = MessageBase.getRequestId(msg);
            try {
                sendCancelRequest(requestVersion, requestId);
            } catch (IOException e2) {
                // most likely an abortive connection closure.
                // ignore, since nothing more can be done.
                if (orb.transportDebugFlag) {

            }
        }
        */

        // REVISIT When a send failure happens, purgeCalls() need to be
        // called to ensure that the connection is properly removed from
        // further usage (ie., cancelling pending requests with COMM_FAILURE
        // with an appropriate minor_code CompletionStatus.MAY_BE).

        // Relying on the IIOPOutputStream (as noted below) is not
        // sufficient as it handles COMM_FAILURE only for the final
        // fragment (during invoke processing). Note that COMM_FAILURE could
        // happen while sending the initial fragments.
        // Also the IIOPOutputStream does not properly close the connection.
        // It simply removes the connection from the table. An orderly
        // closure is needed (ie., cancel pending requests on the connection
        // COMM_FAILURE as well.

        // IIOPOutputStream will cleanup the connection info when it
        // sees this exception.
        SystemException exc = wrapper.writeErrorSend(e1);
        purgeCalls(exc, false, true);
        throw exc;
    }
}
 
Example #29
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: BufferManagerWriteGrow.java    License: GNU General Public License v2.0 4 votes vote down vote up
public void sendMessage ()
{
    Connection conn =
          ((OutputObject)outputObject).getMessageMediator().getConnection();

    conn.writeLock();

    try {

        conn.sendWithoutLock((OutputObject)outputObject);

        sentFullMessage = true;

    } finally {

        conn.writeUnlock();
    }
}
 
Example #30
Source Project: hottub   Author: dsrg-uoft   File: BufferManagerWriteCollect.java    License: GNU General Public License v2.0 4 votes vote down vote up
public void sendMessage ()
{
    // Enqueue the last fragment
    queue.enqueue(((CDROutputObject)outputObject).getByteBufferWithInfo());

    Iterator bufs = iterator();

    Connection conn =
                      ((OutputObject)outputObject).getMessageMediator().
                                                   getConnection();

    // With the collect strategy, we must lock the connection
    // while fragments are being sent.  This is so that there are
    // no interleved fragments in GIOP 1.1.
    //
    // Note that this thread must not call writeLock again in any
    // of its send methods!
    conn.writeLock();

    try {

        // Get a reference to ByteBufferPool so that the ByteBufferWithInfo
        // ByteBuffer can be released to the ByteBufferPool
        ByteBufferPool byteBufferPool = orb.getByteBufferPool();

        while (bufs.hasNext()) {

            ByteBufferWithInfo bbwi = (ByteBufferWithInfo)bufs.next();
            ((CDROutputObject)outputObject).setByteBufferWithInfo(bbwi);

            conn.sendWithoutLock(((CDROutputObject)outputObject));

            sentFragment = true;

            // Release ByteBufferWithInfo's ByteBuffer back to the pool
            // of ByteBuffers.
            if (debug)
            {
                // print address of ByteBuffer being released
                int bbAddress = System.identityHashCode(bbwi.byteBuffer);
                StringBuffer sb = new StringBuffer(80);
                sb.append("sendMessage() - releasing ByteBuffer id (");
                sb.append(bbAddress).append(") to ByteBufferPool.");
                String msg = sb.toString();
                dprint(msg);
            }
            byteBufferPool.releaseByteBuffer(bbwi.byteBuffer);
            bbwi.byteBuffer = null;
            bbwi = null;
        }

        sentFullMessage = true;

    } finally {

        conn.writeUnlock();
    }
}