cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Berin Loritsch <blorit...@apache.org>
Subject Re: XMLFragments, esql
Date Wed, 09 May 2001 19:18:21 GMT
Pablo Bendersky wrote:
> 
> Hi,
> I've seen it, but I'm new to Java and I find it a little bit hard to
> understand.
> I've also looked at the esql generated file, without success.
> 
> I'm confused with all the classes it extends.
> Does anyone has a simpler example ?

Crash Course in Avalon Components (Cocoon is based on Avalon):

In order for a class to be considered a Component, it needs to
extend the Component interface.  At that point it is able to be
managed by the ComponentManager.

In order for a Component to get a reference to the ComponentManager,
it needs to implement the Composable interface.  It is passed the
ComponentManager once, and only once.

In order for a Component to get a reference to a Logger, it must
implement the Loggable interface or extend the AbstractLoggable
class.  It is passed the Logger before anything else.

In order for a Component to get a Configuration object, it must
implement the Configurable interface.  The configure() method is
only called once.  This is usually where you will specify your
database connections, etc.

Now, in order to get at a pooled datasource in Cocoon, you have
to implement code that is roughly like the following:

ComponentSelector dbSelector = (ComponentSelector) manager.lookup(Roles.DB_CONNECTIONS);
DataSourceComponent datasource = (DataSourceComponent) dbSelector.select(dbName);
Connection connection = datasource.getConnection();


"manager" refers to the ComponentManager your Component received when initialized.
"dbName" refers to the hint specified in cocoon.xconf.

> 
> Thanks
> 
> -----Mensaje original-----
> De: Donald Ball [mailto:balld@webslingerZ.com]
> Enviado el: Miercoles, 09 de Mayo de 2001 01:36 p.m.
> Para: cocoon-users@xml.apache.org
> Asunto: Re: XMLFragments, esql
> 
> On Wed, 9 May 2001, Pablo Bendersky wrote:
> 
> > Hello,
> > I'm having a little problem.
> > I'd like to make some selects from a database, which should look like:
> > dep1  emp1
> >       emp2
> > dep2  emp3
> >       emp4
> >
> > and so on. I know esql provides me nested queries, and I find them very
> > useful. Anyway, in this case the sql statement is a little complex, so we
> > have defined a view in the database. I still know I can split the view and
> > work with nested queries, but as I also want to learn a little, I wanted
> to
> > make an XMLFragment which can make the query (Based on an id) and return
> the
> > XML as I want.
> > My question now is:
> > How can I access (Which class, some example, maybe) the database in the
> same
> > way esql does. I mean, I still want to use the same database pool esql
> uses,
> > and the same connection parameters defined no the cocoon.xconf file.
> 
> see the DatabaseAction examples - they use the same connection pooling.
> 
> - donald
> 
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
> 
> To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
> For additional commands, e-mail: <cocoon-users-help@xml.apache.org>
> 
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
> 
> To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
> For additional commands, e-mail: <cocoon-users-help@xml.apache.org>

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>


Mime
View raw message