Return-Path: Delivered-To: apmail-xml-cocoon-users-archive@xml.apache.org Received: (qmail 1113 invoked by uid 500); 25 Sep 2002 16:55:08 -0000 Mailing-List: contact cocoon-users-help@xml.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: cocoon-users@xml.apache.org Delivered-To: mailing list cocoon-users@xml.apache.org Received: (qmail 840 invoked from network); 25 Sep 2002 16:55:06 -0000 Date: Wed, 25 Sep 2002 08:46:18 -0400 From: Alex Vishnev Subject: RE: The DataSourceComponent which returning OtherConnection In-reply-to: To: cocoon-users@xml.apache.org Message-id: MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) Content-type: multipart/alternative; boundary="Boundary_(ID_OFPXhbDivLTbnkSCS4z4rg)" Importance: Normal X-Priority: 3 (Normal) X-MSMail-priority: Normal X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N --Boundary_(ID_OFPXhbDivLTbnkSCS4z4rg) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7BIT sam did not copy me on the solution, can you forward me his answer? -----Original Message----- From: Hiloliddin Karimov [mailto:HKarimov@central.nbu.com] Sent: Tuesday, September 24, 2002 7:17 AM To: Cocoon-Users Subject: The DataSourceComponent which returning OtherConnection 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 --Boundary_(ID_OFPXhbDivLTbnkSCS4z4rg) Content-type: text/html; charset=iso-8859-1 Content-transfer-encoding: 7BIT
sam did not copy me on the solution, can you forward me his answer?
-----Original Message-----
From: Hiloliddin Karimov [mailto:HKarimov@central.nbu.com]
Sent: Tuesday, September 24, 2002 7:17 AM
To: Cocoon-Users
Subject: The DataSourceComponent which returning OtherConnection

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,

 

Hill

--Boundary_(ID_OFPXhbDivLTbnkSCS4z4rg)--