Last active
August 29, 2015 14:02
-
-
Save thejavalistener/46740887bb502c148895 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.thejavalistener.post.jndiintrospector; | |
import javax.naming.Binding; | |
import javax.naming.Context; | |
import javax.naming.InitialContext; | |
import javax.naming.NamingEnumeration; | |
public class JndiIntrospector | |
{ | |
public static void print() | |
{ | |
try | |
{ | |
Context ctx = new InitialContext(); | |
String n = ctx.getNameInNamespace(); | |
_print(n); | |
} | |
catch(Exception ex) | |
{ | |
ex.printStackTrace(); | |
throw new RuntimeException(); | |
} | |
} | |
private static void _print(String name) throws Exception | |
{ | |
try | |
{ | |
System.out.println("Name in manespace: "+name); | |
Context ctx = new InitialContext(); | |
NamingEnumeration<Binding> list = ctx.listBindings(name); | |
while( list.hasMoreElements() ) | |
{ | |
Binding b = list.nextElement(); | |
String s = b.getName(); | |
_print(name+"/"+s); | |
} | |
} | |
catch(Exception ex) | |
{ | |
// ignore | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment