1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
3
* Copyright � 2007 Sun Microsystems, Inc. All rights reserved.
4
* Use is subject to license terms.
9
<title>Using a Service Locator</title>
10
<link rel="StyleSheet" href="nbdocs://org.netbeans.modules.usersguide/org/netbeans/modules/usersguide/ide.css" type="text/css">
14
<h2>Using a Service Locator</h2>
16
<a href="#seealso">See Also</a>
19
<p>A service locator is a class that provides a single, reusable way to obtain
20
a reference to the following:</p>
22
<li>An enterprise bean's local and/or remote home interfaces</li>
23
<li>A JMS connection factory and topic destination</li>
24
<li>An e-mail session</li>
25
<li>A JDBC data source</li>
26
<li>The URL, name, or boolean value for an environment entry</li>
28
<p>You can create a regular service locator or one that caches the obtained reference
29
for further use. Generally you use a caching service regulator in web applications
30
and a regular service locator in the business tier. Enterprise beans especially
31
need non-caching service locators. Because each enterprise bean has a unique
32
JNDI name space, a resource reference with the same name can be declared in
33
multiple enterprise beans, potentially with different types.</p>
34
<p><b>To create a service locator:</b></p>
36
<li>Choose File > New.</li>
37
<li>From the Enterprise category, select Service Locator or Caching Service
40
<p><b>To use a service locator:</b></p>
42
<li>Run any of the following commands:
44
<li>Call Enterprise Bean</li>
46
<li>Send JMS Message</li>
50
<li>In the Service Locator Strategy section, select Use Existing Class and specify
51
the class name of the service locator. You can use the Browse button to search
56
<li>The service locator template is fully functional. You do not need to modify
57
the code, although you can customize its caching behavior.</li>
58
<li>You can only create a service locator in a web application project or EJB
62
<dt><a name="seealso">See Also</a></dt>
63
<dd><a href="../../ejb/editing/call_ejb.html">Calling an Enterprise Bean</a></dd>
64
<dd><a href="send_jms.html">Sending a JMS Message</a></dd>
65
<dd><a href="use_db.html">Accessing a Connection Pool from a Java Class</a></dd>
66
<dd><a href="send_email.html">Sending an E-mail from a Java File</a></dd>
71
<small><a href="../../credits.html">Legal Notices</a></small>
72
<table cellpadding="50" border="0">
73
<tr><td> </td></tr>