Java Mailing List Archive

http://www.junlu.com/

Google
Google
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
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Subject: Servlet : Session invalidate
Oracle Connection Pooling in 3 2 2
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Subject: Running a Simple JMS Example
Tomcat and webapplication specific java library path
Mapping in workers2 properties
org apache jasper JasperException
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action
   MESSAGE
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
Value attribute of <html:checkbox
url string for connecting jboss to oracle
javax servlet ServletException: BeanUtils populate
5 0 18: Windows XP Pro vs Windows 2000
HTTP Status 404 The requested resource is not available
 
Subject: DAO, Entity CMP, Strategy

Subject: DAO, Entity CMP, Strategy

2004-09-28       - By Manish Malhotra

 Back
Reply:     1     2     3     4  

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)

©2008 junlu.com - Jax Systems, LLC, U.S.A.