Torsten Curdt wrote:
> I have a question on the (current;) ComponenManager.
> Right now I have a Component in our project which
> can simply looked up by "cm.lookup(role)" but now
> I'm about to need another Component for the same
> role. So usually I would use a ComponentSelector
> for this. But what happens with the current code
> where I only do a lookup(role). Do I have to go
> threw the code and change this to use the
> ComponentSelector, too?
I'm sure others will correct me if I'm wrong, but I think it depends on how you
define your roles. If you currently had:
<role name="org.apache.avalon.excalibur.datasource.DataSourceComponent"
shorthand="datasource"
default-class="org.apache.avalon.excalibur.component.JdbcDataSource"/>
And you replaced it with;
<role name="org.apache.avalon.excalibur.datasource.DataSourceComponentSelector"
shorthand="datasources"
default-class="org.apache.avalon.excalibur.component.ExcaliburComponentSelector">
<hint shorthand="jdbc"
class="org.apache.avalon.excalibur.datasource.JdbcDataSource"/>
<hint shorthand="j2ee"
class="org.apache.avalon.excalibur.datasource.J2eeDataSource"/>
</role>
You'll have to lookup the ComponentSelector before getting the actual
Component. However, if you have both entries, then you wouldn't have to change
any existing code, because the ComponentManager would still be able to find
your Component under it's original role. The bad thing is that you'd only have
access to one type of DataSourceComponent if you don't go through the
ComponentSelector.
-Mark