zoukankan      html  css  js  c++  java
  • EJB>改变sessionbean的JNDI名称 小强斋

    在Jboss 中要自定义JNDI 名称,可以使用@LocalBinding 和@RemoteBinding 注释,@LocalBinding 注释指定Session Bean 的Local 接口的JNDI 名称,@RemoteBinding 注释指定Session Bean 的Remote 接口的JNDI 名称,变Session Bean 的JNDI 名称
    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");
    如果你使用的是weblogic10/Sun Application Server/Glassfish,你可以使用@Stateless.mappedName()设置bean 的全局JNDI 名称,如:
    @Stateless(mappedName="OperationBeanRemote")
    public class OperationBean implements Operation, LocalOperation {
    客户端访问EJB 的代码片断如下:
    InitialContext ctx = new InitialContext(props);
    Operation operation = (Operation) ctx.lookup("OperationBeanRemote#com.foshanshop.ejb3.Operation");

  • 相关阅读:
    k8s 重要概念
    k8s 核心功能
    5 秒创建 k8s 集群
    学习 Kubernetes 的 Why 和 How
    Yeelink初步体验
    为Qemu aarch32添加BeautifulSoup4模块
    实现Qemu aarch32虚拟开发板ping www.baidu.com
    利用/proc/pid/pagemap将虚拟地址转换为物理地址
    加快Qemu Aarch32虚拟开发板的启动速度
    为Qemu aarch32开发板添加sd卡
  • 原文地址:https://www.cnblogs.com/xiaoqiangzhaitai/p/5637700.html
Copyright © 2011-2022 走看看