KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tester > TesterServletResponseWrapper


1 /*
2  * Copyright 1999, 2000 ,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.tester;
18
19
20 import java.io.*;
21 import java.util.*;
22 import javax.servlet.*;
23 import javax.servlet.http.*;
24
25 /**
26  * Tester response wrapper that logs all calls to the configured logger,
27  * before passing them on to the underlying response.
28  *
29  * @author Craig R. McClanahan
30  * @version $Revision: 1.2 $ $Date: 2004/02/27 14:58:57 $
31  */

32
33 public class TesterServletResponseWrapper extends ServletResponseWrapper {
34
35
36     // ------------------------------------------------------------ Constructor
37

38
39     /**
40      * Configure a new response wrapper.
41      *
42      * @param response The response we are wrapping
43      */

44     public TesterServletResponseWrapper(ServletResponse response) {
45
46         super(response);
47
48     }
49
50
51     // --------------------------------------------------------- Public Methods
52

53
54     // For each public method, log the call and pass it to the wrapped response
55

56
57     public void flushBuffer() throws IOException {
58         StaticLogger.write("TesterServletResponseWrapper.flushBuffer()");
59         getResponse().flushBuffer();
60     }
61
62
63     public int getBufferSize() {
64         StaticLogger.write("TesterServletResponseWrapper.getBufferSize()");
65         return (getResponse().getBufferSize());
66     }
67
68
69     public String JavaDoc getCharacterEncoding() {
70         StaticLogger.write("TesterServletResponseWrapper.getCharacterEncoding()");
71         return (getResponse().getCharacterEncoding());
72     }
73
74
75     public Locale getLocale() {
76         StaticLogger.write("TesterServletResponseWrapper.getLocale()");
77         return (getResponse().getLocale());
78     }
79
80
81     public ServletOutputStream getOutputStream() throws IOException {
82         StaticLogger.write("TesterServletResponseWrapper.getOutputStream()");
83         return (getResponse().getOutputStream());
84     }
85
86
87     public PrintWriter getWriter() throws IOException {
88         StaticLogger.write("TesterServletResponseWrapper.getWriter()");
89         return (getResponse().getWriter());
90     }
91
92
93     public boolean isCommitted() {
94         StaticLogger.write("TesterServletResponseWrapper.isCommitted()");
95         return (getResponse().isCommitted());
96     }
97
98
99     public void reset() {
100         StaticLogger.write("TesterServletResponseWrapper.reset()");
101         getResponse().reset();
102     }
103
104
105     public void resetBuffer() {
106         StaticLogger.write("TesterServletResponseWrapper.resetBuffer()");
107         getResponse().resetBuffer();
108     }
109
110
111     public void setBufferSize(int size) {
112         StaticLogger.write("TesterServletResponseWrapper.setBufferSize()");
113         getResponse().setBufferSize(size);
114     }
115
116
117     public void setContentLength(int len) {
118         StaticLogger.write("TesterServletResponseWrapper.setContentLength()");
119         getResponse().setContentLength(len);
120     }
121
122
123     public void setContentType(String JavaDoc type) {
124         StaticLogger.write("TesterServletResponseWrapper.setContentType()");
125         getResponse().setContentType(type);
126     }
127
128
129     public void setLocale(Locale locale) {
130         StaticLogger.write("TesterServletResponseWrapper.setLocale()");
131         getResponse().setLocale(locale);
132     }
133
134
135 }
136
Popular Tags