• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Stuck in presentation tier design

 
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All:
I am working on class diagram and stuck in presentation tier design.
In business and persistence tier, I have design couple of Services and DAOs.
All of them are EJB Stateless Session Beans and I assume DI is used.
So in presentation tier, I have to call the service in Servlet otherwise DI won't work (I don't use JSF cuz I am not familiar with JSF).
It turns out I need to create one servlet for each use case
and a front controller servlet to handle all requests from clients then dispatch to each action servlet to call service EJB.

Is this a good design or bad?

Thanks for your opinion,

Chris
 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I suggest you'd better use JSF, it will eliminate the need of additional controllers, servlets and other stuff. Even if you haven't done projects with JSF the theory you learned in the first part should be enough to design system with JSF. Don't reinvent the wheel, just use best practices
 
Chih-Wei Lee
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much! Dmitri!
I will move to JSF. It's much easier to use JSF with EJB3 to implement MVC.

Thanks
 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would not use a DAO because of the usage of JPA. Do you have any reasons to use DAO?
When using JSF pay attention to avoid having too much framework classes in the diagrams.

Dmitri, by the way, did you displayed in the diagrams the jsf framework classes/components?

 
Dmitri Ericsson
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ionut, From JSF I've displayed only JSP pages connected to controller (I've displayed it as a Controller, but in real life it's FacesServlet) on the class diagram, It's how it is done in the new book, strange solution but i preferred to do according to the book. I didn't show any classes of the framework and not ManagedBeans. However I've included JSFs and managed beans on my sequence diagrams
 
Chih-Wei Lee
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The reason why I use DAO is because of the flexibility to replace the data persistence mechanism.
For example, if one day for some reason you can't use the relational database, you can easily switch to another persistence mechanism like XML file. If you inject EntityManager in your service implementation, you won't be able to switch to another persistence mechanism without changing your service implementation.
 
Dmitri Ericsson
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Chih-Wei,
DAO may be reasonable in small systems, or to read configuration or in export/import implementations where you sometimes want to export to the database and sometimes to the file.
When it comes to the large enterprise systems, the probability that this system will need to use files instead of database is near to 0. what will be possible is the need of switching database engine (e.g. Oracle instead of DB2), and this will be even easier with JPA, because it has implementations suitable for most of the relational databases.
 
Ionut Bucurescu
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dmitri did you used any design patterns?
Most of them are coming with the frameworks:
jsf-interception filter, front controller, composite view
jpa-value object, value list handler
j2ee-dependency injection

Facade, factory, adapter patterns are good candidate to use with jsf.
Not sure about business delegate, but I guess if you don't have multiple client types(only jsf, maybe also web services) it might not be used.
 
Dmitri Ericsson
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ionut,
In my project I didn't mention any of patterns that come with the framework. I thought that the architecture of a framework and patterns used there is not a part of assignement.

I've used composite view for includng common fragments, Builder and Abstract Factory for object creation, Application Service for common business logic and Proxies when connecting to external systems.
 
Ionut Bucurescu
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much for the answers!
 
Chih-Wei Lee
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dmitri:
Where do you use Builder and Abstract Factory for object creation?
Do you use it in controller to create object such as Request or Bid, so it can store parameter value and pass to JPA for persistence?

Best,
 
Dmitri Ericsson
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not to reveal assignment details, but my system is designed to build objects and connect substitutable components. I use factories for creating various related components and builder to compose main object from those components. I use them in Application service, which is called from presentation tier, after creation they are persisted with JPA.
 
Chih-Wei Lee
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks!!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic