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(); }
/** * @param servletContext * @throws ServletException */ private DWRAction(ServletContext servletContext) throws ServletException { DispatcherUtils.initialize(servletContext); wwDispatcher = DispatcherUtils.getInstance(); actionProcessor = loadActionProcessor(servletContext.getInitParameter(DWRACTIONPROCESSOR_INIT_PARAM)); }
/** * @see javax.portlet.GenericPortlet#destroy() */ public void destroy() { // WW-1395 super.destroy(); DispatcherUtils dispatcherUtils = DispatcherUtils.getInstance(); if (dispatcherUtils == null) { LOG.warn("something is seriously wrong, DispatcherUtil is not initialized (null) "); } else { dispatcherUtils.cleanup(); } }
DispatcherUtils du = DispatcherUtils.getInstance(); du.prepare(request, response);
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);
DispatcherUtils du = DispatcherUtils.getInstance(); du.prepare(request, response); try {
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; }
/** * 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); }
Map session = new SessionMap(req); Map application = new ApplicationMap(servletContext); DispatcherUtils du = DispatcherUtils.getInstance(); HashMap ctx = du.createContextMap(requestMap, params,