Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

A newbie of EJB: ask for the design  RSS feed

 
Stephen Lee
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am now learning EJB. Now, I have the basic concept of EJB, e.g. Session Bean, Message-Driven Bean, Entity Bean. However, I am now trying to learn the design of the bean. I find it is quite difficult to design which type of bean should be created.
Now, I want to create a web application which allows the user to add/edit/delete/view people information in a system. There is a table of People in the DB. So that there should be an entity bean of People. However, how should I design for the action of add, edit, delete and view?
Thanks!
Stephen
 
Rishi Singh
Ranch Hand
Posts: 321
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Lee,
You can either have stateless bean for each activity i.e addition,deletion,viewing..etc or u can have one stateful session bean for each user which will allow him to do all these.The decision basically depends upon how often is these activity going to occur and can the user do one or mutiple activity simultaneously.
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm sorry Rishi, but I think that those of those design options would be lousy. Stateful beans should be avoided whenever possible. And one stateless bean per operation is too many for no good reason...
Instead I would have a single "Facade" stateless EJB that contains the operations add, remove, create and find. Those operations would be implemented by calling the appropriate messages on the Entity bean home and the individual entity beans themselves.
For a couple of examples, you can look here and here. Another couple of books to read are Richard Monson-Haefel's "Enterprise JavaBeans" and Deepak Alur's "Core J2EE Patterns", which walk you through design decisions like this.
Kyle
 
Stephen Lee
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!