EJB问题,关于命名环境。

lia 2001-06-07 10:44:00
//get naming context
Context ctx = new InitialContext();

//look up jndi name
Object ref = ctx.lookup("HelloWorld");

看到一个EJB的例子;得到命名环境的是上面的两句话;
我想Context ctx = new InitialContext();就是得到了缺省得命名环境,如果要写全了应该怎样写;
如果当时有两个命名环境,程序如何判断用哪一个。
...全文
73 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
backlove 2001-06-07
  • 打赏
  • 举报
回复
weblogic:
public static Context getWeblogicInitialContext()
throws javax.naming.NamingException {
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
p.put(Context.PROVIDER_URL, "t3://bingo:7001");
return new InitialContext(p);
}
emily_wang 2001-06-07
  • 打赏
  • 举报
回复
This is a Websphere demo. just for your reference.
// Get the initial context
java.util.Hashtable properties = new java.util.Hashtable(2);
properties.put(javax.naming.Context.PROVIDER_URL, "IIOP://192.168.0.20:900/"); // local name server
properties.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,"com.ibm.ejs.ns.jndi.CNInitialContextFactory"); // IBM name services
javax.naming.InitialContext initContext = null;
initContext = new javax.naming.InitialContext(properties);

/*
* Find all Customer Entity Beans which
* match the loginname
*/

CustomerHome customerHome = null;
Object obj = initContext.lookup("cdworld/Customer"); // JNDI name
customerHome = (CustomerHome) javax.rmi.PortableRemoteObject.narrow(obj,CustomerHome.class);
lia 2001-06-07
  • 打赏
  • 举报
回复
jndi只是一个标准,我问的是用什么软件。
BugHunterPro 2001-06-07
  • 打赏
  • 举报
回复
jndi
lia 2001-06-07
  • 打赏
  • 举报
回复
多谢二位,再请问一下,WebSphere和WebLogic各自用什么产品来维护命名环境的。

67,541

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧