Developing EJBs (continued)… Define Session Beans
public class TellerBean implements SessionBean {
protected SessionContext _sessionContext;
public CheckingsHome checkingsHome;
public SavingsHome savingsHome;
public Checkings createCheckingsAccount(String name, double amount) throws Exception
{ return checkingsHome.create(name, amount); }
public Savings createSavingsAccount(String name, double amount) throws Exception
{ return savingsHome.create(name, amount); }
public void TransferMoney(double amount,int fromAccount,int toAccount) throws Exception
{ /*. . . Do something . . .*/ }
// Container managed beans return void - can have many create methods
public void ejbCreate() throws Exception {}
// these methods are required by the SessionBean interface
public void ejbActivate () throws RemoteException {}
public void ejbPassivate() throws RemoteException {}
public void ejbRemove () throws RemoteException, RemoveException {}
public void setSessionContext(SessionContext context) throws RemoteException {
this._sessionContext = context;
checkingsHome = (CheckingsHome)Naming.lookup("Checkings");
savingsHome = (SavingsHome)Naming.lookup("Savings");
}catch (Exception ex) {System.out.println(e));