Hi All,

I am a relative struts newbie, using the following: Struts 1.0.2, Sun 
JDK1.3.1, Tomcat3.3, MySQL, mm.mysql jdbc driver.

In my application, the only components that need JDBC are model 
components, which I am trying to keep decoupled from any one particular 
front-end for the sake of reusability.

I would like to use the connection pooling available in Struts by 
passing a javax.sql.DataSource into model-land at initialization time. 
Unfortunately I have not found a good way to do that.

I have tried the obvious method of writing a simple servlet (subclass of 
HttpServlet) and set it up in web.xml to load AFTER Struts ActionServlet 
when the webapp is started.  I hoped I could somehow get the DataSource 
via ActionServlet.findDataSource(), the only widely-documented way to 
get it.  I would then pass this DataSource to a configuration singleton 
class in model-land for use from there.

I was hoping that ActionServlet would leave a reference to itself in the 
ServletContext, but alas.  It appears that the only way to have access 
to the ActionServlet, and hence the DataSource, is to be an Action 
invoked by it.

Would the 'right way' be to subclass ActionServlet and initialize my 
model from init() after calling the superclass?  What it the right way 
to (generically) initialize model components with things like 
DataSource, log sink, parameters & resources from the struts / webapp 
framework?

--Jeff

P.S. as an OT aside, could anyone recomend a decent OSS java 
connection-pooling implementation?  (I have already ruled out PoolMan)


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to