Monotoring serialized objects

Is there a way to monitor which objects is really serialized to my ObjectOutputStream. I want to make sure that I do not send a lot of unnecessery objects on the network since references to objects is also serialized.
[231 byte] By [d97te] at [2007-9-26 2:19:04]
# 1

I use Externalizable rather than Serializable. By using Externalizable it requires that your object has the following two methods:

public void readExternal(ObjectInput in)

throws IOException;

public void writeExternal(ObjectOutput out)

throws IOException;

In the readExternal you supply the mechanism for objects to be read such as:

//This assumes that x is of type myObject

x = (myObject)in.readObject();

In the writeExternal you supply the mechanism for objects to be written. I use this to write out an array, but I only write out the "used" elements, to save on traffic:

public Object[] pullPieces() {

Object[] result = new Object[pos];

System.arraycopy(all_obj,0,result,0,pos);

return result;

}

public void writeExternal(ObjectOut out)

throws IOException{

out.writeObject(pullPieces());

}

Hope this helps..

scooterj at 2007-6-29 9:20:55 > top of Java-index,Core,Core APIs...