geirm       01/02/25 20:51:23

  Modified:    src/java/org/apache/velocity/servlet VelocityServlet.java
  Log:
  A little javadoc, and made it clear that getTemplate() throws the new
  application exceptions, ResourceNotFoundException & ParseErrorException
  
  Revision  Changes    Path
  1.22      +30 -2     
jakarta-velocity/src/java/org/apache/velocity/servlet/VelocityServlet.java
  
  Index: VelocityServlet.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/servlet/VelocityServlet.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- VelocityServlet.java      2001/02/12 02:58:28     1.21
  +++ VelocityServlet.java      2001/02/26 04:51:23     1.22
  @@ -79,6 +79,9 @@
   import org.apache.velocity.context.Context;
   import org.apache.velocity.VelocityContext;
   
  +import org.apache.velocity.exception.ResourceNotFoundException;
  +import org.apache.velocity.exception.ParseErrorException;
  +
   /**
    * Base class which simplifies the use of Velocity with Servlets.
    * Extend this class, implement the <code>handleRequest()</code> method, 
  @@ -101,7 +104,7 @@
    * @author Dave Bryson
    * @author <a href="mailto:[EMAIL PROTECTED]">Jon S. Stevens</a>
    * @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
  - * $Id: VelocityServlet.java,v 1.21 2001/02/12 02:58:28 geirm Exp $
  + * $Id: VelocityServlet.java,v 1.22 2001/02/26 04:51:23 geirm Exp $
    */
   public abstract class VelocityServlet extends HttpServlet
   {
  @@ -253,6 +256,12 @@
                */
   
               mergeTemplate( template, context, response );
  +
  +            /*
  +             *  call cleanup routine to let a derived class do some cleanup
  +             */
  +
  +            requestCleanup( request, response, context );
           }
           catch (Exception e)
           {
  @@ -261,6 +270,20 @@
       }
   
       /**
  +     *  cleanup routine called at the end of the request processing sequence
  +     *  allows a derived class to do resource cleanup or other end of 
  +     *  process cycle tasks
  +     *
  +     *  @param request servlet request from client 
  +     *  @param response servlet reponse 
  +     *  @param context  context created by the createContext() method
  +     */
  +    protected void requestCleanup( HttpServletRequest request, HttpServletResponse 
response, Context context )
  +    {
  +        return;
  +    }
  +
  +    /**
        *  merges the template with the context.  Only override this if you really, 
really
        *  really need to. (And don't call us with questions if it breaks :)
        *
  @@ -363,9 +386,14 @@
        * @param name The file name of the template to retrieve relative to the 
        *             template root.
        * @return     The requested template.
  +     * @throws ResourceNotFoundException if template not found
  +     *          from any available source.
  +     * @throws ParseErrorException if template cannot be parsed due
  +     *          to syntax (or other) error.
  +     * @throws Exception if an error occurs in template initialization
        */
       public Template getTemplate( String name )
  -        throws Exception
  +        throws ResourceNotFoundException, ParseErrorException, Exception
       {
           return Runtime.getTemplate(name);
       }
  
  
  

Reply via email to