读书人

EJB3.0 中远道本地bean访问使用

发布时间: 2012-10-19 16:53:36 作者: rapoo

EJB3.0 中远程本地bean访问使用

package com.easyway.tbs;
/**
?* 远程接口
?*
?*/
public interface Operation {
? public int addUp();
}

?

?

?

package com.easyway.tbs;

/**
?* 本地接口
?* @author longgangbai
?*
?*/
public interface LocalOperation? extends Operation{
?
}

?

?

package com.easyway.tbs;

import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateful;
//备注此处为JBoss自带的注解
//import org.jboss.ejb3.annotation.LocalBinding;
//import org.jboss.ejb3.annotation.RemoteBinding;

@Stateful(mappedName="OperationBeanRemote")? //指定为有状态bean weblogic10/Sun Application/Glassfish本地访问的客户端 OperationBeanRemote#com.easyway.tbs。
@Remote({Operation.class})
//@RemoteBinding(jndiBinding="ejb/Operation") //JBoss绑定远程访问的名称
@Local(LocalOperation.class)
//@LocalBinding(jndiBinding="ejb/LocalOperation") //JBoss绑定本地访问的名称
public class OperationBean implements Operation,LocalOperation{
??? private int total=0;
?@Override
?public int addUp() {
??total++;
??return total;
??
?}

}

读书人网 >软件架构设计

热点推荐