java left logo
java middle logo
java right logo
 

Home arrow Java EE Tips arrow Enterprise Java Beans arrow How to improve client-side EJB lookup code
 
 
Main Menu
Home
Java Tutorials
Book Reviews
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Java Network
Java Forums
Java Blog




Most Visited Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews
Top Rated Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews


Statistics
Registered Users: 3947
Java SE Tips: 614
Java ME Tips: 202
Java EE Tips: 183
Other API Tips: 779
Java Applications: 298
Java Libraries: 209
Java Games: 16
Book Reviews:
 
 
 
How to improve client-side EJB lookup code E-mail
User Rating: / 12
PoorBest 

Typical EJB applications make use of a client layer that invokes one or many EJBs several times. This is true for many web applications as well. When q client layer must use a particular bean multiple times, you'll want to make an effort to improve the performance of the JNDI call that looks up the bean. In addition, it would be nice to reduce duplicated code. To improve client performance, create a utility object that encapsulates the JNDI lookup of EJB home object reference. In addition to performing home lookups, the utility object can cache the home reference for reuse.

This tip contains an example - a utility object that looks up the home object for an EJB:

public class SomeBeanHomeCache {
    
    private static SomeBeanHome _home = null;
    
    public static EquityHome getHome() throws NamingException {
        
        if (_home == null) {
            
            try {
                
                InitialContext context = new InitialContext();
                _home = (SomeBeanHomePortableRemoteObject.narrow(
                        context.lookup("test.someBean")
                        SomeBeanHome.class);
                
            catch (Exception e) {
                e.printStackTrace();
                // handle error
            }
        }
        
        return _home;
    }
}


 Related Tips

 
< Prev   Next >

Page 1 of 0 ( 0 comments )

You can share your information about this topic using the form below!

Please do not post your questions with this form! Thanks.


Name (required)


E-Mail (required)

Your email will not be displayed on the site - only to our administrator
Homepage(optional)



Comment Enable HTML code : Yes No



 
       
         
     
 
 
 
   
 
 
java bottom left
java bottom middle
java bottom right
RSS 0.91 FeedRSS 1.0 FeedRSS 2.0 FeedATOM FeedOPML Feed

Home - About Us - Privacy Policy
Copyright 2005 - 2008 www.java-tips.org
Java is a trademark of Sun Microsystems, Inc.