You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cayenne.apache.org by Evgeny Ryabitskiy <ev...@gmail.com> on 2009/12/15 11:56:51 UTC

Dynamic (runtime) adding of DataNodes.

As Andrus asked, I am starting this question in new thread.

Every our library(module) has set of DomainMaps (we can't use only one
DomainMap because our modules are really big).
So each Module has it's "module1-cayenne.xml" that has set of DomainMaps.

Idea is to use this configuration without DomainNodes that are
strongly set in "module1-cayenne.xml" and declare only DomainMaps.

Then create some ... fore example web service, add few
modules/libraries to dependency ...
Create only one DomainNode (in runtime) then load all DataMaps from
"module1-cayenne.xml" ,  "module2-cayenne.xml" , .. etc and bind (add
ref) all this maps to DomainNode of web service.

So question is... if I could create DomainNode at runtime and bind
DataMaps to it?

Evgeny.

RE: Dynamic (runtime) adding of DataNodes.

Posted by Рябицкий Евгений <er...@diasoft.ru>.
Great! Thx.

Evgeny.

-----Original Message-----
From: Andrus Adamchik [mailto:andrus@objectstyle.org] 
Sent: Tuesday, December 15, 2009 3:22 PM
To: dev@cayenne.apache.org
Subject: Re: Dynamic (runtime) adding of DataNodes.

The answer is yes. Any part of Cayenne stack can be created via API in  
runtime, including DataNodes.

DataNode node = new DataNode("mynode");
for(DataMap map : domain.getDataMaps()) {
    node.addDataMap(map);
}

node.setAdapter(...);
node.setDataSource(...);

domain.addNode(node);

Andrus

On Dec 15, 2009, at 5:56 AM, Evgeny Ryabitskiy wrote:

> As Andrus asked, I am starting this question in new thread.
>
> Every our library(module) has set of DomainMaps (we can't use only one
> DomainMap because our modules are really big).
> So each Module has it's "module1-cayenne.xml" that has set of  
> DomainMaps.
>
> Idea is to use this configuration without DomainNodes that are
> strongly set in "module1-cayenne.xml" and declare only DomainMaps.
>
> Then create some ... fore example web service, add few
> modules/libraries to dependency ...
> Create only one DomainNode (in runtime) then load all DataMaps from
> "module1-cayenne.xml" ,  "module2-cayenne.xml" , .. etc and bind (add
> ref) all this maps to DomainNode of web service.
>
> So question is... if I could create DomainNode at runtime and bind
> DataMaps to it?
>
> Evgeny.
>


Re: Dynamic (runtime) adding of DataNodes.

Posted by Andrus Adamchik <an...@objectstyle.org>.
The answer is yes. Any part of Cayenne stack can be created via API in  
runtime, including DataNodes.

DataNode node = new DataNode("mynode");
for(DataMap map : domain.getDataMaps()) {
    node.addDataMap(map);
}

node.setAdapter(...);
node.setDataSource(...);

domain.addNode(node);

Andrus

On Dec 15, 2009, at 5:56 AM, Evgeny Ryabitskiy wrote:

> As Andrus asked, I am starting this question in new thread.
>
> Every our library(module) has set of DomainMaps (we can't use only one
> DomainMap because our modules are really big).
> So each Module has it's "module1-cayenne.xml" that has set of  
> DomainMaps.
>
> Idea is to use this configuration without DomainNodes that are
> strongly set in "module1-cayenne.xml" and declare only DomainMaps.
>
> Then create some ... fore example web service, add few
> modules/libraries to dependency ...
> Create only one DomainNode (in runtime) then load all DataMaps from
> "module1-cayenne.xml" ,  "module2-cayenne.xml" , .. etc and bind (add
> ref) all this maps to DomainNode of web service.
>
> So question is... if I could create DomainNode at runtime and bind
> DataMaps to it?
>
> Evgeny.
>