ejbaccountsbean.java~33~

来自「一个J2EE四层架构的实例」· JAVA~33~ 代码 · 共 85 行

JAVA~33~
85
字号
package sqlaccounts;import java.io.Serializable;import java.util.Enumeration;import java.util.Vector;import javax.ejb.CreateException;import javax.ejb.DuplicateKeyException;import javax.ejb.EJBException;import javax.ejb.EntityBean;import javax.ejb.EntityContext;import javax.ejb.FinderException;import javax.ejb.NoSuchEntityException;import javax.ejb.ObjectNotFoundException;import javax.ejb.RemoveException;import javax.naming.InitialContext;import javax.naming.NamingException;import javax.sql.DataSource;abstract public class EjbAccountsBean implements EntityBean {  EntityContext entityContext;  public java.lang.String ejbCreate(java.lang.String id, String Type, double bal) throws CreateException {    setId(id);    setType(Type);    setBal(bal);    return null;  }  public java.lang.String ejbCreate(String Id) throws CreateException {    /**@todo Complete this method*/    setId(Id);    return null;  }  public void ejbPostCreate(java.lang.String id, String Type, double bal) throws CreateException {    /**@todo Complete this method*/  }  public void ejbPostCreate(String Id) throws CreateException {    /**@todo Complete this method*/  }  public void ejbRemove() throws RemoveException {    /**@todo Complete this method*/  }  public abstract void setId(java.lang.String id);  public abstract void setBal(double bal);  public abstract void setType(java.lang.String type);  public abstract java.lang.String getId();  public abstract double getBal();  public abstract java.lang.String getType();  public void ejbLoad() {    /**@todo Complete this method*/  }  public void ejbStore() {    /**@todo Complete this method*/  }  public void ejbActivate() {    /**@todo Complete this method*/  }  public void ejbPassivate() {    /**@todo Complete this method*/  }  public void unsetEntityContext() {    this.entityContext = null;  }  public void setEntityContext(EntityContext entityContext) {    this.entityContext = entityContext;  }  public double deposit(double bal) {    /**@todo Complete this method*/    setBal(getBal() + bal);    return getBal();  }  public double withdraw(double account) {    /**@todo Complete this method*/    log("AccountBean.withdraw: Withdrawing $" + account + " from '" +                               getId() + "'");   if (account > getBal()) {        log("Request to withdraw $" + account +                               "; is more than balance $" + getBal() +                               " in account " + getId());   }   setBal(getBal() - account);    return getBal();  }  private void log(String s) {    System.out.println(s);  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?