import java.rmi.RemoteException; import javax.ejb.*; public class MyEJBClass implements SessionBean {
public MyEJBClass() { } //定义在SessionBean 中的方法 public void ejbCreate() throws RemoteException, CreateException { }
public void ejbActivate() throws RemoteException { }
public void ejbPassivate() throws RemoteException { }
public void ejbRemove() throws RemoteException { }
public void setSessionContext(SessionContext ctx) throws RemoteException {
}
//此处是具体的实现
public String sayHello()
{
System.out.println("Hello"); } } 第四步,写一个发布用的配置文件ejb-jar.xml 需要提供的信息: Bean Home name -- The nickname that clients use to lookup your bean's home object. Enterprise bean class name -- The fully qualified name of the enterpri se bean class. Home interface class name Remote interface class name Re-entrant -- Whether the enterprise bean allow re-entrant calls. This setting must be false for session beans(it applies to entity beans on ly) stateful or stateless Session timeout -- The length of time (in seconds) before a client should time out when calling methods on your bean. 最后你还可以提供属于自己的配置信息供自己控制EJB的工作方式。