View Javadoc

1   // ========================================================================
2   // Copyright (c) 2010-2011 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  package org.eclipse.jetty.nested;
14  
15  import java.io.IOException;
16  import javax.servlet.ServletInputStream;
17  import javax.servlet.http.HttpServletRequest;
18  import javax.servlet.http.HttpServletResponse;
19  
20  import org.eclipse.jetty.io.bio.StreamEndPoint;
21  
22  public class NestedEndPoint extends StreamEndPoint
23  {
24      private final HttpServletRequest _outerRequest;
25  
26      public NestedEndPoint(HttpServletRequest outerRequest, HttpServletResponse outerResponse)
27          throws IOException
28      {
29          super(outerRequest.getInputStream(),outerResponse.getOutputStream());
30          _outerRequest=outerRequest;
31      }
32  
33      public ServletInputStream getServletInputStream()
34      {
35          return (ServletInputStream)getInputStream();
36      }
37      @Override
38      public String getLocalAddr()
39      {
40          return _outerRequest.getLocalAddr();
41      }
42  
43      @Override
44      public String getLocalHost()
45      {
46          return _outerRequest.getLocalName();
47      }
48  
49      @Override
50      public int getLocalPort()
51      {
52          return _outerRequest.getLocalPort();
53      }
54  
55      @Override
56      public String getRemoteAddr()
57      {
58          return _outerRequest.getRemoteAddr();
59      }
60  
61      @Override
62      public String getRemoteHost()
63      {
64          return _outerRequest.getRemoteHost();
65      }
66      @Override
67      public int getRemotePort()
68      {
69          return _outerRequest.getRemotePort();
70      }
71  }