?? requestprocessor.java
字號:
/* */package com.sun.j2ee.workflow.control.web;import java.util.*;import javax.servlet.ServletContext;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpSession;import java.io.*;import com.sun.j2ee.workflow.util.Debug;import com.sun.j2ee.workflow.util.WebKeys;import com.sun.j2ee.workflow.control.exceptions.WorkflowActionException;import com.sun.j2ee.workflow.control.web.ScreenFlowManager;import com.sun.j2ee.workflow.control.actions.ActionHandler;/** * @author Jian (James) Cai */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) throws WorkflowActionException, IOException { HashMap event = getEvent(request); String selectedUrl = request.getPathInfo(); Debug.println("RequestProcessor: processRequest: " + selectedUrl); /* 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); } */ ActionHandler handler = getHandler(selectedUrl); if (handler != null) { handler.setServletContext(context); //set the servlet context for handler handler.setServletRequest(request); handler.doStart(); //try{ handler.perform(event); /* } catch (Exception ex) { Debug.println("RequestProcessor caught handler perform(): " + ex); throw ex; } */ handler.doEnd(); } } /** * This method load the necessary ActionHandler class necessary to process a the * request for the specified URL. */ private ActionHandler getHandler(String selectedUrl) { ActionHandler handler = null; URLMapping urlMapping = getURLMapping(selectedUrl); String requestProcessorString = null; if (urlMapping != null) { requestProcessorString = urlMapping.getActionHandler(); if (urlMapping.useActionHandler()) { try { //handler = (ActionHandler)getClass().getClassLoader().loadClass(requestProcessorString).newInstance(); handler = (ActionHandler)Class.forName(requestProcessorString).newInstance(); Debug.println("RequestProcessor: loaded handler " + requestProcessorString); } catch (Exception ex) { Debug.println("RequestProcessor caught loading handler: " + ex); } } } return handler; } private HashMap getEvent(HttpServletRequest request) { HashMap event = new HashMap(); String parmName = null; String parmValue = null; for (Enumeration enum = request.getParameterNames() ; enum.hasMoreElements() ;) { parmName = (String)enum.nextElement(); Debug.println("getEvent: "+ parmName); parmValue = request.getParameter(parmName); Debug.println("getEvent: "+ parmValue); event.put(parmName, parmValue); } event.put("session", request.getSession()); return event; }}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -