FileDocCategorySizeDatePackage
CDROutputObject.javaAPI DocJava SE 5 API10254Fri Aug 26 14:54:20 BST 2005com.sun.corba.se.impl.encoding

CDROutputObject

public class CDROutputObject extends com.sun.corba.se.spi.encoding.CorbaOutputObject
author
Harold Carr

Fields Summary
private com.sun.corba.se.impl.protocol.giopmsgheaders.Message
header
private com.sun.corba.se.spi.orb.ORB
orb
private com.sun.corba.se.impl.logging.ORBUtilSystemException
wrapper
private com.sun.corba.se.impl.logging.OMGSystemException
omgWrapper
private com.sun.corba.se.spi.transport.CorbaConnection
connection
Constructors Summary
private CDROutputObject(com.sun.corba.se.spi.orb.ORB orb, com.sun.corba.se.spi.ior.iiop.GIOPVersion giopVersion, com.sun.corba.se.impl.protocol.giopmsgheaders.Message header, BufferManagerWrite manager, byte streamFormatVersion, com.sun.corba.se.spi.protocol.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;
    
public CDROutputObject(com.sun.corba.se.spi.orb.ORB orb, com.sun.corba.se.pept.protocol.MessageMediator messageMediator, com.sun.corba.se.impl.protocol.giopmsgheaders.Message header, byte streamFormatVersion)

        this(
	    orb, 
	    ((CorbaMessageMediator)messageMediator).getGIOPVersion(), 
	    header, 
	    BufferManagerFactory.newBufferManagerWrite(
		((CorbaMessageMediator)messageMediator).getGIOPVersion(),
		header.getEncodingVersion(),
		orb),
	    streamFormatVersion,
	    (CorbaMessageMediator)messageMediator);
    
public CDROutputObject(com.sun.corba.se.spi.orb.ORB orb, com.sun.corba.se.pept.protocol.MessageMediator messageMediator, com.sun.corba.se.impl.protocol.giopmsgheaders.Message header, byte streamFormatVersion, int strategy)

        this( 
	    orb, 
	    ((CorbaMessageMediator)messageMediator).getGIOPVersion(), 
	    header, 
            BufferManagerFactory.
	        newBufferManagerWrite(strategy,
				      header.getEncodingVersion(),
				      orb),
	    streamFormatVersion,
	    (CorbaMessageMediator)messageMediator);
    
public CDROutputObject(com.sun.corba.se.spi.orb.ORB orb, com.sun.corba.se.spi.protocol.CorbaMessageMediator mediator, com.sun.corba.se.spi.ior.iiop.GIOPVersion giopVersion, com.sun.corba.se.spi.transport.CorbaConnection connection, com.sun.corba.se.impl.protocol.giopmsgheaders.Message header, byte streamFormatVersion)

        this(
	    orb, 
	    giopVersion, 
	    header, 
            BufferManagerFactory.
	    newBufferManagerWrite(giopVersion,
				  header.getEncodingVersion(),
				  orb),
	    streamFormatVersion,
	    mediator);
	this.connection = connection ;
    
Methods Summary
protected CodeSetConversion.CTBConvertercreateCharCTBConverter()
Override the default CDR factory behavior to get the negotiated code sets from the connection. These are only called once per message, the first time needed. In the local case, there is no Connection, so use the local code sets.

        CodeSetComponentInfo.CodeSetContext codesets = getCodeSets();

        // If the connection doesn't have its negotiated
        // code sets by now, fall back on the defaults defined
        // in CDRInputStream.
        if (codesets == null)
            return super.createCharCTBConverter();
        
        OSFCodeSetRegistry.Entry charSet
            = OSFCodeSetRegistry.lookupEntry(codesets.getCharCodeSet());

        if (charSet == null)
	    throw wrapper.unknownCodeset( charSet ) ;

        return CodeSetConversion.impl().getCTBConverter(charSet, 
                                                        isLittleEndian(), 
                                                        false);
    
protected CodeSetConversion.CTBConvertercreateWCharCTBConverter()


        CodeSetComponentInfo.CodeSetContext codesets = getCodeSets();

        // If the connection doesn't have its negotiated
        // code sets by now, we have to throw an exception.
        // See CORBA formal 00-11-03 13.9.2.6.
        if (codesets == null) {
            if (getConnection().isServer())
		throw omgWrapper.noClientWcharCodesetCtx() ;
            else
		throw omgWrapper.noServerWcharCodesetCmp() ;
        }

        OSFCodeSetRegistry.Entry wcharSet
            = OSFCodeSetRegistry.lookupEntry(codesets.getWCharCodeSet());

        if (wcharSet == null)
	    throw wrapper.unknownCodeset( wcharSet ) ;

        boolean useByteOrderMarkers
            = ((ORB)orb()).getORBData().useByteOrderMarkers();

        // With UTF-16:
        //
        // For GIOP 1.2, we can put byte order markers if we want to, and
        // use the default of big endian otherwise.  (See issue 3405b)
        //
        // For GIOP 1.1, we don't use BOMs and use the endianness of
        // the stream.
        if (wcharSet == OSFCodeSetRegistry.UTF_16) {
            if (getGIOPVersion().equals(GIOPVersion.V1_2)) {
                return CodeSetConversion.impl().getCTBConverter(wcharSet, 
                                                                false, 
                                                                useByteOrderMarkers);
            }

            if (getGIOPVersion().equals(GIOPVersion.V1_1)) {
                return CodeSetConversion.impl().getCTBConverter(wcharSet,
                                                                isLittleEndian(),
                                                                false);
            }
        }

        // In the normal case, let the converter system handle it
        return CodeSetConversion.impl().getCTBConverter(wcharSet, 
                                                        isLittleEndian(),
                                                        useByteOrderMarkers);
    
public org.omg.CORBA.portable.InputStreamcreate_input_stream()
overrides create_input_stream from CDROutputStream

        // XREVISIT
	return null;
        //return new XIIOPInputStream(orb(), getByteBuffer(), getIndex(), 
	    //isLittleEndian(), getMessageHeader(), conn);
    
protected voiddprint(java.lang.String msg)

	ORBUtility.dprint("CDROutputObject", msg);
    
public final voidfinishSendingMessage()

        getBufferManager().sendMessage();
    
public final com.sun.corba.se.impl.encoding.ByteBufferWithInfogetByteBufferWithInfo()

        return super.getByteBufferWithInfo();
    
private CodeSetComponentInfo.CodeSetContextgetCodeSets()

        if (getConnection() == null)
            return CodeSetComponentInfo.LOCAL_CODE_SETS;
        else
            return getConnection().getCodeSetContext();
    
public com.sun.corba.se.spi.transport.CorbaConnectiongetConnection()

	// REVISIT - only set when doing sendCancelRequest.
	if (connection != null) {
	    return connection;
	}
	return (CorbaConnection) corbaMessageMediator.getConnection();
    
public com.sun.corba.se.impl.protocol.giopmsgheaders.MessagegetMessageHeader()

        return header;
    
public final voidsetByteBufferWithInfo(com.sun.corba.se.impl.encoding.ByteBufferWithInfo bbwi)

        super.setByteBufferWithInfo(bbwi);
    
public voidwriteTo(com.sun.corba.se.spi.transport.CorbaConnection connection)
Write the contents of the CDROutputStream to the specified output stream. Has the side-effect of pushing any current Message onto the Message list.

param
s The output stream to write to.


        //
        // Update the GIOP MessageHeader size field.
        //

        ByteBufferWithInfo bbwi = getByteBufferWithInfo();

        getMessageHeader().setSize(bbwi.byteBuffer, bbwi.getSize());

        if (orb() != null) {
	    if (((ORB)orb()).transportDebugFlag) {
		dprint(".writeTo: " + connection);
	    }
	    if (((ORB)orb()).giopDebugFlag) {
		CDROutputStream_1_0.printBuffer(bbwi);
	    }
        }
	bbwi.byteBuffer.position(0).limit(bbwi.getSize());
	connection.write(bbwi.byteBuffer);