src/java.corba/share/classes/com/sun/corba/se/impl/encoding/BufferManagerWriteGrow.java
author msheppar
Sun, 03 Sep 2017 16:08:13 +0100
changeset 48554 592e22777742
parent 47216 71c04702a3d5
permissions -rw-r--r--
8160104: CORBA communication improvements Reviewed-by: rriggs, dfuchs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4
02bb8761fcce Initial load
duke
parents:
diff changeset
     1
/*
48554
592e22777742 8160104: CORBA communication improvements
msheppar
parents: 47216
diff changeset
     2
 * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
4
02bb8761fcce Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
02bb8761fcce Initial load
duke
parents:
diff changeset
     4
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
02bb8761fcce Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
4
02bb8761fcce Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
4
02bb8761fcce Initial load
duke
parents:
diff changeset
    10
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
02bb8761fcce Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
02bb8761fcce Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
02bb8761fcce Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
02bb8761fcce Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
02bb8761fcce Initial load
duke
parents:
diff changeset
    16
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
02bb8761fcce Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
02bb8761fcce Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
02bb8761fcce Initial load
duke
parents:
diff changeset
    20
 *
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
    23
 * questions.
4
02bb8761fcce Initial load
duke
parents:
diff changeset
    24
 */
02bb8761fcce Initial load
duke
parents:
diff changeset
    25
02bb8761fcce Initial load
duke
parents:
diff changeset
    26
package com.sun.corba.se.impl.encoding;
02bb8761fcce Initial load
duke
parents:
diff changeset
    27
02bb8761fcce Initial load
duke
parents:
diff changeset
    28
import com.sun.corba.se.impl.orbutil.ORBConstants;
48554
592e22777742 8160104: CORBA communication improvements
msheppar
parents: 47216
diff changeset
    29
import com.sun.corba.se.impl.orbutil.ORBUtility;
4
02bb8761fcce Initial load
duke
parents:
diff changeset
    30
import com.sun.corba.se.impl.encoding.ByteBufferWithInfo;
02bb8761fcce Initial load
duke
parents:
diff changeset
    31
import com.sun.corba.se.impl.encoding.BufferManagerWrite;
02bb8761fcce Initial load
duke
parents:
diff changeset
    32
import com.sun.corba.se.pept.encoding.OutputObject;
02bb8761fcce Initial load
duke
parents:
diff changeset
    33
import com.sun.corba.se.pept.transport.Connection;
02bb8761fcce Initial load
duke
parents:
diff changeset
    34
import com.sun.corba.se.spi.orb.ORB;
48554
592e22777742 8160104: CORBA communication improvements
msheppar
parents: 47216
diff changeset
    35
import com.sun.corba.se.spi.orb.ORBData;
4
02bb8761fcce Initial load
duke
parents:
diff changeset
    36
02bb8761fcce Initial load
duke
parents:
diff changeset
    37
public class BufferManagerWriteGrow extends BufferManagerWrite
02bb8761fcce Initial load
duke
parents:
diff changeset
    38
{
02bb8761fcce Initial load
duke
parents:
diff changeset
    39
    BufferManagerWriteGrow( ORB orb )
02bb8761fcce Initial load
duke
parents:
diff changeset
    40
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
    41
        super(orb) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    42
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
    43
02bb8761fcce Initial load
duke
parents:
diff changeset
    44
    public boolean sentFragment() {
02bb8761fcce Initial load
duke
parents:
diff changeset
    45
        return false;
02bb8761fcce Initial load
duke
parents:
diff changeset
    46
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
    47
02bb8761fcce Initial load
duke
parents:
diff changeset
    48
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
    49
     * Returns the correct buffer size for this type of
02bb8761fcce Initial load
duke
parents:
diff changeset
    50
     * buffer manager as set in the ORB.
02bb8761fcce Initial load
duke
parents:
diff changeset
    51
     */
02bb8761fcce Initial load
duke
parents:
diff changeset
    52
    public int getBufferSize() {
48554
592e22777742 8160104: CORBA communication improvements
msheppar
parents: 47216
diff changeset
    53
        ORBData orbData = null;
592e22777742 8160104: CORBA communication improvements
msheppar
parents: 47216
diff changeset
    54
        int bufferSize = ORBConstants.GIOP_DEFAULT_BUFFER_SIZE;
592e22777742 8160104: CORBA communication improvements
msheppar
parents: 47216
diff changeset
    55
        if (orb != null) {
592e22777742 8160104: CORBA communication improvements
msheppar
parents: 47216
diff changeset
    56
            orbData = orb.getORBData();
592e22777742 8160104: CORBA communication improvements
msheppar
parents: 47216
diff changeset
    57
            if (orbData != null) {
592e22777742 8160104: CORBA communication improvements
msheppar
parents: 47216
diff changeset
    58
                bufferSize = orbData.getGIOPBufferSize();
592e22777742 8160104: CORBA communication improvements
msheppar
parents: 47216
diff changeset
    59
                dprint("BufferManagerWriteGrow.getBufferSize: bufferSize == " + bufferSize);
592e22777742 8160104: CORBA communication improvements
msheppar
parents: 47216
diff changeset
    60
            } else {
592e22777742 8160104: CORBA communication improvements
msheppar
parents: 47216
diff changeset
    61
                dprint("BufferManagerWriteGrow.getBufferSize: orbData reference is NULL");
592e22777742 8160104: CORBA communication improvements
msheppar
parents: 47216
diff changeset
    62
            }
592e22777742 8160104: CORBA communication improvements
msheppar
parents: 47216
diff changeset
    63
        } else {
592e22777742 8160104: CORBA communication improvements
msheppar
parents: 47216
diff changeset
    64
            dprint("BufferManagerWriteGrow.getBufferSize: orb reference is NULL");
592e22777742 8160104: CORBA communication improvements
msheppar
parents: 47216
diff changeset
    65
        }
592e22777742 8160104: CORBA communication improvements
msheppar
parents: 47216
diff changeset
    66
        return bufferSize;
4
02bb8761fcce Initial load
duke
parents:
diff changeset
    67
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
    68
02bb8761fcce Initial load
duke
parents:
diff changeset
    69
    public void overflow (ByteBufferWithInfo bbwi)
02bb8761fcce Initial load
duke
parents:
diff changeset
    70
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
    71
        // The code that once lived directly in CDROutputStream.grow()
02bb8761fcce Initial load
duke
parents:
diff changeset
    72
        // has been moved ByteBufferWithInfo.growBuffer().
02bb8761fcce Initial load
duke
parents:
diff changeset
    73
02bb8761fcce Initial load
duke
parents:
diff changeset
    74
        // Grow ByteBufferWithInfo to a larger size.
02bb8761fcce Initial load
duke
parents:
diff changeset
    75
        bbwi.growBuffer(orb);
02bb8761fcce Initial load
duke
parents:
diff changeset
    76
02bb8761fcce Initial load
duke
parents:
diff changeset
    77
        // Must be false for the grow case
02bb8761fcce Initial load
duke
parents:
diff changeset
    78
        bbwi.fragmented = false;
02bb8761fcce Initial load
duke
parents:
diff changeset
    79
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
    80
02bb8761fcce Initial load
duke
parents:
diff changeset
    81
    public void sendMessage ()
02bb8761fcce Initial load
duke
parents:
diff changeset
    82
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
    83
        Connection conn =
02bb8761fcce Initial load
duke
parents:
diff changeset
    84
              ((OutputObject)outputObject).getMessageMediator().getConnection();
02bb8761fcce Initial load
duke
parents:
diff changeset
    85
02bb8761fcce Initial load
duke
parents:
diff changeset
    86
        conn.writeLock();
02bb8761fcce Initial load
duke
parents:
diff changeset
    87
02bb8761fcce Initial load
duke
parents:
diff changeset
    88
        try {
02bb8761fcce Initial load
duke
parents:
diff changeset
    89
02bb8761fcce Initial load
duke
parents:
diff changeset
    90
            conn.sendWithoutLock((OutputObject)outputObject);
02bb8761fcce Initial load
duke
parents:
diff changeset
    91
02bb8761fcce Initial load
duke
parents:
diff changeset
    92
            sentFullMessage = true;
02bb8761fcce Initial load
duke
parents:
diff changeset
    93
02bb8761fcce Initial load
duke
parents:
diff changeset
    94
        } finally {
02bb8761fcce Initial load
duke
parents:
diff changeset
    95
02bb8761fcce Initial load
duke
parents:
diff changeset
    96
            conn.writeUnlock();
02bb8761fcce Initial load
duke
parents:
diff changeset
    97
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
    98
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
    99
02bb8761fcce Initial load
duke
parents:
diff changeset
   100
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   101
     * Close the BufferManagerWrite and do any outstanding cleanup.
02bb8761fcce Initial load
duke
parents:
diff changeset
   102
     *
02bb8761fcce Initial load
duke
parents:
diff changeset
   103
     * No work to do for a BufferManagerWriteGrow.
02bb8761fcce Initial load
duke
parents:
diff changeset
   104
     */
02bb8761fcce Initial load
duke
parents:
diff changeset
   105
    public void close() {}
02bb8761fcce Initial load
duke
parents:
diff changeset
   106
48554
592e22777742 8160104: CORBA communication improvements
msheppar
parents: 47216
diff changeset
   107
    private void dprint(String msg) {
592e22777742 8160104: CORBA communication improvements
msheppar
parents: 47216
diff changeset
   108
        if (orb.transportDebugFlag) {
592e22777742 8160104: CORBA communication improvements
msheppar
parents: 47216
diff changeset
   109
            ORBUtility.dprint(this, msg);
4
02bb8761fcce Initial load
duke
parents:
diff changeset
   110
}
48554
592e22777742 8160104: CORBA communication improvements
msheppar
parents: 47216
diff changeset
   111
    }
592e22777742 8160104: CORBA communication improvements
msheppar
parents: 47216
diff changeset
   112
}