[SOLVED] Serialization

From: Craig Miskell (cmiskel..lbatross.co.nz)
Date: Fri Sep 13 2002 - 00:18:40 EDT

  • Next message: Andrus: "[ANN] 1.0a3-1 released [Was: Nasty GUI bug in Alpha 3]"

    Hi all,
            First, my apologies for wasting bandwidth on something that I
    ended up solving myself. I should have tried longer at the start before
    bugging you guys.

    Right: I've sorted things out so that now DataContext can be serialized.
    It all got easy once I realised that it is *not* a good idea to serialize
    the DataDomain/DataNode.... etc structure along with the datacontext, and
    that the "name" of the datadomain is sufficient to restore the DataContext
    (it can get the domain from the shared config which will be correctly
    lazily initialized, depending on the state of the JavaVM when the given
    DataContext is deserialized). Phew. I have implemented
    readObject/writeObject on DataContext, and will be sending a patch through
    the devel list shortly (plus some other related mods).

    The *only* problem, and it's a minor thing, is that I now can't use
    ServletConfiguration. The session gets deserialized *before* any of the
    listeners get invoked (i.e. before ServletConfiguration.contextInitialized
    gets called). Thus, getSharedConfig() in the DataContext deserialisation
    ends up getting the default Configuration(), which can't find cayenne.xml,
    yadda yadda yadda.

    So, I just have to use the default Configuration, put the model .xml files
    on the normal class path, and make sure that cayenne.jar is in the
    WEB-INF/lib directory of my webapp rather than any shared location
    (otherwise the classpath, as far as Configuration is concerned, doesn't
    include WEB-INF/classes... took me a while to figure that one out :-))

    Again, sorry for wasted bandwidth, but I hope this helps somebody.
    Patches to follow on devel list shortly

    Craig Miskell
    Programmer, Black Albatross, Otago University, New Zealand
    -----BEGIN GEEK CODE BLOCK-----
    Version: 3.1
    GCS d- s+:- a-->? C++++(++)$ ULXH+++$>++++ P+>++++ L++$>++++$ E--- W+++$
    N+ K? w--- !O M-- V? PS--- PE Y t++ 5 X+++ R-- tv+ b+>+++ DI++++ D+ G+ e++
    h--- r+++ y+++
    ------END GEEK CODE BLOCK------



    This archive was generated by hypermail 2.0.0 : Fri Sep 13 2002 - 00:19:00 EDT