[jboss-dev-forums] [Design of JBossCache] - Re: Common marshalling infrastructure

david.lloyd@jboss.com do-not-reply at jboss.com
Wed Aug 6 11:25:42 EDT 2008


"manik.surtani at jboss.com" wrote : * How are ObjectMarshallers selected?  Based on the class info from the ClassMarshaller?  Could this be ClassMarshaller + some token from the StreamHeader? (see previous point for reason why)

You'd configure your MarshallerFactory to use a specific ObjectMarshaller.  The ObjectMarshaller is generally responsible for the wire format of the stream as well as object instance pooling.  The current design expects you to select your marshaller before you start reading... I didn't think of the case where you want to somehow detect it.  I guess the thing to do in this case is write a bit of code that reads the header, determines the marshaller to use, and then connects the stream to that header?  I'm not sure there's a clean way to integrate detection that wouldn't be more easily done outside of the framework.  I'll think about it some more, or if you have any ideas...?

"manik.surtani at jboss.com" wrote : * Pooling MOIS and MOOS - probably will have to happen due to the cost of constructing these, and if they are reused, why would you discard the Object and Cache Marshallers from the Marshaller?

You want to dump your instance and class caches on every "session".  The Object/ClassMarshallers should be very cheap to construct (basically building an empty hashmap on write, or an empty arraylist on read).  The Marshallers *should* be decoupled from MOIS/MOOS usually; I would expect that an implementation would be able implement pooling of these instances if needed.  Note that even if you retain 100% JDK compatibility, if you never serialize an object that has readObject/writeObject methods, then you never even need to have a MOIS/MOOS at all, so that's the cheapest cost possible. :-)  In other words, if you use Externalizable, Externalizer, and default serialization exclusively, then the cost is never incurred.

Also keep in mind that constructing MOIS/MOOS are not *as* expensive as standard Object*Streams because they use the alternate "build my own implementation" constructor which just nulls out most of the fields.  However there is still the issue of a security check on each construction, which may or may not be significant.

* Reference counting.  Do you propose any sort of ref counting, if I were to write the same instance to the stream multiple times?



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4169081#4169081

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4169081



More information about the jboss-dev-forums mailing list