⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 savingaccountbean.java

📁 我在加拿大学习的一个比较复杂的在线银行程序.
💻 JAVA
字号:
package com.ebusiness.ebank.ejb.entitybean;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2005</p> * <p>Company: eBusiness Inc., All right reserved</p> * @author unascribed * @version 1.0 */import java.sql.Timestamp;import javax.ejb.EntityBean;import javax.ejb.CreateException;import javax.ejb.EntityContext;import com.ebusiness.ebank.bean.SavingAccountValue;import com.ebusiness.ebank.exception.BusinessException;//import com.ebusiness.ebank.exception.SystemException;import com.ebusiness.ebank.exception.ErrorMessages;abstract public class SavingAccountBean implements EntityBean{    private EntityContext ctx;    abstract public Long getObjectID();    abstract public void setObjectID(Long oid);    abstract public String getAccountNo();    abstract public void setAccountNo(String accountNo);    abstract public String getAccountType();    abstract public void setAccountType(String accountType);    abstract public String getClientCardID();    abstract public void setClientCardID(String clientCardID);    abstract public int getAnnualFee();    abstract public void setAnnualFee(int annualFee);    abstract public int getMinimumBalance();    abstract public void setMinimumBalance(int minimumBalance);    abstract public int getFreeServiceLimit();    abstract public void setFreeServiceLimit(int freeServiceLimit);    abstract public int getFixedServiceFee();    abstract public void setFixedServiceFee(int fixedServiceFee);    abstract public double getInterestRate();    abstract public void setInterestRate(double interestRate);    abstract public double getBalance();    abstract public void setBalance(double balance);    abstract public Timestamp getEffectiveDate();    abstract public void setEffectiveDate(Timestamp effectiveDate);    abstract public Timestamp getExpiryDate();    abstract public void setExpiryDate(Timestamp expiryDate);    abstract public String getCreateUserID();    abstract public void setCreateUserID(String createUserID);    abstract public Timestamp getCreateDate();    abstract public void setCreateDate(Timestamp createDate);    abstract public String getUpdateUserID();    abstract public void setUpdateUserID(String updateUserID);    abstract public Timestamp getUpdateDate();    abstract public void setUpdateDate(Timestamp expiryDate);    abstract public String getStatus();    abstract public void setStatus(String status);    abstract public String getAction();    abstract public void setAction(String action);    // Business methods    public long getAccountOID()    {        return this.getObjectID().longValue();    }    /**     * Parse the entity bean value to ChequingAccountValue object     *     * @return ChequingAccountValue     */    public SavingAccountValue getValueObject()    {        SavingAccountValue value = new SavingAccountValue();        value.setObjectID(this.getObjectID().longValue());        value.setAccountNo(this.getAccountNo());        value.setAccountType(this.getAccountType());        value.setClientCardID(this.getClientCardID());        value.setAnnualFee(this.getAnnualFee());        value.setMinimumBalance(this.getMinimumBalance());        value.setFreeServiceLimit(this.getFreeServiceLimit());        value.setFixedServiceFee(this.getFixedServiceFee());        value.setInterestRate(this.getInterestRate());        value.setBalance(this.getBalance());        value.setStatus(this.getStatus());        //common values        value.setEffectiveDate(this.getEffectiveDate());        value.setExpiryDate(this.getExpiryDate());        value.setCreateUserID(this.getCreateUserID());        value.setCreateDate(this.getCreateDate());        value.setUpdateUserID(this.getUpdateUserID());        value.setUpdateDate(this.getUpdateDate());        value.setAction(this.getAction());        return value;    }    //deposit money from the account    public void deposit(double amount) throws BusinessException    {        if (!"V".equals(this.getStatus())) //the account is not Valid           throw new BusinessException(ErrorMessages.INVALID_ACCOUNT);        this.setBalance(this.getBalance() + amount);    }    //withdrawal money from the account    public void withdrawal(double amount) throws BusinessException    {        if (!"V".equals(this.getStatus())) //the account is not Valid           throw new BusinessException(ErrorMessages.INVALID_ACCOUNT);        double newBalance = this.getBalance() - amount;        if (newBalance < this.getMinimumBalance())           throw new BusinessException(ErrorMessages.EXCEED_LIMIT);        this.setBalance(newBalance);    }    /**     * Update VisaAccount     *     * @param value :    ChequingAccountValue     * @return      :    updated ChequingAccountValue     */    public SavingAccountValue update(SavingAccountValue value)    {        this.setAnnualFee(value.getAnnualFee());        this.setMinimumBalance(value.getMinimumBalance());        this.setFreeServiceLimit(value.getFreeServiceLimit());        this.setFixedServiceFee(value.getFixedServiceFee());        this.setInterestRate(value.getInterestRate());        this.setBalance(value.getBalance());        //common values        this.setEffectiveDate(new Timestamp(value.getEffectiveDate().getTime()));        this.setExpiryDate(new Timestamp(value.getExpiryDate().getTime()));        String userID = this.ctx.getCallerPrincipal().getName();        this.setUpdateUserID(userID);        return this.getValueObject();    }    // Framework and lifecycle methods    //This method will insert a record to the Chequing_Account table.    public Long ejbCreate(SavingAccountValue value)         throws CreateException    {        this.setAccountNo(value.getAccountNo());        this.setAccountType(value.getAccountType());        this.setClientCardID(value.getClientCardID());        this.setAnnualFee(value.getAnnualFee());        this.setMinimumBalance(value.getMinimumBalance());        this.setFreeServiceLimit(value.getFreeServiceLimit());        this.setFixedServiceFee(value.getFixedServiceFee());        this.setInterestRate(value.getInterestRate());        this.setBalance(value.getBalance());        //common values        this.setEffectiveDate(new Timestamp(value.getEffectiveDate().getTime()));        this.setExpiryDate(new Timestamp(value.getExpiryDate().getTime()));        String userID = this.ctx.getCallerPrincipal().getName();        this.setCreateUserID(userID);        this.setUpdateUserID(userID);        this.setStatus(value.getStatus());        return null; //for container managed persistence    }    public void ejbPostCreate(SavingAccountValue value) {}    public void ejbActivate() {}    public void ejbLoad() {}    public void ejbPassivate() {}    public void ejbRemove() //this method will delete the record from database    {        //Log.info("An Acocunt with ID = " + "" + " is being deleted from database");    }    public void ejbStore() {}    public void setEntityContext(EntityContext ctx)    {        this.ctx = ctx;    }    public void unsetEntityContext() {}}

⌨️ 快捷键说明

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