您的位置:首页 >> 编程开发 >> Java >> JavaBeans >> 正文
RSS
 

用jb7+weblogic6.1实现客户端+无状态sessionbean+实体bean的调用

http://www.rdxx.com 01年11月18日 11:08 互联网 我要投稿

关键词: 状态 , 客户端 , 调用 , WebLogic , Session , JB , Bean , Web , BEA , SSI

        }
        return sReturn
    }

大家注意这句话    AhUserHome ahh = (AhUserHome) (new InitialContext().lookup("java:/comp/env/cmp1"));

由于在同一个容器当中,调用cmp不需要rmi远程调用。采用写环境变量的方法,上面的话要运行成功,必须做以下操作。
选中你的BeanQueryAH这个bean,选中右下的 EJB Local References,Add,填入名字cmp1,这时候生成一行,把islink选上
link里面选上ahuser,type 选entity.

这样上面的那句就可以通过这个环境变量本地调用你这个ejb了。

当然,大家可以根据自己的数据库来修改这两句话来返回不同的值。
  AhUser ahuser = ahh.findByPrimaryKey(mobile);
         sReturn = ahuser.getLogintime();

(五)客户端的建立
1 在jb里面new 一个ejb client test,默认的下面的4个复选框是勾上三个,ok
2 找到main方法是这样写的
    public static void main(String[] args) {
        BeanQueryAHTestClient1 client = new BeanQueryAHTestClient1();
        // Use the client object to call one of the Home interface wrappers
        // above, to create a Remote interface reference to the bean.
        // If the return value is of the Remote interface type, you can use it
        // to access the remote interface methods.  You can also just use the
        // client object to call the Remote interface wrappers.
    }

3 修改
    public static void main(String[] args) {
        BeanQueryAHTestClient1 client = new BeanQueryAHTestClient1();
        // Use the client object to call one of the Home interface wrappers
        // above, to create a Remote interface reference to the bean.
        // If the return value is of the Remote interface type, you can use it
        // to access the remote interface methods.  You can also just use the
        // client object to call the Remote interface wrappers.
        client.create();
        System.out.print(client.queryAH("13956261950")) ;
        System.out.print(client.queryAH("13955177766")) ;
        System.out.print(client.queryAH("13956395757")) ;
        System.out.print(client.queryAH("13956536656")) ;
    }

(六) 运行
1 编译后,生成*.jar文件,启动weblogic,把*.jar部署上去
2 运行client ,命令控制台里面就打印
-- Initializing bean access.

-- Succeeded initializing bean access.

-- Execution time: 2274 ms.

-- Calling create()

-- Succeeded: create()

-- Execution time: 70 ms.

共3页  第1页 第2页 第3页

 
 
标签: 状态 , 客户端 , 调用 , WebLogic , Session , JB , Bean , Web , BEA , SSI 打印本文
 
 
  热点搜索
 
 
 



Valid XHTML 1.0 Transitional
Copyright ©2005 - 2008 Rdxx.Com,All Rights Reserved
收藏本页
收藏本站