?? actionprocessor.java~
字號:
/* */package com.sun.j2ee.workflow.control.web;import java.util.Collection;import java.util.HashMap;import javax.servlet.ServletContext;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import javax.servlet.http.HttpSession;import java.io.*;import java.rmi.RemoteException;import com.sun.j2ee.workflow.util.Debug;import com.sun.j2ee.workflow.util.WebKeys;import com.sun.j2ee.workflow.control.exceptions.StarsEventException;import com.sun.j2ee.workflow.control.web.ScreenFlowManager;import com.sun.j2ee.workflow.control.web.actions.RequestHandler;/** * */public class RequestProcessor implements java.io.Serializable { private ServletContext context; private HashMap urlMappings; /** Empty constructor for use by the JSP engine. */ public RequestProcessor() {} public void init(ServletContext context) { this.context = context; urlMappings = (HashMap)context.getAttribute(WebKeys.URLMappingsKey); } /** */ private URLMapping getURLMapping(String urlPattern) { if ((urlMappings != null) && urlMappings.containsKey(urlPattern)) { return (URLMapping)urlMappings.get(urlPattern); } else { return null; } } /** * This method is the core of the RequestProcessor. It receives all requests * and generates the necessary events. */ public void processRequest(HttpServletRequest request, HttpServletResponse response) throws StarsEventException, IOException { StarsEvent event = null; String selectedUrl = request.getPathInfo(); String checkresult = null; //to check the access control PrintWriter out = response.getWriter(); ModelManager mm = (ModelManager)request.getSession().getAttribute(WebKeys.ModelManagerKey); // application level ModelManager AppModelManager apmm = (AppModelManager)context.getAttribute(WebKeys.AppModelManagerKey); // application level checkermanager CheckerManager chm = (CheckerManager)context.getAttribute(WebKeys.CheckerManagerKey); UserHandlerWebImpl ucrwimpl = (UserHandlerWebImpl)request.getSession().getAttribute(WebKeys.WebHandlerKey); if (ucrwimpl == null) { ucrwimpl = new UserHandlerWebImpl(request.getSession()); mm.setURC(ucrwimpl); request.getSession().setAttribute(WebKeys.WebHandlerKey, ucrwimpl); } RequestHandler handler = getHandler(selectedUrl); if (handler != null) { handler.setServletContext(context); handler.doStart(request); event = handler.processRequest(request); //check the consistency for this even if (event != null) { checkresult = chm.checkEvent(event); if(checkresult.equals("OK")) { chm.doStart(event); //update model state Collection updatedModelList = ucrwimpl.handleEvent(event); mm.notifyListeners(updatedModelList); apmm.notifyListeners(updatedModelList); chm.doEnd(event); //reset model state } out.println(checkresult); } handler.doEnd(request); } out.close(); } /** * This method load the necessary RequestHandler class necessary to process a the * request for the specified URL. */ private RequestHandler getHandler(String selectedUrl) { RequestHandler handler = null; URLMapping urlMapping = getURLMapping(selectedUrl); String requestProcessorString = null; if (urlMapping != null) { requestProcessorString = urlMapping.getRequestHandler(); if (urlMapping.useRequestHandler()) { try { Debug.println("RequestProcessor: loading handler " + requestProcessorString); handler = (RequestHandler)getClass().getClassLoader().loadClass(requestProcessorString).newInstance(); Debug.println("RequestProcessor: loaded handler " + requestProcessorString); } catch (Exception ex) { Debug.println("RequestProcessor caught loading handler: " + ex); } } } return handler; }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -