org.jacorb.orb
Class BufferManager

java.lang.Object
  extended byorg.jacorb.orb.BufferManager

public final class BufferManager
extends java.lang.Object

A BufferManager is used to share a pool of buffers and to implement a buffer allocation policy. This reduces the number of memory allocations and deallocations and the overall memory footprint. Buffers are generally created on demand. The BufferManager uses a singleton pattern, so will only be a single shared BuffferManager across all ORBs in a process.

Version:
$Id: BufferManager.java,v 1.20 2005/12/07 15:20:35 andre.spiegel Exp $
Author:
Gerald Brose, FU Berlin

Method Summary
static void configure(org.apache.avalon.framework.configuration.Configuration configuration)
          configures the BufferManager, in turn configures the singleton.
 byte[] getBuffer(int initial)
           
 byte[] getBuffer(int initial, boolean cdrStr)
          getBuffer returns a new buffer.
static BufferManager getInstance()
          May only be called after configure()
 byte[] getPreferredMemoryBuffer()
           
 void release()
           
 void returnBuffer(byte[] current)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

configure

public static void configure(org.apache.avalon.framework.configuration.Configuration configuration)
                      throws org.apache.avalon.framework.configuration.ConfigurationException
configures the BufferManager, in turn configures the singleton. Must be called before getInstance() !

Throws:
org.apache.avalon.framework.configuration.ConfigurationException

getInstance

public static BufferManager getInstance()
                                 throws BAD_INV_ORDER
May only be called after configure()

Throws:
BAD_INV_ORDER - if not previously configured

getPreferredMemoryBuffer

public byte[] getPreferredMemoryBuffer()

getBuffer

public byte[] getBuffer(int initial)

getBuffer

public byte[] getBuffer(int initial,
                        boolean cdrStr)
getBuffer returns a new buffer.

Parameters:
initial - an int value
cdrStr - a boolean value to denote if CDROuputStream is caller (may use cache in this situation)
Returns:
a byte[] value

returnBuffer

public void returnBuffer(byte[] current)

release

public void release()