欢迎光临
我们一直在努力

在WebLogic下ejb的客户端程序的形式和特点-JSP教程,Java技巧及代码

建站超值云服务器,限时71元/月

对于weblogic的客户端程序可以是jsp/servlet,也可以是application的。1)jsp/servlet与ejb运行在同一个应用服务器上,其典型代码可如下:(无须建立t3协议下的连接,直接由客户端完成)                   context ctx=new initialcontext();                 object obj =ctx.lookup("ejb/com/j2ee/first/ejb/hellohome");                hellohome trh=(hellohome) portableremoteobject.narrow(obj,hellohome.class);           hello tr=trh.create();           out.println(tr.hello()); 注:该jndi-name可以放到web.xml中并用string jndiname=getservletconfig().getinitparameter("para-name")来获得jndi.2)对于一般的application而言,就与ejb不在同一个应用服务器下,那怕是在同一台机器上。  注意:(1)在客户端的系统变量要有:..\weblogic81 erver\lib\weblogic.jar; 否则不能运行。        (2)在文件配置必须要有:远程类,远程home类(一般不包含bean类,即业务类)才能确保客户类的运行。        通常以包的形式来组织这些文件,要注意按package是否正确的配置,否则出错。  其典型代码可如下:             string url="t3://localhost:7001";     properties prop=new properties();     prop.put(context.provider_url,url);            prop.put(context.initial_context_factory,"weblogic.jndi.wlinitialcontextfactory");            prop.put(context.security_principal, "name");         prop.put(context.security_credentials,"code");     context ctx=new initialcontext(prop);  object obj=ctx.lookup("ejb/com/j2ee/first/ejb/hellohome");  hellohome trh=(hellohome) portableremoteobject.narrow(obj,hellohome.class);  hello tr=trh.create();  system.out.println(tr.hello());      注意:context.security_principal和context.security_credentials是可选的,涉及到对ejb的操作的权限。

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 在WebLogic下ejb的客户端程序的形式和特点-JSP教程,Java技巧及代码
分享到: 更多 (0)