cartwebimpl.java

来自「一个优秀的供应商管理系统」· Java 代码 · 共 45 行

JAVA
45
字号
package apusic.myshop.cart.web;import javax.servlet.http.HttpSession;import java.rmi.RemoteException;import apusic.myshop.control.GeneralFailureException;import apusic.myshop.control.web.ModelUpdateListener;import apusic.myshop.control.web.ModelManager;import apusic.myshop.cart.ejb.Cart;import apusic.myshop.util.JNDINames;import apusic.myshop.cart.model.CartModel;public class CartWebImpl extends CartModel  implements ModelUpdateListener {  private ModelManager mm;  private Cart cartEjb;  public CartWebImpl() {    super(null);  }  public void init(HttpSession session) {	  // initializing super class with a null list. This means that	  // if because of some bug, this object gets referenced    // (typically in the JSP page) before performUpdate is called,    // a null pointer exception will get thrown.    this.mm = (ModelManager)session.getAttribute("modelManager");    mm.addListener(JNDINames.CART_EJBHOME, this);  }  public void performUpdate() {	  // Get data from the EJB    if (cartEjb == null) {      cartEjb = mm.getCartEJB();    }    try {      copy(cartEjb.getDetails());    } catch (RemoteException re) {      throw new GeneralFailureException(re);    }  }}

⌨️ 快捷键说明

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