KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infohazard > maverick > ctl > Throwaway2


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 JavaDoc SUCCESS = "success";
24
25     /**
26      * Common name for the typical "error" view.
27      */

28     public static final String JavaDoc 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 JavaDoc go(ControllerContext cctx) throws ServletException
42     {
43         try
44         {
45             this.controllerCtx = cctx;
46
47             return this.go();
48         }
49         catch (Exception JavaDoc 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 JavaDoc go() throws Exception JavaDoc;
59
60     /**
61      * Obtain the controller context for this request.
62      */

63     protected ControllerContext getCtx()
64     {
65         return this.controllerCtx;
66     }
67 }
Popular Tags