-
1. Re: Aspectization via XML seems to fail
mathias.chouet Jul 11, 2008 10:16 AM (in response to mathias.chouet)I'm sorry to post again so soon, but I thought I could add a precision:
When adding<attribute name="marshallNonSerializable">True</attribute>
to pojocache-aop.xml, I don't get the "org.jboss.cache.pojo.PojoCacheException" anymore during call toattach(myFqn,myByteInterleavedRaster);
Nevertheless, any call tofind(myFqn)
returns null, no matter if the cache instance is the one I used to attach(...) or a remote instance.
I'm very surprised because I easily managed to replicate homemade, non-serializable pojo's and this example doesn't work...
Thanks in advance, any help would be very appreciated.
Mathias -
2. Re: Aspectization via XML seems to fail
jason.greene Jul 12, 2008 3:19 AM (in response to mathias.chouet)You ask a very good question. The problem is that you can't advise anything in the bootclasspath, which the awt image stuff is. You would have to weave the classes offline, and then use the Xbootclasspath option, which is technically a violation of the JRE.
A simpler approach is to wrap the image with a custom serializer type like so:public static class ImageWrapper implements Serializable { private RenderedImage image; public ImageWrapper(RenderedImage image) { this.image = image; } public RenderedImage getImage() { return image; } private void writeObject(java.io.ObjectOutputStream out) throws IOException { ImageIO.write(image, "javax_imageio_1.0", out); } private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { image = ImageIO.read(in); } }
You can then declare your field as the wrapper class and use the extra indirection, or alternatively you can mark the non-serializable field as transient, and use the wrapper in a new field, which is used to lazily initialize the transient field. -
3. Re: Aspectization via XML seems to fail
mathias.chouet Jul 15, 2008 4:16 AM (in response to mathias.chouet)First, thank you very much for your answer, which helps me a lot!
I think I had not understood well the nature of the operations performed by the agent at JVM boot. Actually, I see now the necessity of using offline weaving then the -Xbootclasspath option; it is certainly not acceptable as it is violating the JRE.
Therefore I'll try your solution, which seems perfectly suitable in my case. Thanks again for your explanation, for the rest it's a pleasure to use JBossCache.
Regards,
Mathias