You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ted Husted <ne...@husted.com> on 2001/03/13 12:48:50 UTC

Re: Question about struts application model (DataSource, Business Logic beans)

> My problem is that
> access to the DataSource is through the servlet.findDataSource() call.

Struts stores the JDBC Connection pools as servlet context attributes
(in JSP terms, application-scope beans). You can also access them that
way. If you do not specify a name in the Struts-config file, it uses a
constant value. If you specify null to findDataSource(), it uses the
same constant. But you can also access the pools using your own labels
(or the Struts constant) without using the servlet method. 

> Carles Pi-Sunyer wrote:
> 
> Hi,
> 
> I'm using Struts for a new application that I'm developing. I have a
> question about the separation between the Action classes and the
> Business Logic beans.
> 
> My Business Logic beans are making database accesses to manipulate the
> underlying data model. I am planning on using the struts db connection
> pool, which is supplied through the DataSource. My problem is that
> access to the DataSource is through the servlet.findDataSource() call.
> How do I make the Business Logic beans unaware of the servlet/http
> layer (as suggested in the developers guide) while still making the
> DataSource available to the Business Logic beans? Do I have to pass a
> reference to the DataSource on every call the Business Logic beans
> (not an option that I like), or is there a cleaner way to do this? I
> also have a similar issues with logging services.
> 
> I believe that a common way to solve this problem is to bind the
> DataSource to a jndi service. I am using tomcat 3.2.1, and I don't
> believe that this functionality is supplied in either Tomcat or
> Struts.
> 
> Thank You,
> Carles