JNDI查找示例
2008-01-05 08:58:23 来源:WEB开发网核心提示:import java.util.*;import javax.naming.*;import javax.naming.Directory.*;import java.io.*;public class ListAll { public static void main(java.lang.String[] arg
import java.util.*;
import javax.naming.*;
import javax.naming.Directory.*;
import java.io.*;
public class ListAll {
public static void main(java.lang.String[] args) {
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
env.put(Context.PROVIDER_URL, "t3://localhost:7001");
try {
InitialContext ctx = new InitialContext(env);
NamingEnumeration enum = ctx.listBindings("");
while(enum.hasMore()) {
Binding binding = (Binding) enum.next();
Object obj = (Object) binding.getObject();
System.out.println(obj);
}
} catch (NamingException e) {
System.out.println(e);
}
赞助商链接