cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Horner <>
Subject Re: Getting database in my custom objects
Date Sat, 10 Jan 2004 19:46:38 GMT


> My Cocoon project uses JavaBeans objects that act as business model e.g.
> User, Article, Comment, etc. Every object has "data access object" that
> handles database operations. Now i need to pass database connection to
> these objects but I don't know how.

My application appears to be very similar. I have a User and a UserDAO, etc.

> I'm using Cocoon's flow and know that I can get database connection in flow
> script but this didn't help me very much, because I would have to pass
> connection to my beans in every function. The ideal would be that my
> "database access" objects pulled the db connection from Cocoon. How to do
> it?

I'm not sure I totally follow but I'll give it a shot in hopes that it might 
help or even possibly get comments on how I could do it better. This is a bit 
watered down... I have a DaoContainer which gets set up in a 
ServletContextListener where the ServletContextListener reads some database 
properties from a file. The ServletContextListener binds the DaoContainer in 
JNDI. So when I need a, for example, UserDAO, I first get the DaoContainer 
from JNDI. The watered down part is how a DaoContainer creates a UserDAO but 
all DAOs are based on an AbstractDAO and since a DaoContainer (watered down) 
creates all DAO, the DAO already has a database connection. 

There is which I tried but could not get to 
work. This is how and why I ended up with what I coded, well at least the 
class names and their concepts. I think the maintainer fixed the problems I 
was having.

I created a DaoTransformer so I could keep tansactions, etc out of the 
flowscript but today it is beginning to look I won't be able to do that 
forever. And I guess I am procrastinating ...


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message