10 Replies Latest reply on Dec 18, 2006 2:11 PM by esspe

    How do I serialized an POJO stored in the cache

    patlap

      Hi ,

      I am using JobssCacheAop and I want to serialized a POJO stored in the cache in order to sent it on a different network.

      Its seems that once stored in the cache, one field of my POJO is replaced with AOPClassProxy$0 and then become not portable.

      I am sure there is something in the API to give me back my object??

      Thanks

        • 1. Re: How do I serialized an POJO stored in the cache

          If you do "removeObject", it should give you back the original POJO. Later on, you can do another "putObject" again (as a merge, so to speak).

          • 2. Re: How do I serialized an POJO stored in the cache
            patlap

            I did a quick test and it is still giving me the aspectized pojo. This is the proof.
            The XML representation of my obj in different stage of execution:

            before to store it in the cache:
            <com.cae.launchpad.core.dao.Student>
             <school>ULLAVAL</school>
             <courses class="linked-hash-set">
             <com.cae.launchpad.core.dao.Course>
             <title>Spring</title>
             <instructor>Ben</instructor>
             <room>505</room>
             </com.cae.launchpad.core.dao.Course>
             </courses>
             <name>Pat</name>
            </com.cae.launchpad.core.dao.Student>
            
            Once in the cache: (notice the courses field is aspectized)
            <com.cae.launchpad.core.dao.Student>
             <school>ULLAVAL</school>
             <courses class="AOPClassProxy$0"/>
             <name>Pat</name>
            </com.cae.launchpad.core.dao.Student>
            
            ONce removed from the cache: (notice the courses field is still aspectized)
            <com.cae.launchpad.core.dao.Student>
             <school>ULLAVAL</school>
             <courses class="AOPClassProxy$0"/>
             <name>Pat</name>
            </com.cae.launchpad.core.dao.Student>


            • 3. Re: How do I serialized an POJO stored in the cache
              patlap

              Hi guys,

              I think my observation (XML representation of the POJO) might be too complicated. I just wanted to express the fact that removing the object from the cache does not give me back the original POJO like expected according to Ben.

              Is someone has some ideas???

              I am a bit surprise that not that many people seems to have this requirement!

              I am sort of counting on that !

              thanks

              • 4. Re: How do I serialized an POJO stored in the cache

                Sorry, I didn't see your post untill now. Yes, I have tried to reproduce your step. Obviously it is a bug in 1.4 release.

                Here is the Jira:
                http://jira.jboss.com/jira/browse/JBCACHE-847

                Current, 1.4.1 is in beta mode, so GA should come out in about 2 weeks timeframe. If you are in a hurry, you can also try to build the code after I do the fix (the next two days).

                • 5. Re: How do I serialized an POJO stored in the cache
                  patlap

                  I would suggest that if you could add a method that will allow me to get back the original pojo (copy of) without removing the POJO from the cache, it would be create!!!!!


                  Is this a possible ???

                  • 6. Re: How do I serialized an POJO stored in the cache

                    Do you want PojoCache to introduce the Cloneable interface such that you can clone the POJO?

                    But if removeObject can do the job, is there still a need to so?

                    • 7. Re: How do I serialized an POJO stored in the cache
                      patlap

                      The ability to clone the POJO and get the not aspectized copy of it would be ideal. In fact, when I want a copy, I don't necessarily want to remove it from the cache and I definitely don't want the aspectized version of it (since I should not be concerned about aspectization).

                      PS: Event though cloning the POJO will full fill my requirement, I still think that removing the POJO from the cache should give back the not aspectized version of the POJO so that I think it is still a bug that need to be addressed.



                      • 8. Re: How do I serialized an POJO stored in the cache

                        Well, actually, if you want to get aound it, you can implement Cloneable in your POJO and clone it yourself.

                        PS: yes, it is a bug that I will fix soon.

                        • 9. Re: How do I serialized an POJO stored in the cache

                          The fix is in 1.4.1CR1. Will come out soon.

                          • 10. Re: How do I serialized an POJO stored in the cache
                            esspe

                            Hi,

                            we are also having the serialization problem and unfortunately there is no rc for 1.4.1 by now. Is there a chance to get the fixed version soon ?