There are 2 files you need to modify to add a component: cocoon.xconf and user.roles.
Checkout cocoon.roles in the org.apache.cocoon source directory to see the format to
use for the user.roles files (goes in WEB-INF directory), as I think it doesn't exist
by default.
Hiloliddin Karimov <[EMAIL PROTECTED]> wrote:
>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(Excal
>iburComponentManager.java:246)
> at
>org.apache.cocoon.components.CocoonComponentManager.lookup(CocoonComponentMa
>nager.java:236)
> at
>org.apache.avalon.excalibur.component.DefaultComponentFactory$ComponentManag
>erProxy.lookup(DefaultComponentFactory.java:387)
> at
>org.apache.avalon.excalibur.component.ExcaliburComponentManager.lookup(Excal
>iburComponentManager.java:178)
> at
>org.apache.cocoon.components.CocoonComponentManager.lookup(CocoonComponentMa
>nager.java:236)
> at
>org.apache.avalon.excalibur.component.ExcaliburComponentManager.lookup(Excal
>iburComponentManager.java:178)
> at
>org.apache.cocoon.components.CocoonComponentManager.lookup(CocoonComponentMa
>nager.java:236)
> at
>org.apache.avalon.excalibur.component.DefaultComponentFactory$ComponentManag
>erProxy.lookup(DefaultComponentFactory.java:387)
> at
>org.apache.avalon.excalibur.component.DefaultComponentFactory$ComponentManag
>erProxy.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,
>
>Hill
>
__________________________________________________________________
The NEW Netscape 7.0 browser is now available. Upgrade now!
http://channels.netscape.com/ns/browsers/download.jsp
Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>