首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

OpenEjb联接工厂

2012-10-06 
OpenEjb连接工厂public class BeanFactory {/** * 上下文 */private static Context context//权限模块ej

OpenEjb连接工厂

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");}}

热点排行