📄 example4.java
字号:
package com.wlsunleashed.jndi;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
/**
* This Example demonstrates the process of listing a JNDI subtree.
*
* No warranties, explicit or implied are made about this source code.
* This is provided as-is and
*
* @version 1.0
* @since July 2002
*/
public class Example4 {
/**
* Constant representing the Initial context factory to be used
*/
private static final String INITIAL_CONTEXT_FACTORY =
"weblogic.jndi.WLInitialContextFactory" ;
/**
* Constant representing the Provider URL
*/
private static final String PROVIDER_URL =
"t3://localhost:7001" ;
/**
* The main method is invoked when the class file is executed
* @param args : list of command line arguments
*/
public static void main(String[] args) {
Example4 object = new Example4();
try
{
object.listSubTree("javax.transaction");
}
catch (NamingException ne)
{
ne.printStackTrace();
}
}
/**
* Prints the subtree denoted by the passed tree name
* the client's environment
* @param subTree The Tree name
* @return Object
*/
private void listSubTree(String subTree )
throws NamingException
{
Hashtable props = new Hashtable() ;
props.put( Context.INITIAL_CONTEXT_FACTORY,
INITIAL_CONTEXT_FACTORY );
props.put( Context.PROVIDER_URL,
PROVIDER_URL );
Context ctx = new InitialContext( props );
System.out.println("Listing Bindings under javax.transaction");
NamingEnumeration enum = ctx.listBindings(subTree);
while (enum.hasMore())
{
System.out.println( enum.next() );
}
System.out.println("listing done");
ctx.close();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -