/** * @param servletContext * @throws ServletException */ private DWRAction(ServletContext servletContext) throws ServletException { DispatcherUtils.initialize(servletContext); wwDispatcher = DispatcherUtils.getInstance(); actionProcessor = loadActionProcessor(servletContext.getInitParameter(DWRACTIONPROCESSOR_INIT_PARAM)); }
public static void initialize(ServletContext servletContext) { synchronized (DispatcherUtils.class) { if (instance == null) { instance = new DispatcherUtils(servletContext); } } }
public void destroy() { DispatcherUtils du = DispatcherUtils.getInstance(); // should not be null as it is initialized in init(FilterConfig) if (du == null) { LOG.warn("something is seriously wrong, DispatcherUtil is not initialized (null) "); } du.cleanup(); }
public static OgnlValueStack getStack(PageContext pageContext) { HttpServletRequest req = (HttpServletRequest) pageContext.getRequest(); OgnlValueStack stack = (OgnlValueStack) req.getAttribute(ServletActionContext.WEBWORK_VALUESTACK_KEY); if (stack == null) { stack = new OgnlValueStack(); HttpServletResponse res = (HttpServletResponse) pageContext.getResponse(); DispatcherUtils.initialize(pageContext.getServletContext()); DispatcherUtils du = DispatcherUtils.getInstance(); Map extraContext = du.createContextMap(new RequestMap(req), req.getParameterMap(), new SessionMap(req), new ApplicationMap(pageContext.getServletContext()), req, res, pageContext.getServletContext()); extraContext.put(ServletActionContext.PAGE_CONTEXT, pageContext); stack.getContext().putAll(extraContext); req.setAttribute(ServletActionContext.WEBWORK_VALUESTACK_KEY, stack); // also tie this stack/context to the ThreadLocal ActionContext.setContext(new ActionContext(stack.getContext())); } else { // let's make sure that the current page context is in the action context Map context = stack.getContext(); context.put(ServletActionContext.PAGE_CONTEXT, pageContext); AttributeMap attrMap = new AttributeMap(context); context.put("attr", attrMap); } return stack; }
DispatcherUtils du = DispatcherUtils.getInstance(); du.prepare(request, response); request = du.wrapRequest(request, getServletContext()); } catch (IOException e) { String message = "Could not wrap servlet request with MultipartRequestWrapper!"; du.serviceAction(request, response, getServletContext(), mapping);
DispatcherUtils du = DispatcherUtils.getInstance(); du.prepare(request, response); request = du.wrapRequest(request, servletContext); } catch (IOException e) { String message = "Could not wrap servlet request with MultipartRequestWrapper!";
/** * Applies the decorator, creating the relevent contexts and delegating to * the extended applyDecorator(). * * @param page The page * @param decorator The decorator * @param req The servlet request * @param res The servlet response */ protected void applyDecorator(Page page, Decorator decorator, HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { ServletContext servletContext = filterConfig.getServletContext(); ActionContext ctx = ServletActionContext.getActionContext(req); if (ctx == null) { // ok, one isn't associated with the request, so let's get a ThreadLocal one (which will create one if needed) OgnlValueStack vs = new OgnlValueStack(); vs.getContext().putAll(DispatcherUtils.getInstance().createContextMap(req, res, null, servletContext)); ctx = new ActionContext(vs.getContext()); if (ctx.getActionInvocation() == null) { // put in a dummy ActionSupport so basic functionality still works ActionSupport action = new ActionSupport(); vs.push(action); ctx.setActionInvocation(new DummyActionInvocation(action)); } } // delegate to the actual page decorator applyDecorator(page, decorator, req, res, servletContext, ctx); }
public void init(FilterConfig filterConfig) throws ServletException { this.filterConfig = filterConfig; DispatcherUtils.initialize(filterConfig.getServletContext()); }
Map extraContext = createContextMap(request, response, mapping, context); sendError(request, response, context, HttpServletResponse.SC_NOT_FOUND, e); } catch (Exception e) { throw new ServletException(e);
public Map createContextMap(HttpServletRequest request, HttpServletResponse response, ActionMapping mapping, ServletContext context) { // request map wrapping the http request objects Map requestMap = new RequestMap(request); // parameters map wrapping the http paraneters. Map params = null; if (mapping != null) { params = mapping.getParams(); } Map requestParams = new HashMap(request.getParameterMap()); if (params != null) { params.putAll(requestParams); } else { params = requestParams; } // session map wrapping the http session Map session = new SessionMap(request); // application map wrapping the ServletContext Map application = new ApplicationMap(context); return createContextMap(requestMap, params, session, application, request, response, context); }
/** * Wraps and returns the given response or returns the original response object. This is used to transparently * handle multipart data as a wrapped class around the given request. Override this method to handle multipart * requests in a special way or to handle other types of requests. Note, {@link com.opensymphony.webwork.dispatcher.multipart.MultiPartRequestWrapper} is * flexible - you should look to that first before overriding this method to handle multipart data. * * @param request the HttpServletRequest object. * @return a wrapped request or original request. * @see com.opensymphony.webwork.dispatcher.multipart.MultiPartRequestWrapper */ public HttpServletRequest wrapRequest(HttpServletRequest request, ServletContext servletContext) throws IOException { // don't wrap more than once if (request instanceof WebWorkRequestWrapper) { return request; } if (MultiPartRequest.isMultiPart(request)) { request = new MultiPartRequestWrapper(request, getSaveDir(servletContext), getMaxSize()); } else { request = new WebWorkRequestWrapper(request); } return request; }
/** * */ protected AjaxResult doExecute(ActionDefinition actionDefinition, Map<String, String> params, HttpServletRequest request, HttpServletResponse response, ServletContext servletContext) throws ServletException { FakeHttpServletResponse actionResponse = new FakeHttpServletResponse(); if (null != actionProcessor) { actionProcessor.preProcess(request, response, actionResponse, params); } wwDispatcher.prepare(request, actionResponse); ActionInvocation invocation = invokeAction(wwDispatcher, request, actionResponse, servletContext, actionDefinition, params); AjaxResult result; if (actionDefinition.isExecuteResult()) { // HINT: we have output string result = getTextResult(actionResponse); } else { result = new DefaultAjaxDataResult(invocation.getAction()); } if (null != actionProcessor) { actionProcessor.postProcess(request, response, actionResponse, result); } return result; }
private void includeGetParameters() { if(!(DispatcherUtils.isPortletSupportActive() && PortletActionContext.isPortletRequest())) { String query = extractQueryString(); mergeRequestParameters(value, parameters, UrlHelper.parseQueryString(query)); } }
protected DispatcherUtils(ServletContext servletContext) { init(servletContext); }
private Map createExtraContext() { Map parentParams = null; if (!ignoreContextParams) { parentParams = new ActionContext(getStack().getContext()).getParameters(); } Map newParams = (parentParams != null) ? new HashMap(parentParams) : new HashMap(); if (parameters != null) { newParams.putAll(parameters); } ActionContext ctx = new ActionContext(stack.getContext()); ServletContext servletContext = (ServletContext) ctx.get(ServletActionContext.SERVLET_CONTEXT); PageContext pageContext = (PageContext) ctx.get(ServletActionContext.PAGE_CONTEXT); Map session = ctx.getSession(); Map application = ctx.getApplication(); DispatcherUtils.initialize(servletContext); DispatcherUtils du = DispatcherUtils.getInstance(); Map extraContext = du.createContextMap(new RequestMap(req), newParams, session, application, req, res, servletContext); OgnlValueStack newStack = new OgnlValueStack(stack); extraContext.put(ActionContext.VALUE_STACK, newStack); // add page context, such that ServletDispatcherResult will do an include extraContext.put(ServletActionContext.PAGE_CONTEXT, pageContext); return extraContext; }
DispatcherUtils du = DispatcherUtils.getInstance(); du.prepare(request, response); try { request = du.wrapRequest(request, servletContext); } catch (IOException e) { String message = "Could not wrap servlet request with MultipartRequestWrapper!"; o = beforeActionInvocation(request, servletContext); du.serviceAction(request, response, servletContext, mapping); } finally { afterActionInvocation(request, servletContext, o);
Map session = new SessionMap(req); Map application = new ApplicationMap(servletContext); DispatcherUtils du = DispatcherUtils.getInstance(); HashMap ctx = du.createContextMap(requestMap, params, session,
public void init(FilterConfig filterConfig) throws ServletException { this.filterConfig = filterConfig; String param = filterConfig.getInitParameter("packages"); String packages = "com.opensymphony.webwork.static template com.opensymphony.webwork.interceptor.debugging"; if (param != null) { packages = param + " " + packages; } this.pathPrefixes = parse(packages); DispatcherUtils.initialize(filterConfig.getServletContext()); }
Map<String, Object> extraContext = du.createContextMap(request, response, mapping, context);
if(DispatcherUtils.isPortletSupportActive() && PortletActionContext.isPortletRequest()) { result = PortletUrlHelper.buildUrl(action, namespace, parameters, portletUrlType, portletMode, windowState); if(DispatcherUtils.isPortletSupportActive() && PortletActionContext.isPortletRequest()) { result = PortletUrlHelper.buildResourceUrl(value, parameters);