/** * Creates the template engine. * <p> * Called by {@link TemplateServlet#init(ServletConfig)} and returns just * <code>new groovy.text.SimpleTemplateEngine()</code> if the init parameter * <code>template.engine</code> is not set by the container configuration. * * @param config Current servlet configuration passed by the container. * @return The underlying template engine or <code>null</code> on error. */ protected TemplateEngine initTemplateEngine(ServletConfig config) { String name = config.getInitParameter("template.engine"); if (name == null) { return new SimpleTemplateEngine(); } try { return (TemplateEngine) Class.forName(name).newInstance(); } catch (InstantiationException e) { log("Could not instantiate template engine: " + name, e); } catch (IllegalAccessException e) { log("Could not access template engine class: " + name, e); } catch (ClassNotFoundException e) { log("Could not find template engine class: " + name, e); } return null; }
/** * Initializes the servlet from hints the container passes. * <p> * Delegates to sub-init methods and parses the following parameters: * <ul> * <li> <tt>"generatedBy"</tt> : boolean, appends "Generated by ..." to the * HTML response text generated by this servlet. * </li> * </ul> * * @param config Passed by the servlet container. * @throws ServletException if this method encountered difficulties * @see TemplateServlet#initTemplateEngine(ServletConfig) */ public void init(ServletConfig config) throws ServletException { super.init(config); this.engine = initTemplateEngine(config); if (engine == null) { throw new ServletException("Template engine not instantiated."); } String value = config.getInitParameter("generated.by"); if (value != null) { this.generateBy = Boolean.valueOf(value); } value = config.getInitParameter(GROOVY_SOURCE_ENCODING); if (value != null) { this.fileEncodingParamVal = value; } log("Servlet " + getClass().getName() + " initialized on " + engine.getClass()); }
/** * Creates the template engine. * <p> * Called by {@link TemplateServlet#init(ServletConfig)} and returns just * <code>new groovy.text.SimpleTemplateEngine()</code> if the init parameter * <code>template.engine</code> is not set by the container configuration. * * @param config Current servlet configuration passed by the container. * @return The underlying template engine or <code>null</code> on error. */ protected TemplateEngine initTemplateEngine(ServletConfig config) { String name = config.getInitParameter("template.engine"); if (name == null) { return new SimpleTemplateEngine(); } try { return (TemplateEngine) Class.forName(name).newInstance(); } catch (InstantiationException e) { log("Could not instantiate template engine: " + name, e); } catch (IllegalAccessException e) { log("Could not access template engine class: " + name, e); } catch (ClassNotFoundException e) { log("Could not find template engine class: " + name, e); } return null; }
/** * Creates the template engine. * <p/> * Called by {@link TemplateServlet#init(ServletConfig)} and returns just * <code>new groovy.text.SimpleTemplateEngine()</code> if the init parameter * <code>template.engine</code> is not set by the container configuration. * * @param config Current servlet configuration passed by the container. * @return The underlying template engine or <code>null</code> on error. */ protected TemplateEngine initTemplateEngine(ServletConfig config) { String name = config.getInitParameter("template.engine"); if (name == null) { return new SimpleTemplateEngine(); } try { return (TemplateEngine) Class.forName(name).newInstance(); } catch (InstantiationException e) { log("Could not instantiate template engine: " + name, e); } catch (IllegalAccessException e) { log("Could not access template engine class: " + name, e); } catch (ClassNotFoundException e) { log("Could not find template engine class: " + name, e); } return null; }
/** * Creates the template engine. * * Called by {@link TemplateServlet#init(ServletConfig)} and returns just * <code>new groovy.text.SimpleTemplateEngine()</code> if the init parameter * <code>template.engine</code> is not set by the container configuration. * * @param config * Current serlvet configuration passed by the container. * * @return The underlying template engine or <code>null</code> on error. */ protected TemplateEngine initTemplateEngine(ServletConfig config) { String name = config.getInitParameter("template.engine"); if (name == null) { return new SimpleTemplateEngine(); } try { return (TemplateEngine) Class.forName(name).newInstance(); } catch (InstantiationException e) { log("Could not instantiate template engine: " + name, e); } catch (IllegalAccessException e) { log("Could not access template engine class: " + name, e); } catch (ClassNotFoundException e) { log("Could not find template engine class: " + name, e); } return null; }
/** * Creates the template engine. * * Called by {@link TemplateServlet#init(ServletConfig)} and returns just * <code>new groovy.text.SimpleTemplateEngine()</code> if the init parameter * <code>template.engine</code> is not set by the container configuration. * * @param config * Current serlvet configuration passed by the container. * * @return The underlying template engine or <code>null</code> on error. */ protected TemplateEngine initTemplateEngine(ServletConfig config) { String name = config.getInitParameter("template.engine"); if (name == null) { return new SimpleTemplateEngine(); } try { return (TemplateEngine) Class.forName(name).newInstance(); } catch (InstantiationException e) { log("Could not instantiate template engine: " + name, e); } catch (IllegalAccessException e) { log("Could not access template engine class: " + name, e); } catch (ClassNotFoundException e) { log("Could not find template engine class: " + name, e); } return null; }
/** * Creates the template engine. * * Called by {@link TemplateServlet#init(ServletConfig)} and returns just * <code>new groovy.text.SimpleTemplateEngine()</code> if the init parameter * <code>template.engine</code> is not set by the container configuration. * * @param config * Current serlvet configuration passed by the container. * * @return The underlying template engine or <code>null</code> on error. */ protected TemplateEngine initTemplateEngine(ServletConfig config) { String name = config.getInitParameter("template.engine"); if (name == null) { return new SimpleTemplateEngine(); } try { return (TemplateEngine) Class.forName(name).newInstance(); } catch (InstantiationException e) { log("Could not instantiate template engine: " + name, e); } catch (IllegalAccessException e) { log("Could not access template engine class: " + name, e); } catch (ClassNotFoundException e) { log("Could not find template engine class: " + name, e); } return null; }
log("Looking for cached template by key \"" + key + "\""); if (entry.validate(file)) { if (verbose) { log("Cache hit! " + entry); log("Cached template needs recompiliation!"); log("Cache miss."); log("Creating new template from file " + file + "..."); log("Created and added template to cache. [key=" + key + "]");
/** * Initializes the servlet from hints the container passes. * <p/> * Delegates to sub-init methods and parses the following parameters: * <ul> * <li> <tt>"generatedBy"</tt> : boolean, appends "Generated by ..." to the * HTML response text generated by this servlet. * </li> * </ul> * * @param config Passed by the servlet container. * @throws ServletException if this method encountered difficulties * @see TemplateServlet#initTemplateEngine(ServletConfig) */ public void init(ServletConfig config) throws ServletException { super.init(config); this.engine = initTemplateEngine(config); if (engine == null) { throw new ServletException("Template engine not instantiated."); } String value = config.getInitParameter("generated.by"); if (value != null) { this.generateBy = Boolean.valueOf(value); } value = config.getInitParameter(GROOVY_SOURCE_ENCODING); if (value != null) { this.fileEncodingParamVal = value; } log("Servlet " + getClass().getName() + " initialized on " + engine.getClass()); }
/** * Initializes the servlet from hints the container passes. * <p> * Delegates to sub-init methods and parses the following parameters: * <ul> * <li> <tt>"generatedBy"</tt> : boolean, appends "Generated by ..." to the * HTML response text generated by this servlet. * </li> * </ul> * @param config * Passed by the servlet container. * @throws ServletException * if this method encountered difficulties * * @see TemplateServlet#initTemplateEngine(ServletConfig) */ public void init(ServletConfig config) throws ServletException { super.init(config); this.engine = initTemplateEngine(config); if (engine == null) { throw new ServletException("Template engine not instantiated."); } String value = config.getInitParameter("generated.by"); if (value != null) { this.generateBy = Boolean.valueOf(value).booleanValue(); } log("Servlet " + getClass().getName() + " initialized on " + engine.getClass()); }
/** * Initializes the servlet from hints the container passes. * <p> * Delegates to sub-init methods and parses the following parameters: * <ul> * <li> <tt>"generatedBy"</tt> : boolean, appends "Generated by ..." to the * HTML response text generated by this servlet. * </li> * </ul> * @param config * Passed by the servlet container. * @throws ServletException * if this method encountered difficulties * * @see TemplateServlet#initTemplateEngine(ServletConfig) */ public void init(ServletConfig config) throws ServletException { super.init(config); this.engine = initTemplateEngine(config); if (engine == null) { throw new ServletException("Template engine not instantiated."); } String value = config.getInitParameter("generated.by"); if (value != null) { this.generateBy = Boolean.valueOf(value).booleanValue(); } log("Servlet " + getClass().getName() + " initialized on " + engine.getClass()); }
/** * Initializes the servlet from hints the container passes. * <p> * Delegates to sub-init methods and parses the following parameters: * <ul> * <li> <tt>"generatedBy"</tt> : boolean, appends "Generated by ..." to the * HTML response text generated by this servlet. * </li> * </ul> * * @param config Passed by the servlet container. * @throws ServletException if this method encountered difficulties * @see TemplateServlet#initTemplateEngine(ServletConfig) */ public void init(ServletConfig config) throws ServletException { super.init(config); this.engine = initTemplateEngine(config); if (engine == null) { throw new ServletException("Template engine not instantiated."); } String value = config.getInitParameter("generated.by"); if (value != null) { this.generateBy = Boolean.valueOf(value); } value = config.getInitParameter(GROOVY_SOURCE_ENCODING); if (value != null) { this.fileEncodingParamVal = value; } log("Servlet " + getClass().getName() + " initialized on " + engine.getClass()); }
this.fileEncodingParamVal = value; log("Servlet " + getClass().getName() + " initialized on " + engine.getClass());