public class BeanFactory {
/**
* 上下文
*/
private static Context context;
//权限模块ejb接口
private static com.techqy.bbjy.carve.session.IPermission permission;
/**
* 初始化上下文
* @return
* @throws NamingException
* @create by SZQ at 2009-6-11
*/
private static Context loadContext() throws NamingException {
if (context != null)
return context;
synchronized (new byte[0]) {
if (context != null)
return context;
Hashtable<String, String> props = new Hashtable<String, String>();
/*********************远程ejb连接上下文********************
props.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.RemoteInitialContextFactory");
props.put(Context.PROVIDER_URL, "ejbd://127.0.0.1:4201");
*************************************************************/
//本地ejb连接上下文
props.put("java.naming.factory.initial",
"org.apache.openejb.client.LocalInitialContextFactory");
context = new InitialContext(props);
}
return context;
}
/**
* 查找本地接口
* @param name 本地接口名称 *
* @return 本地接口
* @throws NamingException
* @create by SZQ at 2009-6-11
*/
public static Object lookup(String name) throws NamingException {
return loadContext().lookup(name);
}
/**
* 获取权限本地接口
* @return 权限本地接口
* @throws NamingException
* @create by SZQ at 2009-6-11
*/
public static IPermission getPermissionBean() throws NamingException {
return (permission != null)? permission
:(IPermission) lookup("PermissionImplBeanLocal");
}
}
OpenEjb连接工厂
最新推荐文章于 2024-07-19 15:00:08 发布
313

被折叠的 条评论
为什么被折叠?



