|
Hi All, I try to write Component that
returning MyConnection. So I have: package test.datasource; public interface DataSourceComponent
extends Component, Configurable, ThreadSafe { String ROLE = "test.datasource.DataSourceComponent"; MyConnection getConnection()
throws Exception; } public class MyDataSource extends AbstractLogEnabled implements
DataSourceComponent, Configurable, ThreadSafe, Disposable { public
MyDataSource() {} public
void configure( final Configuration configuration )
throws ConfigurationException { // configure } public
MyConnection getConnection()
throws Exception { return myconnection; } public
void dispose() { // dispose } } package test.acting; public class DatabaseSelectAction
extends AbstractDatabaseAction implements ThreadSafe { private
static final Map selectStatements = new HashMap(); public
Map act(Redirector redirector, SourceResolver
resolver, Map objectModel,
String source, Parameters param) throws Exception { DataSourceComponent datasource =
null; boolean reloadable
= Constants.DESCRIPTOR_RELOADABLE_DEFAULT; if (this.settings.containsKey("reloadable")) reloadable = Boolean.getBoolean((String)
this.settings.get("reloadable")); try {
Configuration conf =
this.getConfiguration(param.getParameter("descriptor",
(String) this.settings.get("descriptor")),
resolver,
param.getParameterAsBoolean("reloadable",reloadable));
datasource = this.getDataSource(conf);
System.out.println( "
Connection: " + datasource.getConnection()
);
return EMPTY_MAP; }
catch (Exception e) {
throw new ProcessingException(
e ); } } } public abstract class AbstractDatabaseAction
extends AbstractComplementaryConfigurableAction
implements Configurable, Disposable { protected
ComponentSelector dbselector; public
void compose(ComponentManager manager) { //throws ComponentException { try { this.dbselector = (ComponentSelector)
manager.lookup(DataSourceComponent.ROLE +
"Selector"); super.compose(manager); } catch (ComponentException e) { System.out.println("ERR: " + e);} } protected
final DataSourceComponent getDataSource(Configuration
conf) throws ComponentException { Configuration
dsn = conf.getChild("connection"); return (DataSourceComponent) this.dbselector.select(dsn.getValue("")); } ... When I test it, get error: WARN (2002-09-24)
14:23.59:343 [sitemap]
(/cocoon/test/) HttpProcessor[80][7]/ExcaliburComponentManager:
ComponentLocator exception from parent CM during
lookup. org.apache.avalon.framework.component.ComponentException: Could not find component at org.apache.avalon.excalibur.component.ExcaliburComponentManager.lookup(ExcaliburComponentManager.java:246) at org.apache.cocoon.components.CocoonComponentManager.lookup(CocoonComponentManager.java:236) at org.apache.avalon.excalibur.component.DefaultComponentFactory$ComponentManagerProxy.lookup(DefaultComponentFactory.java:387) at
org.apache.avalon.excalibur.component.ExcaliburComponentManager.lookup(ExcaliburComponentManager.java:178) at org.apache.cocoon.components.CocoonComponentManager.lookup(CocoonComponentManager.java:236) at
org.apache.avalon.excalibur.component.ExcaliburComponentManager.lookup(ExcaliburComponentManager.java:178) at org.apache.cocoon.components.CocoonComponentManager.lookup(CocoonComponentManager.java:236) at org.apache.avalon.excalibur.component.DefaultComponentFactory$ComponentManagerProxy.lookup(DefaultComponentFactory.java:387) at
org.apache.avalon.excalibur.component.DefaultComponentFactory$ComponentManagerProxy.lookup(DefaultComponentFactory.java:387) ... How I understood, I should
add my Component to manager, how can I do it? Any ideas, tips, or help
would be greatly appreciated, |
- RE: The DataSourceComponent which returning OtherConnec... Hiloliddin Karimov
- RE: The DataSourceComponent which returning OtherC... Alex Vishnev
- RE: The DataSourceComponent which returning OtherC... JohnsBrn
- RE: The DataSourceComponent which returning OtherC... Geoff Howard
- Re: The DataSourceComponent which returning Ot... Vadim Gritsenko
