cartbean.java

来自「MICO2.3.13 corba 环境平台」· Java 代码 · 共 69 行

JAVA
69
字号
package examples;import java.util.*;import javax.ejb.*;public class CartBean implements SessionBean {   String customerName;   String customerId;   Vector contents;   public void ejbCreate(String person) throws CreateException {      if (person == null) {        throw new CreateException("Null person not allowed.");      }      else {         customerName = person;      }      customerId = "0";      contents = new Vector();   }   public void ejbCreate(String person, String id) throws CreateException {      if (person == null) {        throw new CreateException("Null person not allowed.");      }      else {         customerName = person;      }      IdVerifier idChecker = new IdVerifier();      if (idChecker.validate(id)) {         customerId = id;      }      else {         throw new CreateException("Invalid id: " + id);      }      contents = new Vector();   }   public void addBook(String title) {      contents.addElement(title);   }   public void removeBook(String title) throws BookException {      boolean result = contents.removeElement(title);      if (result == false) {         throw new BookException(title + " not in cart.");      }   }   public String[] getContents() {      return (String[])contents.toArray(new String[contents.size()]);   }   public CartBean() {}   public void ejbRemove() {}   public void ejbActivate() {}   public void ejbPassivate() {}   public void setSessionContext(SessionContext sc) {}} 

⌨️ 快捷键说明

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