Martin:

What you're describing appears to the ECM container.  This is now
handled by the Excalibur project.

http://excalibur.apache.org

Cheers, Steve.


> -----Original Message-----
> From: MArtin Schumacher [mailto:[EMAIL PROTECTED]
> Sent: 27 August 2004 10:18
> To: [EMAIL PROTECTED]
> Subject: Excalibur Component Lookup
> 
> Hi everyone,
> 
> I hope someon can help me in here.
> We are using a pretty old part of avalon: an about 2 years old version
> of the excalibur-project. We just use the component lookup to have a
> loose coupling. This wors pretty fine the last years.
> 
> But now we want to make it possible that one component can choose the
> other component with hints. But we got the following Exception and
have
> no idea what to do now...
> 
> The Exception:
> ------ 8< ------ 8< ------ 8< ------ 8< ------ 8< ------ 8< ------
> org.apache.avalon.framework.component.ComponentException:
> UnnamedSelector: ComponentSelector could not find the component for
> hint: entega
> ------ 8< ------ 8< ------ 8< ------ 8< ------ 8< ------ 8< ------
> 
> The roles-definition:
> ------ 8< ------ 8< ------ 8< ------ 8< ------ 8< ------ 8< ------
> <role name="mypackage.MyStrategySubServiceInterfaceSelector"
>        shorthand="myStrategySubService"
> default-
>
class="org.apache.avalon.excalibur.component.ExcaliburComponentSelector"
>
>    <hint shorthand="entega"
>          class="mypackage.EntegaSubServiceImpl"/>
>    <hint shorthand="entegaTest"
>          class="mypackage.EntegaTestSubServiceImpl"/>
> </role>
> ------ 8< ------ 8< ------ 8< ------ 8< ------ 8< ------ 8< ------
> 
> The usage:
> ------ 8< ------ 8< ------ 8< ------ 8< ------ 8< ------ 8< ------
> cs = (ComponentSelector)
>             cm.lookup(MyStrategySubServiceInterface.ROLE+"Selector");
> 
> strategy = (MyStrategySubServiceInterface) cs.select("entega");
> strategy.doIt();
> cs.release(strategy);
> ------ 8< ------ 8< ------ 8< ------ 8< ------ 8< ------ 8< ------
> 
> The ComponentManager initialization:
> ------ 8< ------ 8< ------ 8< ------ 8< ------ 8< ------ 8< ------
> this.componentManager = new ExcaliburComponentManager();
> SAXParserFactory factory = SAXParserFactory.newInstance();
> XMLReader reader = factory.newSAXParser().getXMLReader();
> 
> this.loggeravalon =
>
Hierarchy.getDefaultHierarchy().getLoggerFor("main");
> this.componentManager.setLogger(this.loggeravalon);
> 
> // now configure it...
> Configuration roleConfig = null;
> 
> SAXConfigurationHandler b = new SAXConfigurationHandler();
> InputStream inputStream = this.getClass().getClassLoader().
>                               getResourceAsStream(this.rolesfilename);
> 
> InputSource is = new InputSource(inputStream);
> 
> reader.setContentHandler(b);
> reader.parse(is);
> 
> roleConfig = b.getConfiguration();
> 
> DefaultRoleManager drm = new DefaultRoleManager();
> drm.setLogger(this.loggeravalon);
> drm.configure(roleConfig);
> roleConfig = null;
> 
> this.componentManager.setRoleManager(drm);
> 
> Configuration conf = null;
> try {
>    b = new SAXConfigurationHandler();
>    inputStream = this.getClass().getClassLoader().
>                        getResourceAsStream("application/config.xml");
>    is = new InputSource(inputStream);
> 
>    reader.setContentHandler(b);
>    reader.parse(is);
> 
>    conf = b.getConfiguration();
>    this.componentManager.configure(conf);
> } catch (java.net.MalformedURLException malex) {
> logger.info("cannot load confix.xml. proceeding without...");
>                               }
> // and finished
> this.componentManager.initialize();
> ------ 8< ------ 8< ------ 8< ------ 8< ------ 8< ------ 8< ------
> 
> Really hope, that someone can help me!
> 
> MArtin
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to