KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > verge > mvc > servlet > test > TestMVCMediator


1 /*
2  * Copyright (c) 2003, Inversoft
3  *
4  * This software is distribuable under the GNU Lesser General Public License.
5  * For more information visit gnu.org.
6  */

7 package com.inversoft.verge.mvc.servlet.test;
8
9
10 import javax.servlet.http.HttpServletRequest JavaDoc;
11 import javax.servlet.http.HttpServletResponse JavaDoc;
12
13 import com.inversoft.verge.mvc.MVCException;
14 import com.inversoft.verge.mvc.MVCMediator;
15
16
17 /**
18  * This class is a simple implementation of the MVCMediator
19  * to test the initialization of the MVCServlet
20  *
21  * @author Brian Pontarelli
22  */

23 public class TestMVCMediator implements MVCMediator {
24
25     /**
26      * The string that is the parameter for failure tests as well as the error
27      * message for the MVCException that gets thrown
28      */

29     public static final String JavaDoc FAIL = "fail";
30
31
32     /**
33      * Instantiates a new <code>TestMVCMediator</code>
34      */

35     public TestMVCMediator() {
36     }
37
38
39     /**
40      * Handles the mediation of the entire MVC system. Implementation classes
41      * can handle this however they see fit. There are NO requirements on
42      * what functionilty they must contain.
43      *
44      * @param request The HttpServletRequest from which the clients request
45      * information may be retrieved
46      * @param response The HttpServletResponse which can be used to redirect
47      * or forward the the client to another view
48      * @throws com.inversoft.verge.mvc.MVCException If there were any problems during MVC execution
49      */

50     public void mediate(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
51     throws MVCException {
52         assert (request != null) : "request == null";
53         assert (response != null) : "response == null";
54
55         if (request.getParameter(FAIL) != null &&
56                 request.getParameter(FAIL).equals(FAIL)) {
57             throw new MVCException(FAIL);
58         }
59     }
60 }
61
Popular Tags