org.apache.axiom.attachments.impl
Class BufferUtils
java.lang.Object
org.apache.axiom.attachments.impl.BufferUtils
public class BufferUtils
- extends java.lang.Object
Attachment processing uses a lot of buffers.
The BufferUtils class attempts to reuse buffers to prevent
excessive GarbageCollection
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
log
private static org.apache.commons.logging.Log log
BUFFER_LEN
static int BUFFER_LEN
ENABLE_FILE_CHANNEL
static boolean ENABLE_FILE_CHANNEL
_cacheBuffer
private static byte[] _cacheBuffer
_cacheBufferInUse
private static boolean _cacheBufferInUse
_cacheByteBuffer
private static java.nio.ByteBuffer _cacheByteBuffer
_cacheByteBufferInUse
private static boolean _cacheByteBufferInUse
BufferUtils
public BufferUtils()
inputStream2OutputStream
public static void inputStream2OutputStream(java.io.InputStream is,
java.io.OutputStream os)
throws java.io.IOException
- Private utility to write the InputStream contents to the OutputStream.
- Parameters:
is
- os
-
- Throws:
java.io.IOException
inputStream2OutputStream
public static int inputStream2OutputStream(java.io.InputStream is,
java.io.OutputStream os,
int limit)
throws java.io.IOException
- Parameters:
is
- InputStreamos
- OutputStreamlimit
- maximum number of bytes to read
- Returns:
- total ytes read
- Throws:
java.io.IOException
inputStream2FileOutputStream
public static boolean inputStream2FileOutputStream(java.io.InputStream is,
java.io.FileOutputStream fos)
throws java.io.IOException
- Opimized writing to FileOutputStream using a channel
- Parameters:
is
- fos
-
- Returns:
- false if lock was not aquired
- Throws:
java.io.IOException
doesDataHandlerExceedLimit
public static int doesDataHandlerExceedLimit(javax.activation.DataHandler dh,
int limit)
- The method checks to see if attachment is eligble for optimization.
An attachment is eligible for optimization if and only if the size of
the attachment is greated then the optimzation threshold size limit.
if the Content represented by DataHandler has size less than the
optimize threshold size, the attachment will not be eligible for
optimization, instead it will be inlined.
returns 1 if DataHandler data is bigger than limit.
returns 0 if DataHandler data is smaller.
return -1 if an error occurs or unsupported.
- Parameters:
in
-
- Returns:
-
- Throws:
java.io.IOException
getInputStream
private static java.io.InputStream getInputStream(javax.activation.DataHandler dataHandlerObject)
throws OMException
- Throws:
OMException
getTempBuffer
private static byte[] getTempBuffer()
releaseTempBuffer
private static void releaseTempBuffer(byte[] buffer)
getTempByteBuffer
private static java.nio.ByteBuffer getTempByteBuffer()
releaseTempByteBuffer
private static void releaseTempByteBuffer(java.nio.ByteBuffer buffer)