Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Service Locator

 
roul ravashimka
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
if i understeand it good, the service locator caches the EJBHome-Obejct.
I was wondering, why not cache the EJB-Object, instead of the EJBHome-Object?
Greetings,
Roul
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to EJB forum...
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Roul,
EJB Object refers to the Bean object on the server side so its pooled or cached by the server already to enhance performance. Why to cache it again on client side where we are using service locator?
Also, if we cache EJBObject then server's pooling etc would be meaningless and it would like client is managing EJBObject which is against the J2EE architecture right?
I hope I make sense..
Others please provide more insights here...
Regards
Maulin
 
Sergiu Truta
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Caching EJB objects doesn't help you very much. Usually you have to use several objects of the same type and instead of caching let's say 10 EmployeeBean bean objects,you cache only the EmployeeHome object and through this you can create/find/delete any number of EJBObjects.
The EJBHome object is used as a factory for EJBObjects and by caching it you don't have to look it up every time you want to manipulate an object it is responsable of.
You could read the EJBHomeFactory pattern (you can find it in Floyd Marinescu's EJB Desing Patterns) and after that you'll see the benefits of caching the EJBHome objects.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic