ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzatz_5.4.0.1/51/program/jndihuhc.htm

66 lines
1.9 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<LINK rel="stylesheet" type="text/css" href="../../../rzahg/ic.css">
<title>JNDI helper class</title>
</head>
<BODY>
<!-- Java sync-link -->
<SCRIPT LANGUAGE="Javascript" SRC="../../../rzahg/synch.js" TYPE="text/javascript"></SCRIPT>
<h6><a name="jndihuhc"></a>JNDI helper class</h6>
<p>The <a href="apidocs/ae/com/ibm/websphere/naming/JndiHelper.html">com.ibm.websphere.naming.JndiHelper</a> <img src="api.gif" border="0" width="18" height="15" alt="Go to API documentation"> class contains static methods to simplify common JNDI programming and administration tasks.</p>
<p>These helper class functions include:</p>
<ul>
<li><strong>Recursively creating subcontexts</strong>
<pre>import com.ibm.websphere.naming.JndiHelper;
...
try {
Context startingContext = new InitialContext();
startingContext = startingContext.lookup(&quot;com/mycompany&quot;);
// Create each intermediate subcontext, if necessary, as well as leaf context.
// AlreadyBoundException is not thrown.
<strong>JndiHelper.recursiveCreateSubcontext(startingContext, &quot;apps/
accounting&quot;);</strong>
}
catch (NamingException e){
// Handle other errors.
}
</pre>
</li>
<li><strong>Rebinding objects and creating intermediate contexts that do not already exist</strong>
<pre>
import com.ibm.websphere.naming.JndiHelper;
...
try {
Context startingContext = new InitialContext();
// Creates each intermediate subcontext, if necessary, and rebinds object.
<strong>JndiHelper.recursiveRebind(startingContext, &quot;com/mycompany/apps/accounting&quot;,
someObject);</strong>
}
catch (NamingException e){
// Handle other errors.
}
</pre>
</li>
</ul>
</body>
</html>