Meaningless Drivel is fun!
The moose likes EJB and other Java EE Technologies and the fly likes Service Locator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Service Locator" Watch "Service Locator" New topic

Service Locator

roul ravashimka
Ranch Hand

Joined: Mar 16, 2004
Posts: 53
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?

MSc Electronics, ICT
Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
Moving to EJB forum...

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1873
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...
Sergiu Truta
Ranch Hand

Joined: Dec 16, 2003
Posts: 121
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. I'm walking the path...
I agree. Here's the link:
subject: Service Locator
It's not a secret anymore!