statefulfundmanagerejb.txt

来自「ejb的学习资料」· 文本 代码 · 共 36 行

TXT
36
字号
import  javax.ejb.*;
public class  StatefulFundManagerEJB   implements  SessionBean {
        double  amount;
        public  void  ejbRemove () { }
        public  void  ejbActive ()  { }
        public  void  ejbPassivate () { }
      public  void  setSessionContext ( SessionContext  sc ) { }
// Bean生成过程中,容器调用ejbCreate()方法。
public void ejbCreate(double amount) throws CreateException {
if  (amount <0) { 
               throw  new  CreateException ("Invalid  amount");
}else { 
               this.amont = amount;
             }
}
//用addFunds()方法存款时,如果amount<0,则存款失败,这是典型的业务方法。
public  void  addFunds (double amount) {
if ( amount ≤=0) {
                return;
            }
        this.amount +=amount;
}
// withdrawFunds()方法取款时,一旦发生账户余额不足,则取款失败。
    public  void  withdrawFunds( double amount ) 
        throws  InsufficientBalanceException {
            if ( this.amount < amount ) {
                throw (new InsufficientBalanceException());
              }
      this.amount -=amount;
          }
       public double  getBalance() {
        return  amount;
    }
}

⌨️ 快捷键说明

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