66 lines
1.9 KiB
HTML
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("com/mycompany");
|
||
|
|
||
|
// Create each intermediate subcontext, if necessary, as well as leaf context.
|
||
|
// AlreadyBoundException is not thrown.
|
||
|
<strong>JndiHelper.recursiveCreateSubcontext(startingContext, "apps/
|
||
|
accounting");</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, "com/mycompany/apps/accounting",
|
||
|
someObject);</strong>
|
||
|
}
|
||
|
catch (NamingException e){
|
||
|
// Handle other errors.
|
||
|
}
|
||
|
</pre>
|
||
|
</li>
|
||
|
</ul>
|
||
|
|
||
|
|
||
|
|
||
|
</body>
|
||
|
</html>
|