org.jboss.cache.marshall.io
Class ReusableObjectOutputStream
java.lang.Object
java.io.OutputStream
java.io.ObjectOutputStream
org.jboss.cache.marshall.io.ReusableObjectOutputStream
- All Implemented Interfaces:
- Closeable, DataOutput, Flushable, ObjectOutput, ObjectStreamConstants
public class ReusableObjectOutputStream
- extends ObjectOutputStream
An ObjectOutputStream that can safely be reset and reused. Allows for easy pooling of streams for performance.
This is an ObjectOutputStream with an internal underlying byte stream, which can be queried with getBytes()
.
This stream is reusable - calling reset()
will ensure the underlying byte stream is reset and the ObjectOutputStream
caches are flushed, and headers are written.
- Since:
- 2.1.0
- Author:
- Manik Surtani (manik@jboss.org)
Fields inherited from interface java.io.ObjectStreamConstants |
baseWireHandle, PROTOCOL_VERSION_1, PROTOCOL_VERSION_2, SC_BLOCK_DATA, SC_ENUM, SC_EXTERNALIZABLE, SC_SERIALIZABLE, SC_WRITE_METHOD, STREAM_MAGIC, STREAM_VERSION, SUBCLASS_IMPLEMENTATION_PERMISSION, SUBSTITUTION_PERMISSION, TC_ARRAY, TC_BASE, TC_BLOCKDATA, TC_BLOCKDATALONG, TC_CLASS, TC_CLASSDESC, TC_ENDBLOCKDATA, TC_ENUM, TC_EXCEPTION, TC_LONGSTRING, TC_MAX, TC_NULL, TC_OBJECT, TC_PROXYCLASSDESC, TC_REFERENCE, TC_RESET, TC_STRING |
Method Summary |
byte[] |
getBytes()
|
void |
init()
Initialises a pooled stream for use. |
void |
reset()
Unlike ObjectOutputStream.reset() , this method will flush and wipe the underlying byte stream,
and ensure ObjectOutputStream headers are rewritten, awaiting proper reuse. |
Methods inherited from class java.io.ObjectOutputStream |
annotateClass, annotateProxyClass, close, defaultWriteObject, drain, enableReplaceObject, flush, putFields, replaceObject, useProtocolVersion, write, write, write, writeBoolean, writeByte, writeBytes, writeClassDescriptor, writeDouble, writeFields, writeFloat, writeChar, writeChars, writeInt, writeLong, writeObject, writeObjectOverride, writeShort, writeStreamHeader, writeUnshared, writeUTF |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ReusableObjectOutputStream
public ReusableObjectOutputStream()
throws IOException,
SecurityException
- Throws:
IOException
SecurityException
ReusableObjectOutputStream
protected ReusableObjectOutputStream(org.jboss.cache.marshall.io.ReusableObjectOutputStream.ResettableByteArrayOutputStream baos)
throws IOException,
SecurityException
- Throws:
IOException
SecurityException
init
public void init()
- Initialises a pooled stream for use.
reset
public void reset()
throws IOException
- Unlike
ObjectOutputStream.reset()
, this method will flush and wipe the underlying byte stream,
and ensure ObjectOutputStream headers are rewritten, awaiting proper reuse.
- Overrides:
reset
in class ObjectOutputStream
- Throws:
IOException
getBytes
public byte[] getBytes()
throws IOException
- Returns:
- bytes in the underlying byte stream. Will internally do a flush first.
- Throws:
IOException
Copyright © 2008 JBoss, a division of Red Hat. All Rights Reserved.