University of Cincinnati logo and link  
The Bean Class
 
  UC ingot The bean contains the business logic of the program.  This is where the action is.
    • Our example will be a session bean, so it implements javax.ejb.SessionBean .
    • We must implement the four methods specified in SessionBean.
      • These methods are called by the container, not by us, and they are generally informational in nature.
      • So, our implementation of these methods need not be robust.
    • We also implement the sayHello method we defined, and an ejbCreate method.
public class HelloBean implements javax.ejb.SessionBean {

  private SessionContext ctx;

  public void ejbCreate() {
     System.out.println("In ejbCreate.");
  }
 

  public void ejbRemove() {
     System.out.println("In ejbRemove");
  }

  public void ejbActivate() {
     System.out.println("In ejbActivate");
  }

  public void ejbPassivate() {
     System.out.println("In ejbPassivate");
  }

  public void setSessionContext(javax.ejb.SessionContext ctx) 
  {
     this.ctx = ctx;
  }

  public String sayHello() {
     System.out.println("sayHello()");
     return "Hello Whirled!";
  }
}
    
 The Deployment Descriptor