  | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Tomcat - JSP/Servlet container | | Struts - A MVC web framework | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | JSP - A mailing list about Java Server Pages specification and reference | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | |
Struts & Hibernate
|
|
|
  | | | Subject: DAO, Entity CMP, Strategy | Subject: DAO, Entity CMP, Strategy 2004-09-28 - By Manish Malhotra
Back Hi,
In the code snippet of the DAO factory. The objects of DAO's are created using SingleTon pattern. But I have also doveloped the same factory and I asked the question that do Is this the right design or it could create the bottelneck situation for the application. My application was getting hanged during stress testing. So, I raised this question.
Now, can you explain that is there any flaw when our application is going to be used by simoltaneously users. Your input is appreciable.
Manish
-- --Original Message-- -- From: An interest list for Sun Java Center J2EE Pattern Catalog [mailto:J2EEPATTERNS-INTEREST@(protected)]On Behalf Of Koala Sent: Thursday, September 23, 2004 1:46 PM To: J2EEPATTERNS-INTEREST@(protected) Subject: Re: DAO, Entity CMP, Strategy
Ricardo de Souza Moura wrote:
> I wish I can to do all my database access by a DAO. > But, what if I have a Entity CMP ? Would be a good pratice to use a > Strategy > pattern ? > > for sample: > > /* > DAO Interface > */ > public Interface CustomerDAO{ > public void insertCustomer(String name); > } > > /* > DAO implementation > */ > public class CustomerDAOEJBImpl implements CustomerDAO{ > Context context; > EJBHome home; > > public CustomerDAOEJBImpl(){ > context = InitiContext(); > home = context.lookup(...); > } > > public void insertCustomer(String name){ > home.create(name); > } > > } > > thanks in advance > > __ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ __ > MSN Messenger: converse com os seus amigos online. > http://messenger.msn.com.br > > ==================================================================== > Companion Site: http://www.corej2eepatterns.com > J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns > List Archive: > http://archives.java.sun.com/archives/j2eepatterns-interest.html > Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to > listserv@(protected) > A good example is Firestorm a dao generator tool. Here how to do. For each DAO MyDAO create:
1. a value object MyDAOValue 2. an interface
interface MyDAO { PrimaryKey create(MyDAOValue v); void remove(PrimaryKey p); void update(PrimaryKey p ,MyDAOValue v); ... Collection findAll(); MyDAOValue findByPrimaryKey(PrimaryKey p) }
notice I use value objects for my CRUD methods.
2. An implementation class MyDAOImpl with two constructors:
class MyDAOImpl extends MyDAO { MyDAOImpl() { } // if the dao do not partecipate to an external transaction MyDAOImpl(Transaction t) { } // if the dao partecipate to an external transaction .... }
3. A factory with the following methods:
class MyDAOFactory { static MyDAO create() { // here you can read from a conf file to understand what DAO create if (dao == null) dao = new MyDAOImpl() else return dao; }
static MyDAO create(Transaction t) { // here you can read from a conf file to understand what DAO create return new MyDAOImpl(t) }
private MyDAO dao; }
This is the implementation provided by Firestorm (a dao generator tool).
With EJB there is a problem I explained in the thread CMP -DAO, please see there.
==================================================================== Companion Site: http://www.corej2eepatterns.com J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns List Archive: http://archives.java.sun.com/archives/j2eepatterns-interest.html Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to listserv@(protected)
==================================================================== Companion Site: http://www.corej2eepatterns.com J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns List Archive: http://archives.java.sun.com/archives/j2eepatterns-interest.html Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to listserv@(protected)
|
|
 |