cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bertrand Delacretaz <>
Subject Re: generator type value substitution (GroovySQL vaporware strikes again)
Date Thu, 29 Apr 2004 21:47:51 GMT
Le 29 avr. 04, à 20:41, Leszek Gawron a écrit :
> ...I am more than willing to help. What should I do ?

See this thread
for some discussion and ideas about this.

I think the following steps would be enough to allow the 
GroovySQL/GroovyMarkup stuff to be usable:

-update the groovy lib to the latest one in the BSF block
-provide a way for Groovy scripts (running in the BSF block's 
ScriptGenerator) to receive a Connection or Datasource from the Cocoon 
connection pools
-in the groovy script, create an SQL object which uses this connection

It might need to be optimized later on (precompilation, dedicated 
Groovy block instead of BSF, etc) but that would be a good start!

Ideally, any connections used in the groovy script should be released 
by the ScriptGenerator/ConnectionProvider, to keep the scripts as 
simple and safe as possible.

For now, there is an example using groovy markup in the BSF block 
samples (src/blocks/bsf/samples/generator/

Off the top of my head, a generator script using GroovySQL and 
GroovyMarkup could look like:

import groovy.xml.SAXBuilder
import groovy.sql.Sql

contentHandler = bsf.lookupBean("contentHandler")
xml = new SAXBuilder(contentHandler)

connectionProvider = bsf.lookupBean("connectionProvider")
sql = new Sql(connectionProvider.getConnection("myconnection"))  // 
didn't check syntax here


sql.queryEach ("select * from person") { person |
     xml.customer(, type:'Customer', name:person.firstname + 
" " + person.lastname)


Hope this helps!

View raw message