Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Looking up EJB's

 
PN Kumar
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic