File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Looking up EJB's 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 "Looking up EJB Watch "Looking up EJB New topic
Author

Looking up EJB's

PN Kumar
Ranch Hand

Joined: Sep 08, 2001
Posts: 38
There is a need to periodically lookup components - initially we thought of storing the lookup references (home interface references) in static variables, so that after the first lookup, the reference would be available and further JNDI lookups can be avoided. This has a drawback in the sense that when the component servers are restarted, the old cached reference would continue to remain.If instead we decide to lookup for each and every call, this would slow down the process.Any ideas/suggestions on the pros & cons of either of the above two procedures in welcome.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Why do you want to cache your lookups ? AFAIK modern containers already
cache JNDI queries so you don't have to take care of it.
Originally posted by PN Kumar:
There is a need to periodically lookup components - initially we thought of storing the lookup references (home interface references) in static variables, so that after the first lookup, the reference would be available and further JNDI lookups can be avoided. This has a drawback in the sense that when the component servers are restarted, the old cached reference would continue to remain.If instead we decide to lookup for each and every call, this would slow down the process.Any ideas/suggestions on the pros & cons of either of the above two procedures in welcome.
eammon bannon
Ranch Hand

Joined: Mar 16, 2004
Posts: 140

This has a drawback in the sense that when the component servers are restarted, the old cached reference would continue to remain

Why is this a drawback? And the EJBHomeFactory pattern (which is pretty much what you describe) is a widely used design pattern.
vin miller
Ranch Hand

Joined: Feb 01, 2001
Posts: 33
Here's an article about repairing the broken references. I'm not exactly sure how they 'validate' the reference to see if it needs to be refreshed.
http://www.javaworld.com/javaworld/jw-07-2002/jw-0703-service.html
What I don't understand is why it's ok to potentially allow multiple clients to have a reference to the same ejb object. Couldn't that cause problems?
Vin
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Looking up EJB's