@Override protected synchronized RequestProcessor getRequestProcessor(ModuleConfig moduleConfig) throws ServletException { ServletContext servletContext = getServletContext(); String key = Globals.REQUEST_PROCESSOR_KEY + moduleConfig.getPrefix(); RequestProcessor requestProcessor = (RequestProcessor) servletContext.getAttribute(key); if (requestProcessor == null) { ControllerConfig controllerConfig = moduleConfig.getControllerConfig(); try { requestProcessor = (RequestProcessor) InstanceFactory.newInstance( ClassLoaderUtil.getPortalClassLoader(), controllerConfig.getProcessorClass()); } catch (Exception e) { throw new ServletException(e); } requestProcessor.init(this, moduleConfig); servletContext.setAttribute(key, requestProcessor); } return requestProcessor; }
/** * Initialize this request processor instance. * * @param servlet The ActionServlet we are associated with * @param moduleConfig The ModuleConfig we are associated with. * @throws ServletException If an error occurs during initialization */ public void init(ActionServlet servlet, ModuleConfig moduleConfig) throws ServletException { LOG.info( "Initializing composable request processor for module prefix '" + moduleConfig.getPrefix() + "'"); super.init(servlet, moduleConfig); initCatalogFactory(servlet, moduleConfig); ControllerConfig controllerConfig = moduleConfig.getControllerConfig(); String catalogName = controllerConfig.getCatalog(); catalog = this.catalogFactory.getCatalog(catalogName); if (catalog == null) { throw new ServletException("Cannot find catalog '" + catalogName + "'"); } String commandName = controllerConfig.getCommand(); command = catalog.getCommand(commandName); if (command == null) { throw new ServletException("Cannot find command '" + commandName + "'"); } this.setActionContextClassName(controllerConfig.getProperty(ACTION_CONTEXT_CLASS)); }
/** * Check to see if the controller is configured to prevent caching, and if so, request no cache * flags to be set. * * @param actionCtx The <code>Context</code> for the current request * @return <code>false</code> so that processing continues * @throws Exception if thrown by the Action class */ public boolean execute(ActionContext actionCtx) throws Exception { // Retrieve the ModuleConfig instance ModuleConfig moduleConfig = actionCtx.getModuleConfig(); // If the module is configured for no caching, request no caching if (moduleConfig.getControllerConfig().getNocache()) { requestNoCache(actionCtx); } return CONTINUE_PROCESSING; }
/** * Check to see if the content type is set, and if so, set it for this response. * * @param actionCtx The <code>Context</code> for the current request * @return <code>false</code> so that processing continues * @throws Exception if thrown by the Action class */ public boolean execute(ActionContext actionCtx) throws Exception { // Retrieve the ModuleConfig instance ModuleConfig moduleConfig = actionCtx.getModuleConfig(); // If the content type is configured, set it for the response String contentType = moduleConfig.getControllerConfig().getContentType(); if (contentType != null) { setContentType(actionCtx, contentType); } return (false); }