posts - 4,  comments - 9,  trackbacks - 0
          默認的JNDI命名規則前面已經介紹過,但有些情況下需要自定義名稱。要自定義JNDI名稱,可以使用
          @LocalBinding 和 @RemoteBinding 注釋,@LocalBinding注釋指定Session Bean的Local接口的JNDI名稱,
          @RemoteBinding注釋指定Session Bean的Remote接口的JNDI名稱,下面的代碼展示了如何自定義JNDI名:
          //author:lihuoming
          package com.foshanshop.ejb3.impl;
          import javax.ejb.Local;
          import javax.ejb.Remote;
          import javax.ejb.Stateless;
          import com.foshanshop.ejb3.LocalOperation;
          import com.foshanshop.ejb3.Operation;
          import org.jboss.annotation.ejb.LocalBinding;
          import org.jboss.annotation.ejb.RemoteBinding;
          @Stateless
          @Remote ({Operation.class})
          @RemoteBinding (jndiBinding="foshanshop/RemoteOperation")
          @Local ({LocalOperation.class})
          @LocalBinding (jndiBinding="foshanshop/LocalOperation")
          public class OperationBean implements Operation, LocalOperation {
          private int total = 0;
          private int addresult = 0;
          public int Add(int a, int b) {
          addresult = a + b;
          return addresult;
          }
          public int getResult() {
          total += addresult;
          return total;
          }
          }
          在JSP客戶端調用上面EJB的代碼片斷如下:
          InitialContext ctx = new InitialContext(props);
          Operation operation = (Operation) ctx.lookup("foshanshop/RemoteOperation");
          posted on 2006-11-01 22:57 凌宇 閱讀(244) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
          博客園   IT新聞   Chat2DB   C++博客   博問  
           
          <2025年7月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          常用鏈接

          留言簿(3)

          隨筆檔案(3)

          文章檔案(14)

          相冊

          收藏夾

          Java

          最新隨筆

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 读书| 乐清市| 太康县| 行唐县| 离岛区| 荆州市| 湄潭县| 绥芬河市| 边坝县| 平遥县| 蚌埠市| 潮安县| 遂宁市| 皋兰县| 红河县| 普安县| 绥宁县| 宁国市| 万全县| 盖州市| 麻栗坡县| 武宣县| 利津县| 和平区| 沐川县| 大港区| 蕉岭县| 买车| 资中县| 板桥市| 永兴县| 麦盖提县| 永新县| 亚东县| 襄垣县| 庆云县| 蒙山县| 枝江市| 伊川县| 林州市| 宜春市|