If you use EJB's, the best approach is to allow the EJB container to manage
all your database connections and then access all data using Entiy Beans.

Here are some general rules of thumb I'd recommend:

 - EJBs fit with Struts Model components. Generally, they should only be
called from the Struts Action class.

 - If you have more than 1 (or maybe 2) EJBs to access from your Action
class, consider implementing a Stateless Session Bean (or even a non-EJB
helper class that is called from your Action class) to act as a "façade"
and simplify your Action class.

 - Entity Beans should be "Coarse Grained" to minimize the number of beans
created and to isolate the Action class from changes in the table structure
of the underlying database.

 - Use "Value Objects" and pass data to and from the EJB "a bean at a time"
rather than "a property at a time".

 - Avoid using Stateful Session Beans. Instead use Stateless Session Beans
and maintain stateful information in Struts using the session context of
the Web container.

 - Use Stateful Session Beans only if you have transactions that span more
than one user request and you need the EJB container to manage committing
or rolling-back the transaction.

I go into a good bit more detail in my book Struts Kick Start - it has
sample code and build scripts as well and comes with a CD-ROM containing
JBoss and a bunch of other apps.

Respond back if you have more specific questions -

Kevin



-------------------
Kevin Bedell
Author, Struts Kick Start
http://www.amazon.com/exec/obidos/tg/detail/-/0672324725/qid=1036445679/sr=1-1/ref=sr_1_1/002-7047256-5912803?v=glance








"Andrew Lubalin" <[EMAIL PROTECTED]> on 11/04/2002 04:08:40 PM

Please respond to "Struts Users Mailing List"
       <[EMAIL PROTECTED]>

To:    [EMAIL PROTECTED]
cc:     (bcc: Kevin Bedell/Systems/USHO/SunLife)
Subject:    Connection Pool for EJBs


I am planning on using EJBs for my business tier in my application.  If I
configure a datasource and create a connection pool using Struts, will this
pool be global?  Will it be container managed or should I create my
connection pool independent of Struts and use it conjunction with the
framework.  What is the best way when using EJBs?


--
To unsubscribe, e-mail:   <
mailto:struts-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <
mailto:struts-user-help@;jakarta.apache.org>







---------------------------------------------------------------------------
This e-mail message (including attachments, if any) is intended for the use
of the individual or entity to which it is addressed and may contain
information that is privileged, proprietary , confidential and exempt from
disclosure.  If you are not the intended recipient, you are notified that
any dissemination, distribution or copying of this communication is
strictly prohibited.  If you have received this communication in error,
please notify the sender and erase this e-mail message immediately.
---------------------------------------------------------------------------



--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@;jakarta.apache.org>

Reply via email to