Last active
August 29, 2015 14:09
-
-
Save luszczynski/c7d849e0c34a2cc43f72 to your computer and use it in GitHub Desktop.
EJB JNDI View
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
private Map<Class<?>, String> getEJBLookups() throws NamingException, ClassNotFoundException { | |
InitialContext ctx = new InitialContext(); | |
NamingEnumeration<NameClassPair> globals; | |
NamingEnumeration<NameClassPair> modules; | |
NamingEnumeration<NameClassPair> apps; | |
Map<Class<?>,String> lookups = new HashMap<Class<?>,String>(); | |
globals = ctx.list("java:global"); | |
while (globals.hasMore()) { | |
NameClassPair global = globals.next(); | |
modules = ctx.list("java:global/" + global.getName()); | |
while(modules.hasMore()) { | |
NameClassPair module = modules.next(); | |
apps = ctx.list("java:global/" + global.getName() + "/" + module.getName()); | |
while(apps.hasMore()) { | |
NameClassPair app = apps.next(); | |
String[] strings = app.getName().split("!"); | |
String packageClass = strings[1].substring(0,strings[1].lastIndexOf(".")); | |
Class<?> clazz = Class.forName(packageClass + "." + strings[0]); | |
if(!app.getName().endsWith("Local")) | |
lookups.put(clazz, "java:global/" + global.getName() + "/" + module.getName() + "/" + app.getName()); | |
} | |
} | |
} | |
return lookups; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment