01: /**
02: *
03: * Licensed to the Apache Software Foundation (ASF) under one or more
04: * contributor license agreements. See the NOTICE file distributed with
05: * this work for additional information regarding copyright ownership.
06: * The ASF licenses this file to You under the Apache License, Version 2.0
07: * (the "License"); you may not use this file except in compliance with
08: * the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */package org.apache.openejb.server.httpd;
18:
19: import javax.servlet.http.HttpServletResponse;
20: import java.io.PrintWriter;
21: import java.io.IOException;
22: import java.io.OutputStream;
23:
24: public class ServletResponseAdapter implements HttpResponse {
25: private final HttpServletResponse response;
26:
27: public ServletResponseAdapter(HttpServletResponse response) {
28: this .response = response;
29: }
30:
31: public PrintWriter getPrintWriter() throws IOException {
32: return response.getWriter();
33: }
34:
35: public void setHeader(String name, String value) {
36: response.setHeader(name, value);
37: }
38:
39: public String getHeader(String name) {
40: throw new UnsupportedOperationException(
41: "Not possible to implement");
42: }
43:
44: public OutputStream getOutputStream() {
45: try {
46: return response.getOutputStream();
47: } catch (IOException e) {
48: throw (IllegalStateException) new IllegalStateException()
49: .initCause(e);
50: }
51: }
52:
53: public void setStatusCode(int code) {
54: response.setStatus(code);
55: }
56:
57: public int getStatusCode() {
58: throw new UnsupportedOperationException(
59: "Not possible to implement");
60: }
61:
62: public void setContentType(String type) {
63: response.setContentType(type);
64: }
65:
66: public String getContentType() {
67: return response.getContentType();
68: }
69:
70: @SuppressWarnings({"deprecation"})
71: public void setStatusMessage(String responseString) {
72: response.setStatus(getStatusCode(), responseString);
73: }
74:
75: public void flushBuffer() throws IOException {
76: response.flushBuffer();
77: }
78: }
|