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

📄 shoppingclientcontrollerwebimpl.java

📁 一个优秀的供应商管理系统
💻 JAVA
字号:
package apusic.myshop.control.web;import java.util.Collection;import java.rmi.RemoteException;import javax.rmi.PortableRemoteObject;import javax.ejb.FinderException;import javax.ejb.CreateException;import javax.ejb.RemoveException;import javax.naming.NamingException;import javax.naming.InitialContext;import javax.servlet.http.HttpSession;import apusic.myshop.util.Debug;import apusic.myshop.util.JNDINames;import apusic.myshop.control.GeneralFailureException;import apusic.myshop.control.web.ModelManager;import apusic.myshop.cart.model.CartModel;import apusic.myshop.cart.ejb.Cart;import apusic.myshop.customer.ejb.Customer;import apusic.myshop.control.EventException;import apusic.myshop.control.event.BaseEvent;import apusic.myshop.order.ejb.Order;import apusic.myshop.order.model.OrderModel;/** * This class is essentially just a proxy object that calls methods on the * EJB tier using the com.sun.estore.control.ejb.ShoppingClientControllerEJB * object. All the methods that access the EJB are synchronized so * that concurrent requests do not happen to the stateful session bean. */  //EJB层的代理,代理CONTROL远程接口public class ShoppingClientControllerWebImpl {  private apusic.myshop.control.ejb.ShoppingClientController sccEjb;  private HttpSession session;  /**  * constructor for an HTTP client.  */  public ShoppingClientControllerWebImpl(HttpSession session) {    this.session = session;    ModelManager mm = (ModelManager)session.getAttribute("modelManager");    sccEjb = mm.getSCCEJB();//获得CONTROL组件的远程接口  }  public synchronized Collection handleEvent(BaseEvent be)	  throws EventException {    try {      return sccEjb.handleEvent(be);	  } catch (RemoteException re) {      throw new GeneralFailureException(re);    }  }  public synchronized Order getOrderEJB(int requestId) {	  try {	    return sccEjb.getOrder(requestId);	  } catch (RemoteException re) {      throw new GeneralFailureException(re);	  } catch (FinderException fe) {      throw new GeneralFailureException(fe);	  }  }  /**     * @param requestId the unique id used to place the order.     * @return the order placed by this user that corresponds to the     * unique requestId     * @exception com.sun.estore.control.GeneralFailureException     */    public synchronized OrderModel getOrder(int requestId) throws FinderException {	    try {	      return sccEjb.getOrder(requestId).getDetails();	    } catch (RemoteException re) {	      throw new GeneralFailureException(re);	    }    }    /**     * Just being faithful to the interface     * @return null always     * @exception com.sun.estore.control.GeneralFailureException     */    public Collection getOrders() {    	return null;    }  public synchronized Customer getCustomerEJB() {    try {      return sccEjb.getCustomer();    } catch (RemoteException re) {      throw new GeneralFailureException(re);    }  }  public synchronized Cart getCartEJB() {	  try {	    return sccEjb.getCart();	  } catch (RemoteException re) {      throw new GeneralFailureException(re);    }  }  /**  * frees up all the resources associated with this controller and  * destroys itself.  */  public synchronized void remove() {    // call ejb remove on self/shopping cart/etc.    try {      sccEjb.remove();    } catch(RemoveException re){      // ignore, after all its only a remove() call!      Debug.print(re);    } catch(RemoteException re){      // ignore, after all its only a remove() call!      Debug.print(re);    }  }}

⌨️ 快捷键说明

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