package headfirst;
import javax.ejb.*;
public class AdviceBean implements SessionBean {
// OK, not very exciting advice! You should come up with something better...
private String[] adviceStrings = {"test", "test1", "test2", "test3"};
public void ejbActivate() {
System.out.println("ejb activate");
}
public void ejbPassivate() {
System.out.println("ejb passivate");
}
public void ejbRemove() {
System.out.println("ejb remove");
}
public void setSessionContext(SessionContext ctx) {
System.out.println("session context");
}
// this business method name is changed from the book, because
// there of a bug on some versions of the J2EE RI
public String getMessage() {
System.out.println("in get advice");
int random = (int) (Math.random() * adviceStrings.length);
return adviceStrings[random];
}
public void ejbCreate() {
System.out.println("in ejb create");
}
} |