panda.util.JndiLookup Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of panda-core Show documentation
Show all versions of panda-core Show documentation
Panda Core is the core module of Panda Framework, it contains commonly used utility classes similar to apache-commons.
package panda.util;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class JndiLookup {
public static Object lookup(String name) throws NamingException {
try {
return ((Context)new InitialContext().lookup("java:comp/env")).lookup(name);
}
catch (NamingException e) {
try {
return new InitialContext().lookup(name);
}
catch (NamingException e2) {
return ((Context)new InitialContext().lookup("java:/comp/env")).lookup(name);
}
}
}
}