You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Stephen Winnall <st...@winnall.ch> on 2003/09/26 17:37:20 UTC

Database access using sitemap parameter

Hi

I am writing a generator which returns metadata from a database via JDBC.
I would like to retrieve the name of the database from the pool declared
in cocoon.xconf. The examples that I have seen show how to do this by
extending ComposerGenerator and setting the DataSource in the method
'compose'.

As I understand it, this means that the database name is effectively
hard-coded because 'compose' is only called when Cocoon is initialised.

I would like to be able to specify the name of the database as a sitemap
parameter or as a the src= parameter of the generator:

<map:generate type="DbSchemaGenerator" src="name-of-db-pool"/>

or

<map:generate type="DbSchemaGenerator" ...>
  <parameter name="db" value="name-of-db-pool"/>

As I understand it, I cannot read the <parameter>s in until 'setup' is
called. This means that I need to create the DataSource in 'setup' or in
'generate'. My attempts to do this have failed so far.

Is there a trick involved or can someone point me at some documentation
which explains how to do this?

Regards
Steve

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


Re: Database access using sitemap parameter

Posted by Christian Haul <ha...@dvs1.informatik.tu-darmstadt.de>.
On 26.Sep.2003 -- 05:37 PM, Stephen Winnall wrote:
> Hi
> 
> I am writing a generator which returns metadata from a database via JDBC.
> I would like to retrieve the name of the database from the pool declared
> in cocoon.xconf. The examples that I have seen show how to do this by
> extending ComposerGenerator and setting the DataSource in the method
> 'compose'.
> 
> As I understand it, this means that the database name is effectively
> hard-coded because 'compose' is only called when Cocoon is initialised.

AFAIK the contract is that you don't access other components earlier
than compose() in the Avalon lifecycle. If you have a reference to the
component manager through compose(), you can use it later to lookup
any datasource / selector later on. E.g. the database actions do that.

	Chris.
-- 
C h r i s t i a n       H a u l
haul@informatik.tu-darmstadt.de
    fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

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