📄 jndiutil.java
字号:
package junitbook.ejb.util;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class JNDIUtil
{
private static InitialContext jndiContext;
private static InitialContext getInitialContext()
{
if (jndiContext == null)
{
try
{
jndiContext = new InitialContext();
}
catch (NamingException e)
{
throw new RuntimeException(
"Failed to create InitialContext ["
+ e.getMessage() + "]");
}
}
return jndiContext;
}
public static Object lookup(String name)
{
Object object = null;
try
{
object = getInitialContext().lookup(name);
}
catch (NamingException e)
{
throw new RuntimeException("JNDI lookup failure for ["
+ name + "]. Reason [" + e.getMessage() + "]");
}
return object;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -