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

context.lookup() performance isuue

 
mohan dodderi
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
i have found the following question in the net ,but i dont know the answer for the question , we may get similar type of questions in SCBCD exam also , so i am posting in forum , any of u know the answer for this question pls reply.



If there are 100 beans in JNDI & the context.lookup() method takes time to
lookup. How do you handle the situation to make it easy retrieval of the bean?


regards
Mohan dodderi
 
Ankit Doshi
Ranch Hand
Posts: 222
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think I can expect such question on the SCBCD exam. The reason being that the exam is purely based on the concepts given in the specs...

But this can surely be a good question if you're appearing for a EJB interview

I am not sure about the answer either ...
 
Frederic Esnault
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To make lookup faster, you must use JNDI subcontext in a clever way. This means giving subcontext allowing JNDI to eliminate the maximum of beans.

If all your beans are in the ejb/ subcontext, then JNDI will have to find between all of them which one you need.

If you make a clear tree, where you specify meaningful business-related subcontexts, then you help JNDI a lot. How many beans do you think have a JNDI name like ejb/session/shopping/cart/ShoppingCartBean ? With this, JNDI can go down the context tree and find your bean very fast.
 
Rahul Mishra
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to further expand what Fredric has said

You have a sub context called ejb..

so do this,

context = ctx.lookUp(java:comp/env/ejb)....Cache this..either in session(avoid persistent cache..because it might not give you too much of an edge)...

Next time you look up..something inside ejb subcontext

Do, a context.lookUp...From cached version

Advantage of this is...you are eliminating the concept of you moving across the entire JNDI Tree and focusing on a particular sub context which could be relatively faster...
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic