Hi,

I'm trying something here and I would like to see from you if this is adequate.  In 
some of my logicsheets I'm using a helper class to get attributes from a database, 
instead of using, eg, ESQL.  So for example:

Suppose I have a table CAR, with a column COLOR, indexed by key KEY.  And I have a 
logicsheet like this (I've simplified/cleared the code a bit, nevermind syntax 
problems)

<xsl:template match="car:get-color"> 
<!-- return the color of the car $key -->

<xsp:expr>

  ObjectHelper.getStringAttribute ("CAR", "COLOR", 
         <xsl:copy-of select="$key"/>, 
         new DataSourceHelper(manager))

</xsp:expr>

</xsl:template>

That is, getStringAttribute is a static (synchronized) method that receives a database 
connection and DTRT.  

Notice the "new DataSourceHelper (manager)"

I have also what I call a "DataSourceHelper", that does something like this:

this.manager = manager;
dbselector = (ComponentSelector) 
      manager.lookup(DataSourceComponent.ROLE + "Selector");
datasource = (DataSourceComponent) dbselector.select("database");

Inside "getStringAttribute" I do a "getConnection" and DataSourceHelper gets me a 
(new?) connection from the datasource pool.  When I'm done, I close everything (the 
connection including) and call a method on DataSourceHelper that does this:

this.dbselector.release (this.datasource);
this.datasource = null;
manager.release (this.dbselector);

None of those classes are remotely related to any kind of Avalon component.  They deal 
with them through the manager available "magically" on the logicsheet.  

My question is if there is a way of doing this in a more integrated way to 
Cocoon/Avalon's components, so I know that I'm using all the pools efficiently and I'm 
not leaking any memory (and I'm not prone to deadlocks either).

I hope I posted the relevant parts of my code.

Thanks,
Fabricio

---------------------------------------------------------------------
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]>

Reply via email to