Search in sources :

Example 1 with DefinitionsFactory

use of org.apache.struts.tiles.DefinitionsFactory in project sonar-java by SonarSource.

the class ReloadDefinitionsAction method execute.

/**
 * Process the specified HTTP request, and create the corresponding HTTP
 * response (or forward to another web component that will create it),
 * with provision for handling exceptions thrown by the business logic.
 *
 * @param mapping The ActionMapping used to select this instance
 * @param form The optional ActionForm bean for this request (if any)
 * @param request The HTTP request we are processing
 * @param response The HTTP response we are creating
 *
 * @exception Exception if the application business logic throws
 *  an exception
 * @since Struts 1.1
 */
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    response.setContentType("text/plain");
    PrintWriter writer = response.getWriter();
    try {
        ServletContext context = getServlet().getServletContext();
        DefinitionsFactory factory = TilesUtil.getDefinitionsFactory(request, context);
        factory.setConfig(factory.getConfig(), context);
        writer.println("OK");
    } catch (ClassCastException e) {
        writer.println("FAIL - " + e.toString());
        getServlet().log("ReloadAction", e);
    } catch (DefinitionsFactoryException e) {
        writer.println("FAIL - " + e.toString());
        getServlet().log("ReloadAction", e);
    }
    writer.flush();
    writer.close();
    return (null);
}
Also used : DefinitionsFactoryException(org.apache.struts.tiles.DefinitionsFactoryException) DefinitionsFactory(org.apache.struts.tiles.DefinitionsFactory) ServletContext(javax.servlet.ServletContext) PrintWriter(java.io.PrintWriter)

Example 2 with DefinitionsFactory

use of org.apache.struts.tiles.DefinitionsFactory in project sonar-java by SonarSource.

the class ViewDefinitionsAction method execute.

/**
 * Process the specified HTTP request, and create the corresponding HTTP
 * response (or forward to another web component that will create it),
 * with provision for handling exceptions thrown by the business logic.
 *
 * @param mapping The ActionMapping used to select this instance
 * @param form The optional ActionForm bean for this request (if any)
 * @param request The HTTP request we are processing
 * @param response The HTTP response we are creating
 *
 * @exception Exception if the application business logic throws
 *  an exception
 * @since Struts 1.1
 */
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    response.setContentType("text/plain");
    PrintWriter writer = response.getWriter();
    try {
        ServletContext context = getServlet().getServletContext();
        DefinitionsFactory factory = TilesUtil.getDefinitionsFactory(request, context);
        writer.println(factory.toString());
    } catch (Exception e) {
        writer.println("FAIL - " + e.toString());
        getServlet().log("ReloadAction", e);
    }
    writer.flush();
    writer.close();
    return (null);
}
Also used : DefinitionsFactory(org.apache.struts.tiles.DefinitionsFactory) ServletContext(javax.servlet.ServletContext) PrintWriter(java.io.PrintWriter)

Example 3 with DefinitionsFactory

use of org.apache.struts.tiles.DefinitionsFactory in project sonar-java by SonarSource.

the class InitDefinitionsTag method doStartTag.

/**
 * Do start tag.
 */
public int doStartTag() throws JspException {
    DefinitionsFactory factory = TilesUtil.getDefinitionsFactory(pageContext.getRequest(), pageContext.getServletContext());
    if (factory != null)
        return SKIP_BODY;
    DefinitionsFactoryConfig factoryConfig = new DefinitionsFactoryConfig();
    factoryConfig.setFactoryClassname(classname);
    factoryConfig.setDefinitionConfigFiles(filename);
    try {
        factory = TilesUtil.createDefinitionsFactory(pageContext.getServletContext(), factoryConfig);
    } catch (DefinitionsFactoryException ex) {
        ex.printStackTrace();
        throw new JspException(ex);
    }
    return SKIP_BODY;
}
Also used : JspException(javax.servlet.jsp.JspException) DefinitionsFactoryConfig(org.apache.struts.tiles.DefinitionsFactoryConfig) DefinitionsFactoryException(org.apache.struts.tiles.DefinitionsFactoryException) DefinitionsFactory(org.apache.struts.tiles.DefinitionsFactory)

Example 4 with DefinitionsFactory

use of org.apache.struts.tiles.DefinitionsFactory in project sonar-java by SonarSource.

the class RedeployableActionServlet method getRequestProcessor.

protected synchronized RequestProcessor getRequestProcessor(ModuleConfig config) throws ServletException {
    if (tileProcessor != null) {
        TilesRequestProcessor processor = (TilesRequestProcessor) super.getRequestProcessor(config);
        return processor;
    }
    // reset the request processor
    String requestProcessorKey = Globals.REQUEST_PROCESSOR_KEY + config.getPrefix();
    getServletContext().removeAttribute(requestProcessorKey);
    // create a new request processor instance
    TilesRequestProcessor processor = (TilesRequestProcessor) super.getRequestProcessor(config);
    tileProcessor = processor;
    try {
        // reload Tiles defs
        DefinitionsFactory factory = processor.getDefinitionsFactory();
        factory.init(factory.getConfig(), getServletContext());
    // System.out.println("reloaded tiles-definitions");
    } catch (DefinitionsFactoryException e) {
        e.printStackTrace();
    }
    return processor;
}
Also used : TilesRequestProcessor(org.apache.struts.tiles.TilesRequestProcessor) DefinitionsFactoryException(org.apache.struts.tiles.DefinitionsFactoryException) DefinitionsFactory(org.apache.struts.tiles.DefinitionsFactory)

Aggregations

DefinitionsFactory (org.apache.struts.tiles.DefinitionsFactory)4 DefinitionsFactoryException (org.apache.struts.tiles.DefinitionsFactoryException)3 PrintWriter (java.io.PrintWriter)2 ServletContext (javax.servlet.ServletContext)2 JspException (javax.servlet.jsp.JspException)1 DefinitionsFactoryConfig (org.apache.struts.tiles.DefinitionsFactoryConfig)1 TilesRequestProcessor (org.apache.struts.tiles.TilesRequestProcessor)1