Java Reference
In-Depth Information
Service Locator
The EJB session beans and message-driven beans are used to implement business
workflows. These components on deployment are registered on the JNDI tree of the
application server. The JNDI provides a directory service, which external clients can use
to discover and look up objects by name. Hence, the JNDI makes EJBs accessible to
remote clients. Besides EJBs, JMS queues, topics, connection factories, and JDBC, data
sources are also bound in the JNDI. Listing 4-1 shows the JNDI lookup code used by the
magic JSP controller of the eInsure application.
Listing 4-1. UnderwritingController.jsp
final String JNDI_URL = "t3://localhost:7001";
public UnderwritingHome getEJBHome() {
UnderwritingHome home
= null;
Hashtable h = new Hashtable();
h.put(Context.PROVIDER_URL, JNDI_URL);
Context ctx = new InitialContext(h);
Object homeObj = ctx.lookup("uwrbusinessslsb");
home = (UnderwritingHome)PortableRemoteObject.narrow(homeObj,
catch(Exception e){
home = null;
return home;
String eventCode = request.getParameter("eventCode");
Search WWH ::

Custom Search