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 凌宇 阅读(234) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航:
 
<2024年5月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

常用链接

留言簿(3)

随笔档案(3)

文章档案(14)

相册

收藏夹

Java

最新随笔

搜索

  •  

最新评论

阅读排行榜

评论排行榜