Re: Code Generation

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Mon Dec 13 2004 - 00:06:42 EST

  • Next message: Kevin J. Menard, Jr.: "Re: Code Generation"

    On Dec 12, 2004, at 9:22 PM, Kevin Menard wrote:
    > Now, I have a question about the code generation stuff. I've been
    > playing with the superclass template, and it'll set up an
    > encodeAsXML() that works pretty.

    Hmm, I thought you were planning a dynamic encoder/decoder for
    DataObjects based on Cayenne mapping? I guess adding this as a
    generated code has its benefits (i.e. no need for a DataContext). But a
    DataContext (or maybe EntityResolver which is probably a cleaner
    solution) can be passed around in encoder/decoder (or in a subclass of
    coder)... So any other reason we might need a generated method instead
    of a generic one in CayenneDataObject?

    > The problem is that I need to know the package of the subclass
    > created, and before I go modifying
    > org.objectstyle.cayenne.gen.ClassGenerator, I figured I'd ask if it
    > was already available somehow.

    Full name of the lowest subclass is available as
    ClassGenerator.getEntity().getClassName(). Is this what you are looking
    for?

    > In particular, in setRoot(), I'm feeding in a class name for the XML
    > encoding, which is needed for decoding. Generally speaking though,
    > people work with their subclass. As such, two problems are at hand.
    > I'd like to auto-create the decode code (which is being done in a
    > constructor that takes a single arg of type XMLDecoder), but then the
    > subclass needs to provide a new constructor that just calls super(),
    > which seems like a waste. But putting the auto-generated code in the
    > subclass is a no go too.

    How about a two-step decoding? A noarg constructor, and then calling a
    decodeFromXML(..)?

    Andrus



    This archive was generated by hypermail 2.0.0 : Mon Dec 13 2004 - 00:06:47 EST