📄 orderwebimpl.java
字号:
package apusic.myshop.order.web;/** * This class is the web-tier representation of the order. * It is used in the web tier to get an order that has been * placed. The requestId represents the order that has been * placed. If no order has been placed the requestId will * remain as -l. */import java.rmi.RemoteException;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpSession;import apusic.myshop.control.web.ModelManager;import apusic.myshop.control.web.ModelUpdateListener;import apusic.myshop.order.ejb.Order;import apusic.myshop.util.WebKeys;import apusic.myshop.order.model.OrderModel;import apusic.myshop.util.Debug;import apusic.myshop.control.GeneralFailureException;public class OrderWebImpl extends OrderModel implements ModelUpdateListener { private ModelManager mm; private Order orderEjb; private HttpSession session; private int requestId = -1; public OrderWebImpl() { super(); } public void init(HttpServletRequest request){ this.session = request.getSession(); Integer id = (Integer)request.getAttribute(WebKeys.RequestIdKey); if (id != null) requestId = id.intValue(); this.mm = (ModelManager)session.getAttribute("modelManager"); syncUpData(); } private void syncUpData() { // Get data from the EJB if (orderEjb == null && requestId != -1) { orderEjb = mm.getOrderEJB(requestId); } // Using XOR to assert that either requestId == -1 or EJB is non null. Debug.assert((requestId == -1) ^ (orderEjb != null)); try { if (orderEjb != null) copy(orderEjb.getDetails()); } catch (RemoteException re) { throw new GeneralFailureException(re); } } public void performUpdate(){ // do nothing - this is a request scope bean }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -