Re: POJO question

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Thu Mar 10 2005 - 23:59:17 EST

  • Next message: Jürgen Saar: "optional 1:1 relation, how to?"

    On Mar 10, 2005, at 11:15 AM, Michael Engelhart wrote:

    > Hi Andrus,
    >
    > Thanks for the quick response. As I mentioned I'm not really
    > familiar with serialization code but that being said I'd be more then
    > happy to look into writing something like this if someone could point
    > me in the right direction. Is there anything similar going on in the
    > current codebase that could be used as a sample of what needs to be
    > done to accomplish this?

    The only place in the current codebase that is somewhat related is
    read/writeObject methods on CayenneDataObject and DataContext. And this
    is something that we need to change... I've mentioned the need for
    Externalizable interface outside of CayenneDataObject that overrides
    default policy (as you can't redefine private read/writeObject in
    subclasses, only add to it, if I understand default Java serialization
    behavior correctly). But I am also open to suggestions to modify
    CayenneDataObject itself. E.g. rely on some sort of thread-bound
    serializer ...

    Anyway, from the high level the idea is to have a serializer class that
    would implement a number of convenience serialization methods to get
    controllable chunks of the object graph. E.g.:

    /**
      * Serializes root objects in the collection and all related objects
    specified by relationship keys.
      * Possible side effect is inflating related objects if they are not
    resolved.
      */
    void writeGraph(Collection rootObjects, Collection relationshipKeys);

    /**
      * Serializes root objects and all related objects that are not faults.
      */
    void writeResolved(Collection rootObjects);

    On deserialization end no special handling should be needed.
    DataObjects should be smart enough to realize that there is no Cayenne
    stack around.. I was thinking of implementing a dummy DataContext
    subclass that throws exceptions on any attempts to access Cayenne, and
    use a singleton instance of this subclass as "dataContext" property of
    all deserialized objects.

    This is maybe too convoluted, as I haven't tried it out. I'll do it
    eventually, but you are very welcome to jump on it yourself. In the
    later case I suggest opening a new issue in our Jira bugtracker, so
    that interested parties can collaborate, submit code and follow the
    progress.

    Andrus



    This archive was generated by hypermail 2.0.0 : Thu Mar 10 2005 - 23:59:21 EST