40 lines
850 B
Java
40 lines
850 B
Java
package wenrgise.common.utility;
|
|
|
|
import java.util.Hashtable;
|
|
import javax.naming.Context;
|
|
import javax.naming.InitialContext;
|
|
import javax.naming.NamingException;
|
|
|
|
public class ContextProvider {
|
|
private Context ctx = null;
|
|
|
|
public static InitialContext localContext;
|
|
|
|
static {
|
|
try {
|
|
localContext = new InitialContext();
|
|
} catch (NamingException oNx) {
|
|
oNx.printStackTrace();
|
|
}
|
|
}
|
|
|
|
private static ContextProvider objContextProvider = new ContextProvider();
|
|
|
|
private ContextProvider() {
|
|
try {
|
|
Hashtable env = new Hashtable();
|
|
this.ctx = new InitialContext();
|
|
} catch (Throwable e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
public static Context getContext() {
|
|
return objContextProvider.ctx;
|
|
}
|
|
|
|
public static InitialContext getLocalContext() {
|
|
return localContext;
|
|
}
|
|
}
|