EJB 2 工作流程图 import javax.ejb.EJBHome;
import javax.ejb.CreateException;
import java.rmi.RemoteException;
public interface HelloHome extends EJBHome {
public Hello create() throws CreateException, RemoteException;
}
---------------------------------------------------
import javax.ejb.EJBObject;
import java.rmi.RemoteException;
public interface Hello extends EJBObject {
public String sayHello() throws RemoteException;
}
---------------------------------------------------
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import javax.ejb.CreateException;
import java.sql.*;
public class HelloBean implements SessionBean {
SessionContext sessionContext;
public void ejbCreate() throws CreateException {
System.out.println("ejbCreate()");
}
public void ejbRemove() {
System.out.println("ejbRemove()");
}
public void ejbActivate() {
System.out.println("ejbActivate()");
}
public void ejbPassivate() {
System.out.println("ejbPassivate()");
}
public void setSessionContext(SessionContext sessionContext) {
this.sessionContext = sessionContext;
}
public String sayHello() {
return "欢迎来到EJB世界!";
}
}