Re: Dynamic Data Maps

From: Jonathan Carlson (Jonathan.Carlso..atun.com)
Date: Tue Jan 17 2006 - 19:00:01 EST

  • Next message: emre.yilma..r.net: "Re:Re: Performance question"

    Thanks Andrus for this code. I've been playing with it and I really
    like it.

    Notice the simplistic persistence framework in this new RAD web
    development environment:

    https://slingshot.dev.java.net/

    Given your DbLoader, I know that Cayenne can be as easy as that while
    still providing the high-end features for those who decide they want
    them. Cayenne should make it easy for projects like this to use Cayenne
    instead of building their own that will never be as good. I started
    looking through the Cayenne source to see if I could create a
    DynamicConfiguration subclass that takes a DataSource and a schema name.
     It seemed to get a little messy, especially as I noticed that
    BasicServletConfiguration, one of my examples, is now deprecated in 1.2.
     Assuming others think this is a worthwhile thing to do, is there any
    interest in someone (more knowledgable than I) creating a
    DynamicConfiguration subclass like this that would fit logically with
    the rest of the Configurators? (I'm pretty short on free time)

    Having listened in on the Groovy mailing list for a while and having
    watched the growing interest in Ruby on Rails, it is obvious to me that
    there is a growing interest in "convention over configuration".

    Many RAD tools, like the one above, are using Groovy to speed up the
    development time. The one critical missing piece that I didn't mention
    before is that Groovy could relatively easily make a CayenneDataObject
    look like a regular Groovy Bean (just subclass CayenneDataObject with a
    class that implements GroovyObject).

    I really believe that an easy-to-use DynamicConfiguration and a
    GroovyCayenneDataObject would have a lot of general interest in the
    Groovy/RAD development crowd. I don't think any other ORM tool can do
    this as cleanly as Cayenne can. If we get an easy-to-use
    DynamicConfiguration class written, I bet I/we could convince someone on
    the Groovy mailing list to write the GroovyCayenneDataObject (or at
    least help me do it :-)

    My 2 cents,

    Jonathan Carlson

    >>> andru..bjectstyle.org 2006-01-05 2:28:21 AM >>>

    On Jan 4, 2006, at 6:24 PM, Jonathan Carlson wrote:
    > I see how DbLoader will create a DataMap, but I don't see how I can
    > create a DataContext from a DataMap without using configuration
    files.

    ...

    > I noticed Configuration.getSharedConfiguration(), but that seems to
    > assume the use of configuration files.

    Assembling Cayenne stack via API is totally possible and you may
    still optionally use Configuration when doing that. This will allow
    to preserve DataContext creation procedure. But the main two classes
    in the stack you care about is DataNode and DataDomain. Here is how
    such procedure might look like:

    // create DataSource (from the connection data that users enter via
    UI?)
    DataSource ds = new org.objectstyle.cayenne.conn.PoolManager(...);

    // get DataMap via DbLoader
    DataMap map = ...;

    // assemble stack

    DataNode node = new DataNode("MyNode");
    node.setAdapter(new AutoAdapter(ds));
    node.setDataSource(ds);
    node.addDataMap(map);

    DataDomain domain = new DataDomain("MyDomain");
    domain.addNode(node);

    // you can use the domain above directly to create DataContexts,
    // if so you can ignore the code below.

    // Alternatively you can stick the domain in a shared
    // configuration for the static DataContext factory methods benefit.

    Configuration c = new DefaultConfiguration() {
        public void initialize() {
           // make noop to prevent config file loading
        }
    };

    c.addDomain(domain);
    Configuration.initializeSharedConfiguration(c);

    > I think there could be a whole new
    > class of Cayenne users if this were an easy thing to do (unless I
    just
    > missed how easy it is already!). If I can get this working nicely,

    > I'm
    > going to share this method of using Cayenne on the Groovy mailing
    list
    > (unless you don't want me to :-).

    If you have a way of bringing a whole new class of users to Cayenne,
    by all means do it :-)

    Andrus

    ______________________________________________________________________
    This email has been scanned by the MessageLabs Email Security System.
    For more information please visit http://www.messagelabs.com/email
    ______________________________________________________________________

    ______________________________________________________________________
    This email and any files transmitted with it are confidential and
    intended solely for the use of the individual or entity to whom they
    are addressed. If you have received this email in error please notify
    the system manager.

    Katun Corporation -- www.katun.com
    _____________________________________________________________________



    This archive was generated by hypermail 2.0.0 : Tue Jan 17 2006 - 19:00:40 EST