5497l2.txt

Listing 2. CalculatorBean.java, the Bean Class for Our EJB Calculator

package il.co.lerner.calculator;

import java.rmi.RemoteException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;

public class CalculatorBean implements SessionBean
{
    // This version of multiply() handles integers
    public int multiply(int num1, int num2)
    {
        System.out.println("Multiply invoked with ints '", +
                           num1 + "' and '" + num2 + "'.");
        return num1 * num2;
    }

    // ejbCreate -- we don't need this for our session bean
    public void ejbCreate() {}

    // ejbRemote -- we don't need this for our session bean
    public void ejbRemove() {}

    // ejbActivate -- we don't need this for our session bean
    public void ejbActivate() {}

    // ejbActivate -- we don't need this for our session bean
    public void ejbPassivate() {}

    // setSessionContext -- we don't need this for our session bean
    public void setSessionContext(SessionContext sc) {}
}
