cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: Best practices question
Date Thu, 04 Oct 2007 16:33:16 GMT
Been meaning to implement a runtime "multiple configs merge"  
algorithm in Cayenne for some time. I think there may even be a Jira  
for that somewhere. Conceptually this is a valuable addition as it  
allows seamless modular packaging.

As for the workaround that does not involve manual merging, I usually  
create a separate mapping project with a single cayenne.xml that can  
be imported in multiple applications. Inside that project I separate  
logical "packages" by placing them in separate DataMaps.

Andrus


On Oct 4, 2007, at 6:24 PM, Eric BIANCHI wrote:

> Hello Chris,
>
> We have the same configuration here.
>
> We put cayenne.xml in our/class/path/ in Package B.
>
> From Package A, we load package B's cayenne.xml :
>
> DefaultConfiguration conf = new DefaultConfiguration();
> conf.addClassPath("our/class/path");
> Configuration.initializeSharedConfiguration(conf);
>
> Then we load package A's cayenne.xml
>
> DefaultConfiguration conf2 = new DefaultConfiguration();
>
> And finally we merge the two datamaps :
>
> try {
> 	conf2.initialize();
> 	Configuration.getSharedConfiguration().getDomain().addMap 
> ((DataMap) conf2.getDomain().getDataMaps().iterator().next());
> 	Configuration.getSharedConfiguration().getDomain().addNode 
> ((DataNode) conf2.getDomain().getDataNodes().iterator().next());
> } catch (Exception e) {
> 	//beuh...
> }
> 	
> I hope it helps !!
>
> Best Regards
>
> Eric
>
> Le 4 oct. 07 à 16:16, Chris Gamache a écrit :
>
>> Here's the scenario...
>>
>> Project A uses cayenne
>> Project B also uses cayenne
>>
>> They both have a cayenne.xml and nodes and domains, etc.
>>
>> Package A uses package B. I'm finding that when package A first
>> initializes cayenne, subsequent initializations when classes from
>> package B are instantiated ignore the cayenne.xml file from package B
>> and it's underlying maps,nodes,domains, etc. causing some chaos. I  
>> bet
>> this is the expected behavior. I could merge and copy the cayenne.xml
>> files so that all packages use the same file. I bet there's a better
>> way, though. Perhaps even the /best/ (tm) way...
>>
>> Please advise!
>>
>> CG
>>
>
> --
> Eric BIANCHI
> ---------------------------------------
> eric.bianchi@rodanotech.ch         +41 (0)774 10 80 36
> http://www.rodanotech.ch           Skype: erbianchi
>
>
>
>


Mime
View raw message