刚开始学习ejb,依据基本原理编写一个ejb小例子,有想学习ejb的欢迎大家一块学习指导!
my QQ
243067750
1 新建ejb项目
1、Remote(或Local)接口
package com.terry.ejbsample;
import java.rmi.RemoteException;
import javax.ejb.EJBObject;
public interface Hello extends EJBObject {
public String getHello(String s) throws RemoteException;//远程调用的接口方法
}
2、Home(或LocalHome)接口
package com.terry.ejbsample;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBHome;
public interface HelloHome extends EJBHome {
Hello create() throws RemoteException, CreateException;
}
3、企业Bean ,具体的业务实现类
package com.terry.ejbsample;
import javax.ejb.CreateException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
public class HelloBean implements SessionBean {
public String getHello(String s) { //具体的业务实现方法
return s;
}