Friday, March 13, 2009

What design pattern would you use to reduce JNDI lookups (EJB)

Question :What design pattern would you use to reduce JNDI lookups? (EJB)
Answer :Use ServiceLocator/EJBHomeFactory Pattern to reduce expensive JNDI
lookup process.
How it works is to cache those service objects when the client performs
JNDI lookup first
time and reuse that service object from the cache second time onwards for
other clients.
This technique maintains a cache of service objects and looks up the JNDI
only first time
for a service object. This technique reduces redundant and expensive JNDI
lookup process
thus increasing performance significantly.
Service Locator Pattern implements this technique by having a class to
cache service objects,
methods for JNDI lookup and methods for getting service objects from the
cache.
ServiceLocator acts as interceptor between client and JNDI.

No comments: