|
||||||||||
| 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 |
|---|
| Constructor Summary | |
|---|---|
ObjectOutputStream(OutputStream out)
|
|
| Method Summary | |
|---|---|
void |
flush()
Flushes this data output stream. |
void |
reset()
|
void |
serializeObject(Object obj)
|
void |
serializeObject(Object obj,
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(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(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(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(Object obj)
|
void |
writeReset()
|
void |
writeShort(int v)
Writes a short to the underlying output stream as two
bytes, high byte first. |
void |
writeString(String s)
|
void |
writeUTF(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(OutputStream out)
throws IOException
IOException| Method Detail |
|---|
public void reset()
throws IOException
IOException
public void serializeObject(Object obj,
OutputStream out)
throws NotSerializableException,
IOException
NotSerializableException
IOException
public void serializeObject(Object obj)
throws NotSerializableException,
IOException
NotSerializableException
IOException
public void writeObject(Object obj)
throws IOException
writeObject in interface ObjectOutputIOException
public void writeString(String s)
throws IOException
IOException
public void writeException(Throwable th)
throws IOException
IOException
public void writeReset()
throws IOException
IOExceptionpublic void write(int b)
write in interface DataOutputwrite in interface ObjectOutputwrite in class 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 DataOutputwrite in interface ObjectOutputwrite in class OutputStreamb - the data.off - the start offset in the data.len - the number of bytes to write.
public void flush()
throws IOException
The flush method of DataOuputStream
calls the flush method of its underlying output stream.
flush in interface Flushableflush in interface ObjectOutputflush in class OutputStreamIOException - 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 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 DataOutputv - a boolean value to be written.
IOException - if an I/O error occurs.
public final void writeByte(int v)
throws IOException
byte to the underlying output stream as
a 1-byte value.
writeByte in interface DataOutputv - a byte value to be written.
IOException - if an I/O error occurs.
public final void writeShort(int v)
throws IOException
short to the underlying output stream as two
bytes, high byte first.
writeShort in interface DataOutputv - a short to be written.
IOException - if an I/O error occurs.
public final void writeChar(int v)
throws IOException
char to the underlying output stream as a
2-byte value, high byte first.
writeChar in interface DataOutputv - a char value to be written.
IOException - if an I/O error occurs.
public final void writeInt(int v)
throws IOException
int to the underlying output stream as four
bytes, high byte first.
writeInt in interface DataOutputv - an int to be written.
IOException - if an I/O error occurs.
public final void writeLong(long v)
throws IOException
long to the underlying output stream as eight
bytes, high byte first.
writeLong in interface DataOutputv - a long to be written.
IOException - if an I/O error occurs.
public final void writeFloat(float v)
throws 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 DataOutputv - a float value to be written.
IOException - if an I/O error occurs.
public final void writeDouble(double v)
throws 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 DataOutputv - a double value to be written.
IOException - if an I/O error occurs.Double.doubleToLongBits(double)
public final void writeBytes(String s)
throws IOException
writeBytes in interface DataOutputs - a string of bytes to be written.
IOException - if an I/O error occurs.
public final void writeChars(String s)
throws IOException
writeChars in interface DataOutputs - a String value to be written.
IOException - if an I/O error occurs.
public final void writeUTF(String str)
throws IOException
writeUTF in interface DataOutputIOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||