KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > junit > internal > http > RequestDispatcherWrapper


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.junit.internal.http;
8
9
10 import java.io.IOException JavaDoc;
11
12 import javax.servlet.RequestDispatcher JavaDoc;
13 import javax.servlet.ServletException JavaDoc;
14 import javax.servlet.ServletRequest JavaDoc;
15 import javax.servlet.ServletResponse JavaDoc;
16
17
18 /**
19  * <p>
20  * A dummy request dispatcher object. This object allows
21  * much more flexibility with changing standards as well
22  * as changing requirements on specific projects. For
23  * example, if someone wishes to test a forward without
24  * actually doing the forward, a sub-class of this that
25  * allows them to test this.
26  * </p>
27  *
28  * <p>
29  * <br>
30  * Overall, this class is empty allowing all request dispatcher
31  * calls to be propogated to the real request dispatcher.
32  * </p>
33  *
34  * @author Brian Pontarelli
35  * @since 1.0
36  * @version 1.0
37  */

38 public class RequestDispatcherWrapper implements RequestDispatcher JavaDoc {
39
40     /**
41      * The original and wrapped request dispatcher
42      */

43     protected RequestDispatcher JavaDoc rd;
44
45
46     /**
47      * Constructs a new request dispatcher wrapper that forwards all its method
48      * calls to the original request dispatcher
49      */

50     public RequestDispatcherWrapper(RequestDispatcher JavaDoc rd) {
51         this.rd = rd;
52     }
53
54
55     /**
56      * Returns the original request dispatcher
57      */

58     public RequestDispatcher JavaDoc getWrappedRequestDispatcher() {
59         return rd;
60     }
61
62     /** Forwards method call to the wrapped request dispatcher */
63     public void forward(ServletRequest JavaDoc request, ServletResponse JavaDoc response)
64     throws IOException JavaDoc, ServletException JavaDoc {
65         System.out.println("Forwarding! class is [" + request + "]");
66         rd.forward(((HttpServletRequestWrapper) request).getRequest(),
67             ((HttpServletResponseWrapper) response).getResponse());
68     }
69
70     /** Forwards method call to the wrapped request dispatcher */
71     public void include(ServletRequest JavaDoc request, ServletResponse JavaDoc response)
72     throws IOException JavaDoc, ServletException JavaDoc {
73         rd.include(((HttpServletRequestWrapper) request).getRequest(),
74             ((HttpServletResponseWrapper) response).getResponse());
75     }
76 }
77
Popular Tags