Design and Datasource question

2003-02-05 Thread Tolle Krez
I am a newbie to struts and started with the struts-example application.  And modified 
it
a bit and learning.. . It looks like there are no separate model classes and all 
business
logic exists in the Action classes itself. I am thinking of separate them. The 
Datasource
settings are in my struts-config file and they are obtained in the Action class using
servlet.getServletContext().getAttribute(Action.DATA_SOURCE_KEY)) .

My question is, if I separate the business logic and database access away from Action
classes, how to I do get access to the datasource and connection pool.

PS: I am not using EJB and only plain java classes to access the database and for
business logics.

Any help is appreciated

T



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




Re: Design and Datasource question

2003-02-05 Thread Vic Cekvenich
Some people get a connection in Action, and pass it in many ways to DAO.

I get a connection in DAO (via DBCP). Ex:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/basicportal/basicportal/src/basicWebLib/org/apache/basicWebLib/DAO/BasicDAOImpl.java?rev=1.2content-type=text/vnd.viewcvs-markup

.V

Tolle Krez wrote:

I am a newbie to struts and started with the struts-example application.  And modified it
a bit and learning.. . It looks like there are no separate model classes and all business
logic exists in the Action classes itself. I am thinking of separate them. The Datasource
settings are in my struts-config file and they are obtained in the Action class using
servlet.getServletContext().getAttribute(Action.DATA_SOURCE_KEY)) .

My question is, if I separate the business logic and database access away from Action
classes, how to I do get access to the datasource and connection pool.

PS: I am not using EJB and only plain java classes to access the database and for
business logics.

Any help is appreciated

T




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




Re: Design and Datasource question

2003-02-05 Thread Tolle Krez
I dont think it is good practice to pass datasource from Action class to your business
beans.
http://marc.theaimsgroup.com/?l=struts-userm=104333643909577w=2
http://marc.theaimsgroup.com/?l=struts-userm=104182416102397w=2

I feel using JNDI to get datasource is the best choice. Others - i should have searched
the archives properly. i apologize.

Thanks

- Original Message -
From: Vic Cekvenich [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, February 05, 2003 7:44 PM
Subject: Re: Design and Datasource question


 Some people get a connection in Action, and pass it in many ways to DAO.

 I get a connection in DAO (via DBCP). Ex:

http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/basicportal/basicportal/src/basicWebLib/org
/apache/basicWebLib/DAO/BasicDAOImpl.java?rev=1.2content-type=text/vnd.viewcvs-markup

 .V

 Tolle Krez wrote:
  I am a newbie to struts and started with the struts-example application.  And 
modified
it
  a bit and learning.. . It looks like there are no separate model classes and all
business
  logic exists in the Action classes itself. I am thinking of separate them. The
Datasource
  settings are in my struts-config file and they are obtained in the Action class 
using
  servlet.getServletContext().getAttribute(Action.DATA_SOURCE_KEY)) .
 
  My question is, if I separate the business logic and database access away from 
Action
  classes, how to I do get access to the datasource and connection pool.
 
  PS: I am not using EJB and only plain java classes to access the database and for
  business logics.
 
  Any help is appreciated
 
  T



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


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




Re: Design and Datasource question

2003-02-05 Thread Christopher Willingham
subclass dispatch action.  in execute method store the results from your
jndi lookup in the servlet context then pass it to your data access objects
which will then get connections from container pool(or your own).  you only
want to do the lookup once.  if its ejb, you'll need to duplicate similar
arrangement in that container.


- Original Message -
From: Tolle Krez [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Wednesday, February 05, 2003 8:42 PM
Subject: Re: Design and Datasource question


 I dont think it is good practice to pass datasource from Action class to
your business
 beans.
 http://marc.theaimsgroup.com/?l=struts-userm=104333643909577w=2
 http://marc.theaimsgroup.com/?l=struts-userm=104182416102397w=2

 I feel using JNDI to get datasource is the best choice. Others - i should
have searched
 the archives properly. i apologize.

 Thanks

 - Original Message -
 From: Vic Cekvenich [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Wednesday, February 05, 2003 7:44 PM
 Subject: Re: Design and Datasource question


  Some people get a connection in Action, and pass it in many ways to DAO.
 
  I get a connection in DAO (via DBCP). Ex:
 

http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/basicportal/basicportal/src/b
asicWebLib/org

/apache/basicWebLib/DAO/BasicDAOImpl.java?rev=1.2content-type=text/vnd.view
cvs-markup
 
  .V
 
  Tolle Krez wrote:
   I am a newbie to struts and started with the struts-example
application.  And modified
 it
   a bit and learning.. . It looks like there are no separate model
classes and all
 business
   logic exists in the Action classes itself. I am thinking of separate
them. The
 Datasource
   settings are in my struts-config file and they are obtained in the
Action class using
   servlet.getServletContext().getAttribute(Action.DATA_SOURCE_KEY)) .
  
   My question is, if I separate the business logic and database access
away from Action
   classes, how to I do get access to the datasource and connection pool.
  
   PS: I am not using EJB and only plain java classes to access the
database and for
   business logics.
  
   Any help is appreciated
  
   T
 
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 

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





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