1 // ========================================================================
2 // Copyright (c) 2009-2009 Mort Bay Consulting Pty. Ltd.
3 // ------------------------------------------------------------------------
4 // All rights reserved. This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v1.0
6 // and Apache License v2.0 which accompanies this distribution.
7 // The Eclipse Public License is available at
8 // http://www.eclipse.org/legal/epl-v10.html
9 // The Apache License v2.0 is available at
10 // http://www.opensource.org/licenses/apache2.0.php
11 // You may elect to redistribute this code under either of these licenses.
12 // ========================================================================
13
14 package org.eclipse.jetty.http.spi;
15
16 import java.io.IOException;
17 import java.io.InputStream;
18 import java.io.OutputStream;
19 import java.net.InetSocketAddress;
20 import java.net.URI;
21
22 import javax.servlet.http.HttpServletRequest;
23 import javax.servlet.http.HttpServletResponse;
24
25 import com.sun.net.httpserver.Headers;
26 import com.sun.net.httpserver.HttpContext;
27 import com.sun.net.httpserver.HttpExchange;
28 import com.sun.net.httpserver.HttpPrincipal;
29
30 /* ------------------------------------------------------------ */
31 /**
32 */
33 public class JettyHttpExchange extends HttpExchange implements JettyExchange
34 {
35 private JettyHttpExchangeDelegate _delegate;
36
37 public JettyHttpExchange(HttpContext jaxWsContext, HttpServletRequest req, HttpServletResponse resp)
38 {
39 super();
40 _delegate = new JettyHttpExchangeDelegate(jaxWsContext,req,resp);
41 }
42
43 /* ------------------------------------------------------------ */
44 /**
45 * @see org.eclipse.jetty.http.spi.JettyExchange#hashCode()
46 */
47 @Override
48 public int hashCode()
49 {
50 return _delegate.hashCode();
51 }
52
53 /* ------------------------------------------------------------ */
54 /**
55 * @see org.eclipse.jetty.http.spi.JettyExchange#getRequestHeaders()
56 */
57 @Override
58 public Headers getRequestHeaders()
59 {
60 return _delegate.getRequestHeaders();
61 }
62
63 /* ------------------------------------------------------------ */
64 /**
65 * @see org.eclipse.jetty.http.spi.JettyExchange#getResponseHeaders()
66 */
67 @Override
68 public Headers getResponseHeaders()
69 {
70 return _delegate.getResponseHeaders();
71 }
72
73 /* ------------------------------------------------------------ */
74 /**
75 * @see org.eclipse.jetty.http.spi.JettyExchange#getRequestURI()
76 */
77 @Override
78 public URI getRequestURI()
79 {
80 return _delegate.getRequestURI();
81 }
82
83 /* ------------------------------------------------------------ */
84 /**
85 * @see org.eclipse.jetty.http.spi.JettyExchange#getRequestMethod()
86 */
87 @Override
88 public String getRequestMethod()
89 {
90 return _delegate.getRequestMethod();
91 }
92
93 /* ------------------------------------------------------------ */
94 /**
95 * @see org.eclipse.jetty.http.spi.JettyExchange#getHttpContext()
96 */
97 @Override
98 public HttpContext getHttpContext()
99 {
100 return _delegate.getHttpContext();
101 }
102
103 /* ------------------------------------------------------------ */
104 /**
105 * @see org.eclipse.jetty.http.spi.JettyExchange#close()
106 */
107 @Override
108 public void close()
109 {
110 _delegate.close();
111 }
112
113 /* ------------------------------------------------------------ */
114 /**
115 * @see org.eclipse.jetty.http.spi.JettyExchange#equals(java.lang.Object)
116 */
117 @Override
118 public boolean equals(Object obj)
119 {
120 return _delegate.equals(obj);
121 }
122
123 /* ------------------------------------------------------------ */
124 /**
125 * @see org.eclipse.jetty.http.spi.JettyExchange#getRequestBody()
126 */
127 @Override
128 public InputStream getRequestBody()
129 {
130 return _delegate.getRequestBody();
131 }
132
133 /* ------------------------------------------------------------ */
134 /**
135 * @see org.eclipse.jetty.http.spi.JettyExchange#getResponseBody()
136 */
137 @Override
138 public OutputStream getResponseBody()
139 {
140 return _delegate.getResponseBody();
141 }
142
143 /* ------------------------------------------------------------ */
144 /**
145 * @see org.eclipse.jetty.http.spi.JettyExchange#sendResponseHeaders(int, long)
146 */
147 @Override
148 public void sendResponseHeaders(int rCode, long responseLength) throws IOException
149 {
150 _delegate.sendResponseHeaders(rCode,responseLength);
151 }
152
153 /* ------------------------------------------------------------ */
154 /**
155 * @see org.eclipse.jetty.http.spi.JettyExchange#getRemoteAddress()
156 */
157 @Override
158 public InetSocketAddress getRemoteAddress()
159 {
160 return _delegate.getRemoteAddress();
161 }
162
163 /* ------------------------------------------------------------ */
164 /**
165 * @see org.eclipse.jetty.http.spi.JettyExchange#getResponseCode()
166 */
167 @Override
168 public int getResponseCode()
169 {
170 return _delegate.getResponseCode();
171 }
172
173 /* ------------------------------------------------------------ */
174 /**
175 * @see org.eclipse.jetty.http.spi.JettyExchange#getLocalAddress()
176 */
177 @Override
178 public InetSocketAddress getLocalAddress()
179 {
180 return _delegate.getLocalAddress();
181 }
182
183 /* ------------------------------------------------------------ */
184 /**
185 * @see org.eclipse.jetty.http.spi.JettyExchange#getProtocol()
186 */
187 @Override
188 public String getProtocol()
189 {
190 return _delegate.getProtocol();
191 }
192
193 /* ------------------------------------------------------------ */
194 /**
195 * @see org.eclipse.jetty.http.spi.JettyExchange#getAttribute(java.lang.String)
196 */
197 @Override
198 public Object getAttribute(String name)
199 {
200 return _delegate.getAttribute(name);
201 }
202
203 /* ------------------------------------------------------------ */
204 /**
205 * @see org.eclipse.jetty.http.spi.JettyExchange#setAttribute(java.lang.String, java.lang.Object)
206 */
207 @Override
208 public void setAttribute(String name, Object value)
209 {
210 _delegate.setAttribute(name,value);
211 }
212
213 /* ------------------------------------------------------------ */
214 /**
215 * @see org.eclipse.jetty.http.spi.JettyExchange#setStreams(java.io.InputStream, java.io.OutputStream)
216 */
217 @Override
218 public void setStreams(InputStream i, OutputStream o)
219 {
220 _delegate.setStreams(i,o);
221 }
222
223 /* ------------------------------------------------------------ */
224 /**
225 * @see org.eclipse.jetty.http.spi.JettyExchange#getPrincipal()
226 */
227 @Override
228 public HttpPrincipal getPrincipal()
229 {
230 return _delegate.getPrincipal();
231 }
232
233 /* ------------------------------------------------------------ */
234 /**
235 * @see org.eclipse.jetty.http.spi.JettyExchange#setPrincipal(com.sun.net.httpserver.HttpPrincipal)
236 */
237 public void setPrincipal(HttpPrincipal principal)
238 {
239 _delegate.setPrincipal(principal);
240 }
241
242 /* ------------------------------------------------------------ */
243 /**
244 * @see org.eclipse.jetty.http.spi.JettyExchange#toString()
245 */
246 @Override
247 public String toString()
248 {
249 return _delegate.toString();
250 }
251
252 }