avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Berin Loritsch <blorit...@apache.org>
Subject Re: One component, multiple configurations ...
Date Mon, 07 Jan 2002 14:23:00 GMT
Peter Donald wrote:

> On Fri, 4 Jan 2002 15:19, Taglang, Guillaume wrote:
> 
>>Hi list,
>>
> 
> Hi there,
> 
> 
>>I've started to play around with Avalon, Phoenix and the other goodies. I
>>arrived to a point where I'm not able to find in the documentation what I'm
>>searching, so I have a small question:
>>
>>I have a generic component X which can have different behaviour for the
>>same ROLE depending on the configuration. I want to run different instances
>>of this component with different configurations. How could I achieve this ?
>>



Use the ComponentSelector approach.  Cocoon demonstrates this with the DataSource
selection.  You can have multiple DataSourceConnections associated with one webapp:

<datasources>
   <jdbc name="foo"/>
   <jdbc name="bar"/>
</datasources>

Each instance has a different configuration depending on what you are using.  You
use the API like this:

ComponentSelector selector = (ComponentSelector) manager.lookup(DataSourceComponent.ROLE +
"Selector");
DataSourceComponent component = (DataSourceComponent) selector.select("bar");

// ..... use it

selector.release(component);
manager.release(selector);


> 
> Depends on what container you are working with. In most of the containers you 
> can create multiple instances of the same type of component but with 
> different names (and configurations). As they are the same type they 
> implement the same interface (and thus have same Role) but the way they 
> implement depends on whioch one you are working with.
> 
> 
> Alternatively you could create multiple different components that all 
> implement the same interface (and thus have same Role) but are different 
> actualt types. It really depends on how different the implementations are.
> 
> Does this make sense ?
> 
> 



-- 

"They that give up essential liberty to obtain a little temporary safety
  deserve neither liberty nor safety."
                 - Benjamin Franklin


--
To unsubscribe, e-mail:   <mailto:avalon-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-dev-help@jakarta.apache.org>


Mime
View raw message