I'm experimenting with using TC for Web Sessions on Tomcat 6. I would like to use custom ObjectOutputStream/ObjectInputStream implementations, which override ReplaceObject/ResolveObject in order to do some object substitutions.
Is there a way to instruct Terracotta to use my custom classes instead of the standard ones when performing session serialization/deserialization? If possible, I would expect this to be specified via declarative TerracottaTomcat60xSessionValve settings in context.xml. Unfortunately, I can't seem to find any documentation to this effect, including API doc on that valve class.
Does anyone know if this is possible? I sure hope so.
Unfortunately there really is no mechanism to plugin your input/output stream classes there as you desire.
We actually use custom classes for doing serialization as well to optimize how class descriptors are stored.
I'll admit I don't have much experience with those resolve/replace methods, but I thought there was a way to get a similar affect with magic method in the types you're serializing (much like readObject()) ?
The only other thing I can think that you could do would be to do the serialization/deserialization yourself and then store resulting byte[] in the session.
It looks like I can accomplish what I need by having certain of my classes implement the magic writeReplace() and readResolve() methods. Can you please confirm that your custom serialization classes will indeed invoke those methods?
Well I guess I wouldn't want to say for certain that those standard methods work with our serialization without trying it first, but I have no reason to suspect they would not. We just subclass ObjectOutputStream and ObjectInputStream and don't touch the paths where those methods would be invoked.