Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Should I put a BD between Session and Entity Bean?

 
Rahul Devgan
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Please enlighten me on this one; Is it a good idea to put a Business Delegate between a Session Bean and Entity Bean, if I do not know whether the entity is local or remote? I believe the Session Bean(a Session Facade) is a client as far as EB is concerned and there should be a BD inbetween just like between a Servlet Client and Session Facade.
One can say that try the to contact the Entity locally first and if not available then contact it in the catch block remotely but the same can be done in BD with a service locator to find the entity home.
Please respond.
 
Jeremy Hsu
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Business Delegate is used to help the application developer to not worry about the complex specification of EJBs. For example, look up the remote/local interface using the Home object, etc, and catch those ejb exceptions.

As a result, it is normally used in servlet or jsp to access an EJB.

Therefore, using business delegate in session bean to access an entity bean won't really fit the definition of business delegate. When you use a session bean to access an Entity bean, this is called a Session Facade. In other words, how you make calls to an entity bean in your session bean really depends on you. And usually this helper is called the service activator but never business delegate.
[ June 07, 2005: Message edited by: Jeremy Hsu ]
 
Lucy Hummel
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rahul,

I totally agree with Jeremy.

In my architecture BD is used by a controller object that is part of the client side and not part of the server side.

Lucy
 
Rahul Devgan
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
Thanks for your replies.
Well, the essence of my question was how do we cache Entity Home Objects, without knowing whether they are remote or local, so that we can get some performance benefits. There being several ways to do it, like creating a home object in the ejbCreate of the Session Facade and having a global reference to the same or using a helper class, as mentioned by Jeremy, which gives us cahced homes. I wanted to find out the best approach for the same.
What do you guys think is the best approach?
 
Jeremy Hsu
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Rahul Devgan

Take a look at Service Locator J2ee pattern. I believe that is what you want. A service locator pattern basically locates objects placed on the JNDI. As a result, you can put all your cached code there.

and since I am in a good mood today. I find the link for you to study:
http://java.sun.com/blueprints/corej2eepatterns/Patterns/ServiceLocator.html
[ June 08, 2005: Message edited by: Jeremy Hsu ]
[ June 08, 2005: Message edited by: Jeremy Hsu ]
 
Jeremy Hsu
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way, just something came to my mind about you talking about caching the Home for the entity bean.

Hmm, let me put this way. Caching should be used to reduce network calls. Since you talking about caching the home objects for the entity bean, I feel you are thinking the possiblity of using remote interface for entity bean. OK. This is very scary because you talking about very bad J2EE practice here (using remote interface for entity bean). I know before ejb 2.0, there is no way to specify local interface for entity bean, as a result, talking about caching the home for entity bean is fine. However, with ejb 2.0 or later, we are now provided with local interface, so this is why so many people talking about wrapping your entity bean with your session beans. If you are doing this, caching the local home for you entity bean services very little purpose because accessing a local home object is just making in memory JNDI calls, and This is very quick. Caching this in memory will not boost too much performance in this case. However, if you do this on your web client side (caching remote home for your session beans), this will boost a lot of performance because you are reducing the network calls in this case.
 
Rahul Devgan
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On the main SCEA page, I can see 5 replies to my topic but when i click the link to this topic, I can only see my original message and none of the replies.
i was able to view the 2 replies about 2 days ago.
 
Rahul Devgan
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
After I posted my last reply I was able to see the replies to my original message.
Thanks Jeremy for your inputs. I am aware of the Service Locator Pattern and local and remote interfaces of EJB. However, I just wanted to clear a few confusions creeping into my mind and see what other have to say about them. Also, the SCEA is based on EJB1.1, J2EE 1.2, so am not sure if we can use local interfaces in our designs. Any clarifications on this.
 
Jeremy Hsu
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well, I pretty sure if you make this clear in your assumption. I think you will be fine.
 
Dean Homer
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rahul

Based on what I've read in this forum, most agree that the design patterns and general architectural concepts applied in part 2 are not bound to a specific version of J2EE. As well, the assignment instructions make no reference to a particular J2EE version.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic