Re: Aggregated cayenne.xml from several modules (projects)

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Thu Oct 22 2009 - 04:44:07 EDT

  • Next message: Andrey Razumovsky: "Re: release countdown"

    I was working on this exact problem, but due to the lack of time and
    some other priorities it got postponed till after 3.0. This Jira
    contains links to the design that I had in mind:

    https://issues.apache.org/jira/browse/CAY-943

    For 3.1 I actually have more radical ideas, so it may look different
    at the end. Anyways, all the complexity of this task is due to the
    need to handle a general case of merging multiple descriptors and
    resolve arising conflicts. If you know that your configuration does
    not have any such conflicts, it should be reasonably simple to merge
    things by hand. Here is a rough example (this is for 3.0, some things
    may be different in 2.0):

    Configuration myConfig = new Configuration() {
        // override all abstract methods to do nothing
    }

    ClassLoader cl = .. // get a thread class loader

    // assuming all Cayenne projects are at the root of the classpath:
    Enumeration<URL> projectURLs = cl.indResources("cayenne.xml");
    while(projectURLs.hasMoreElements()) {
        URL baseURL = projectURLs.nextElement();

        ResourceLocator resourceLocator = new ResourceLocator() {
             // override locator methods as appropriate... e.g.:
             public URL getResource(String name) {
               if(name.equals("cayenne.xml") {
                 return baseURL;
               }

               // assuming there's no conflciting DataMap names
               return super.getResource(name);
              }

        } ;
        Configuration scratchConfig = new
    DefaultConfiguration("cayenne.xml", resourceLocator);

        // move all DataMaps from scratchConfig to myConfig
        // move all DataNodes from scratchConfig to myConfig
    }

    Configuration.initializeSharedConfiguration(myConfig);

    Andrus

    On Oct 21, 2009, at 7:12 PM, Evgeny Ryabitskiy wrote:

    > Hello to everyone!
    >
    > I wonder if our cayenne is able to aggregate it's configuration from
    > several projects?
    >
    > Like in my case I have several modules, each has it's configuration
    > like module1-cayenne.xml
    > So now root project need to get aggregated configuration from all
    > modules.
    >
    > So I'm trying to use DefaultConfiguration for each module.
    > The problem that after initialization configuration rewrites previous
    > and become singleton configuration (I need them all!)
    >
    > Maybe I do something wrong or there no such feature?
    >
    > Evgeny Ryabitskiy.
    >



    This archive was generated by hypermail 2.0.0 : Thu Oct 22 2009 - 04:44:40 EDT