Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/infohazard/maverick/ctl/Throwaway2.java


1   /*
2    * $Id: Throwaway2.java,v 1.3 2003/10/27 11:00:39 thusted Exp $
3    * $Source: /cvsroot/mav/maverick/src/java/org/infohazard/maverick/ctl/Throwaway2.java,v $
4    */
5   
6   package org.infohazard.maverick.ctl;
7   
8   import org.infohazard.maverick.flow.Controller;
9   import org.infohazard.maverick.flow.ControllerContext;
10  import javax.servlet.*;
11  
12  /**
13   * Throwaway2 is a base class for simple controllers which implements
14   * the single-use controller pattern (a fresh controller instance is
15   * created to service each request).  No population of properties is
16   * performed by this class.
17   */
18  public abstract class Throwaway2 implements Controller
19  {
20    /**
21     * Common name for the typical "success" view.
22     */
23    public static final String SUCCESS = "success";
24  
25    /**
26     * Common name for the typical "error" view.
27     */
28    public static final String ERROR = "error";
29  
30    /**
31     */
32    private ControllerContext controllerCtx;
33    
34    /**
35     * Sets up the servlet parameters and calls through to the
36     * parameterless rawPerform() method.  Does not result in
37     * bean population.
38     *
39     * @see Controller#go
40     */
41    public final String go(ControllerContext cctx) throws ServletException
42    {
43      try
44      {
45        this.controllerCtx = cctx;
46  
47        return this.go();
48      }
49      catch (Exception ex)
50      {
51        throw new ServletException(ex);
52      }
53    }
54  
55    /**
56     * This is the method you should override to implement application logic.
57     */
58    protected abstract String go() throws Exception;
59  
60    /**
61     * Obtain the controller context for this request.
62     */
63    protected ControllerContext getCtx()
64    {
65      return this.controllerCtx;
66    }
67  }