Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

11.1. Wiring EJBs in Spring

If you’ve ever written a client for a 2.x EJB, you are probably familiar with how you gain access to an EJB reference. First you would look up the EJB’s home interface from JNDI using code that looks a little like this:

private TrafficServiceHome trafficServiceHome;
private TrafficServiceHome getTrafficServiceHome ()
    throws javax.naming.NamingException {

  if(trafficServiceHome != null)
      return trafficServiceHome;

  javax.naming.InitialContext ctx =
      new javax.naming.InitialContext();

  try {
    Object objHome = ctx.lookup("trafficService");

    TrafficServiceHome home =
        (TrafficServiceHome) javax.rmi.PortableRemoteObject.narrow(
          objHome, TrafficServiceHome.class);

    trafficServiceHome = home;
    return home;
  } finally {
    ctx.close();
  }
}


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint