|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.OutputStream
org.openejb.util.io.ObjectOutputStream
public class ObjectOutputStream
This is a faster ObjectOutputStream for high volume object serialization.
This ObjectOutputStream's strength is that it can be reused unlike the Sun ObjectOutputStream
which needs to be discarded and re-instantiated. This ObjectOutputStream also has the main
algorithm inlined. This of coarse looks terrible but is faster then delegating everything
to reusable methods. This is implementation is not finished yet as it does not use the writeObject
callback method and does not serialize exceptions to the stream as it should.
We chose not to implement the formula to generate the serialVersionID for classes that do not specify
one explicitly as this adds a lot of overhead the first time a new class type is introduced into the stream.
This will most likely be added as an optional function.
This ObjectOutputStream is not faster in all situations. When doing only a few dozen serializations during
the life of the VM you will want to use the java.io.ObjectOutputStream. You'll notice however that this
ObjectOutputStream performs considerably faster with a high number of serializations. This makes this implementation
ideal for handling the heavy load of typical a server.
Run the SerializationPerformanceTest to get a better idea on how this OutputPerforms on your machine.
example: $java org.openejb.test.SerializationPerformanceTest 20 100 10
| Field Summary |
|---|
| 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 |
| Constructor Summary | |
|---|---|
ObjectOutputStream(java.io.OutputStream out)
|
|
| Method Summary | |
|---|---|
void |
flush()
Flushes this data output stream. |
void |
reset()
|
void |
serializeObject(java.lang.Object obj)
|
void |
serializeObject(java.lang.Object obj,
java.io.OutputStream out)
|
int |
size()
Returns the current size of the buffer. |
byte[] |
toByteArray()
Creates a newly allocated byte array. |
void |
write(byte[] b,
int off,
int len)
Writes len bytes from the specified byte array
starting at offset off to this byte array output stream. |
void |
write(int b)
Writes the specified byte to this byte array output stream. |
void |
writeBoolean(boolean v)
Writes a boolean to the underlying output stream as
a 1-byte value. |
void |
writeByte(int v)
Writes out a byte to the underlying output stream as
a 1-byte value. |
void |
writeBytes(java.lang.String s)
Writes out the string to the underlying output stream as a sequence of bytes. |
void |
writeChar(int v)
Writes a char to the underlying output stream as a
2-byte value, high byte first. |
void |
writeChars(java.lang.String s)
Writes a string to the underlying output stream as a sequence of characters. |
void |
writeDouble(double v)
Converts the double argument to a long using the
doubleToLongBits method in class Double,
and then writes that long value to the underlying
output stream as an 8-byte quantity, high byte first. |
void |
writeException(java.lang.Throwable th)
|
void |
writeFloat(float v)
Converts the float argument to an int using the
floatToIntBits method in class Float,
and then writes that int value to the underlying
output stream as a 4-byte quantity, high byte first. |
void |
writeInt(int v)
Writes an int to the underlying output stream as four
bytes, high byte first. |
void |
writeLong(long v)
Writes a long to the underlying output stream as eight
bytes, high byte first. |
void |
writeObject(java.lang.Object obj)
|
void |
writeReset()
|
void |
writeShort(int v)
Writes a short to the underlying output stream as two
bytes, high byte first. |
void |
writeString(java.lang.String s)
|
void |
writeUTF(java.lang.String str)
|
| Methods inherited from class java.io.OutputStream |
|---|
close, write |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.io.ObjectOutput |
|---|
close, write |
| Constructor Detail |
|---|
public ObjectOutputStream(java.io.OutputStream out)
throws java.io.IOException
java.io.IOException| Method Detail |
|---|
public void reset()
throws java.io.IOException
java.io.IOException
public void serializeObject(java.lang.Object obj,
java.io.OutputStream out)
throws java.io.NotSerializableException,
java.io.IOException
java.io.NotSerializableException
java.io.IOException
public void serializeObject(java.lang.Object obj)
throws java.io.NotSerializableException,
java.io.IOException
java.io.NotSerializableException
java.io.IOException
public void writeObject(java.lang.Object obj)
throws java.io.IOException
writeObject in interface java.io.ObjectOutputjava.io.IOException
public void writeString(java.lang.String s)
throws java.io.IOException
java.io.IOException
public void writeException(java.lang.Throwable th)
throws java.io.IOException
java.io.IOException
public void writeReset()
throws java.io.IOException
java.io.IOExceptionpublic void write(int b)
write in interface java.io.DataOutputwrite in interface java.io.ObjectOutputwrite in class java.io.OutputStreamb - the byte to be written.
public void write(byte[] b,
int off,
int len)
len bytes from the specified byte array
starting at offset off to this byte array output stream.
write in interface java.io.DataOutputwrite in interface java.io.ObjectOutputwrite in class java.io.OutputStreamb - the data.off - the start offset in the data.len - the number of bytes to write.
public void flush()
throws java.io.IOException
The flush method of DataOuputStream
calls the flush method of its underlying output stream.
flush in interface java.io.Flushableflush in interface java.io.ObjectOutputflush in class java.io.OutputStreamjava.io.IOException - if an I/O error occurs.public byte[] toByteArray()
ByteArrayOutputStream.size()public int size()
count field, which is the number
of valid bytes in this output stream.
public final void writeBoolean(boolean v)
throws java.io.IOException
boolean to the underlying output stream as
a 1-byte value. The value true is written out as the
value (byte)1; the value false is
written out as the value (byte)0.
writeBoolean in interface java.io.DataOutputv - a boolean value to be written.
java.io.IOException - if an I/O error occurs.
public final void writeByte(int v)
throws java.io.IOException
byte to the underlying output stream as
a 1-byte value.
writeByte in interface java.io.DataOutputv - a byte value to be written.
java.io.IOException - if an I/O error occurs.
public final void writeShort(int v)
throws java.io.IOException
short to the underlying output stream as two
bytes, high byte first.
writeShort in interface java.io.DataOutputv - a short to be written.
java.io.IOException - if an I/O error occurs.
public final void writeChar(int v)
throws java.io.IOException
char to the underlying output stream as a
2-byte value, high byte first.
writeChar in interface java.io.DataOutputv - a char value to be written.
java.io.IOException - if an I/O error occurs.
public final void writeInt(int v)
throws java.io.IOException
int to the underlying output stream as four
bytes, high byte first.
writeInt in interface java.io.DataOutputv - an int to be written.
java.io.IOException - if an I/O error occurs.
public final void writeLong(long v)
throws java.io.IOException
long to the underlying output stream as eight
bytes, high byte first.
writeLong in interface java.io.DataOutputv - a long to be written.
java.io.IOException - if an I/O error occurs.
public final void writeFloat(float v)
throws java.io.IOException
int using the
floatToIntBits method in class Float,
and then writes that int value to the underlying
output stream as a 4-byte quantity, high byte first.
writeFloat in interface java.io.DataOutputv - a float value to be written.
java.io.IOException - if an I/O error occurs.
public final void writeDouble(double v)
throws java.io.IOException
long using the
doubleToLongBits method in class Double,
and then writes that long value to the underlying
output stream as an 8-byte quantity, high byte first. *
writeDouble in interface java.io.DataOutputv - a double value to be written.
java.io.IOException - if an I/O error occurs.Double.doubleToLongBits(double)
public final void writeBytes(java.lang.String s)
throws java.io.IOException
writeBytes in interface java.io.DataOutputs - a string of bytes to be written.
java.io.IOException - if an I/O error occurs.
public final void writeChars(java.lang.String s)
throws java.io.IOException
writeChars in interface java.io.DataOutputs - a String value to be written.
java.io.IOException - if an I/O error occurs.
public final void writeUTF(java.lang.String str)
throws java.io.IOException
writeUTF in interface java.io.DataOutputjava.io.IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||