httplite: implement servlet-api 2.5 methods on HttpServletRequest and ServletContext to fix build.

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1182661 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/httplite/src/main/java/org/apache/felix/http/lightweight/servlet/HttpServletRequestImpl.java b/httplite/src/main/java/org/apache/felix/http/lightweight/servlet/HttpServletRequestImpl.java
index 358c5de..b15381a 100644
--- a/httplite/src/main/java/org/apache/felix/http/lightweight/servlet/HttpServletRequestImpl.java
+++ b/httplite/src/main/java/org/apache/felix/http/lightweight/servlet/HttpServletRequestImpl.java
@@ -132,6 +132,7 @@
      * 
      * @see javax.servlet.ServletRequest#getInputStream()
      */
+    @Override
     public ServletInputStream getInputStream() throws IOException
     {
 
@@ -155,6 +156,7 @@
      * 
      * @see javax.servlet.ServletRequest#getReader()
      */
+    @Override
     public BufferedReader getReader() throws IOException
     {
         if (m_getInputStreamCalled)
@@ -326,6 +328,7 @@
      * 
      * @see javax.servlet.http.HttpServletRequest#getMethod()
      */
+    @Override
     public String getMethod()
     {
         return m_method;
@@ -339,6 +342,7 @@
      * @return The value of the specified header or <tt>null</tt>.
      **/
 
+    @Override
     public String getHeader(final String header)
     {
         Object value = m_headers.get(header.toLowerCase());
@@ -351,6 +355,7 @@
         return value.toString();
     }
 
+    @Override
     public Enumeration getHeaders(final String name)
     {
         Object v = m_headers.get(name);
@@ -374,6 +379,7 @@
             + v.getClass().getName());
     }
 
+    @Override
     public Enumeration getHeaderNames()
     {
         if (m_headers.isEmpty())
@@ -389,6 +395,7 @@
      * 
      * @see javax.servlet.ServletRequest#getAttribute(java.lang.String)
      */
+    @Override
     public Object getAttribute(final String arg0)
     {
         if (m_attributes != null)
@@ -405,6 +412,7 @@
      * @see javax.servlet.ServletRequest#getAttributeNames()
      */
 
+    @Override
     public Enumeration getAttributeNames()
     {
         if (m_attributes != null)
@@ -421,11 +429,13 @@
      * @see javax.servlet.ServletRequest#getCharacterEncoding()
      */
 
+    @Override
     public String getCharacterEncoding()
     {
         return getHeader("Accept-Encoding");
     }
 
+    @Override
     public int getContentLength()
     {
         int len = 0;
@@ -448,6 +458,7 @@
      * @see javax.servlet.ServletRequest#getContentType()
      */
 
+    @Override
     public String getContentType()
     {
         return getHeader("Content-Type");
@@ -459,6 +470,7 @@
      * @see javax.servlet.ServletRequest#getLocale()
      */
 
+    @Override
     public Locale getLocale()
     {
         return m_locale;
@@ -470,6 +482,7 @@
      * @see javax.servlet.ServletRequest#getLocales()
      */
 
+    @Override
     public Enumeration getLocales()
     {
         return Collections.enumeration(Arrays.asList(new Object[] { m_locale }));
@@ -481,6 +494,7 @@
      * @see javax.servlet.ServletRequest#getParameter(java.lang.String)
      */
 
+    @Override
     public String getParameter(final String arg0)
     {
         if (m_parameters == null)
@@ -505,6 +519,7 @@
      * @see javax.servlet.ServletRequest#getParameterMap()
      */
 
+    @Override
     public Map getParameterMap()
     {
         return m_parameters;
@@ -516,6 +531,7 @@
      * @see javax.servlet.ServletRequest#getParameterNames()
      */
 
+    @Override
     public Enumeration getParameterNames()
     {
         return Collections.enumeration(m_parameters.keySet());
@@ -527,6 +543,7 @@
      * @see javax.servlet.ServletRequest#getParameterValues(java.lang.String)
      */
 
+    @Override
     public String[] getParameterValues(String arg0)
     {
         return (String[]) m_parameters.values().toArray(new String[m_parameters.size()]);
@@ -537,6 +554,7 @@
      * 
      * @see javax.servlet.ServletRequest#getProtocol()
      */
+    @Override
     public String getProtocol()
     {
         return m_version;
@@ -547,6 +565,7 @@
      * 
      * @see javax.servlet.ServletRequest#getRealPath(java.lang.String)
      */
+    @Override
     public String getRealPath(final String arg0)
     {
         throw new UnimplementedAPIException();
@@ -557,6 +576,7 @@
      * 
      * @see javax.servlet.ServletRequest#getRemoteAddr()
      */
+    @Override
     public String getRemoteAddr()
     {
         return getSocket().getRemoteSocketAddress().toString();
@@ -565,6 +585,7 @@
     /* (non-Javadoc)
      * @see javax.servlet.ServletRequest#getRemoteHost()
      */
+    @Override
     public String getRemoteHost()
     {
         return getSocket().getRemoteSocketAddress().toString();
@@ -573,6 +594,7 @@
     /* (non-Javadoc)
      * @see javax.servlet.ServletRequest#getRequestDispatcher(java.lang.String)
      */
+    @Override
     public RequestDispatcher getRequestDispatcher(String arg0)
     {
         return null;
@@ -581,6 +603,7 @@
     /* (non-Javadoc)
      * @see javax.servlet.ServletRequest#getScheme()
      */
+    @Override
     public String getScheme()
     {
         return HttpConstants.HTTP_SCHEME;
@@ -589,6 +612,7 @@
     /* (non-Javadoc)
      * @see javax.servlet.ServletRequest#getServerName()
      */
+    @Override
     public String getServerName()
     {
         return HttpConstants.SERVER_INFO;
@@ -597,6 +621,7 @@
     /* (non-Javadoc)
      * @see javax.servlet.ServletRequest#getServerPort()
      */
+    @Override
     public int getServerPort()
     {
         return getSocket().getLocalPort();
@@ -605,6 +630,7 @@
     /* (non-Javadoc)
      * @see javax.servlet.ServletRequest#isSecure()
      */
+    @Override
     public boolean isSecure()
     {
         return false;
@@ -613,6 +639,7 @@
     /* (non-Javadoc)
      * @see javax.servlet.ServletRequest#removeAttribute(java.lang.String)
      */
+    @Override
     public void removeAttribute(String arg0)
     {
         if (m_attributes != null)
@@ -624,6 +651,7 @@
     /* (non-Javadoc)
      * @see javax.servlet.ServletRequest#setAttribute(java.lang.String, java.lang.Object)
      */
+    @Override
     public void setAttribute(String arg0, Object arg1)
     {
         if (m_attributes == null)
@@ -637,6 +665,7 @@
     /* (non-Javadoc)
      * @see javax.servlet.ServletRequest#setCharacterEncoding(java.lang.String)
      */
+    @Override
     public void setCharacterEncoding(String arg0) throws UnsupportedEncodingException
     {
         throw new UnimplementedAPIException();
@@ -648,6 +677,7 @@
      * @see javax.servlet.http.HttpServletRequest#getAuthType()
      */
 
+    @Override
     public String getAuthType()
     {
         return null;
@@ -659,6 +689,7 @@
      * @see javax.servlet.http.HttpServletRequest#getCookies()
      */
 
+    @Override
     public Cookie[] getCookies()
     {
         if (m_cookies == null)
@@ -698,6 +729,7 @@
      * javax.servlet.http.HttpServletRequest#getDateHeader(java.lang.String)
      */
 
+    @Override
     public long getDateHeader(final String name)
     {
         String headerValue = getHeader(name);
@@ -726,6 +758,7 @@
      * @see javax.servlet.http.HttpServletRequest#getIntHeader(java.lang.String)
      */
 
+    @Override
     public int getIntHeader(final String name)
     {
         String value = getHeader(name);
@@ -744,6 +777,7 @@
      * @see javax.servlet.http.HttpServletRequest#getPathInfo()
      */
 
+    @Override
     public String getPathInfo()
     {
         String alias = getAlias();
@@ -761,12 +795,14 @@
         return null;
     }
 
+    @Override
     public String getPathTranslated()
     {
         // TODO: Always returning null may be incorrect.
         return null;
     }
 
+    @Override
     public String getContextPath()
     {
         return "";
@@ -778,26 +814,31 @@
      * @see javax.servlet.http.HttpServletRequest#getQueryString()
      */
 
+    @Override
     public String getQueryString()
     {
         return m_queryString;
     }
 
+    @Override
     public String getRemoteUser()
     {
         return null;
     }
 
+    @Override
     public boolean isUserInRole(String role)
     {
         return false;
     }
 
+    @Override
     public Principal getUserPrincipal()
     {
         return null;
     }
 
+    @Override
     public String getRequestedSessionId()
     {
         return null;
@@ -808,6 +849,7 @@
      * 
      * @see javax.servlet.http.HttpServletRequest#getRequestURI()
      */
+    @Override
     public String getRequestURI()
     {
         return m_uri;
@@ -818,6 +860,7 @@
      * 
      * @see javax.servlet.http.HttpServletRequest#getRequestURL()
      */
+    @Override
     public StringBuffer getRequestURL()
     {
         StringBuffer sb = new StringBuffer();
@@ -833,6 +876,7 @@
      * @see javax.servlet.http.HttpServletRequest#getServletPath()
      */
 
+    @Override
     public String getServletPath()
     {
         if (m_servletPath == null)
@@ -867,31 +911,37 @@
         return element.getAlias();
     }
 
+    @Override
     public HttpSession getSession(boolean create)
     {
         throw new UnimplementedAPIException();
     }
 
+    @Override
     public HttpSession getSession()
     {
         throw new UnimplementedAPIException();
     }
 
+    @Override
     public boolean isRequestedSessionIdValid()
     {
         throw new UnimplementedAPIException();
     }
 
+    @Override
     public boolean isRequestedSessionIdFromCookie()
     {
         throw new UnimplementedAPIException();
     }
 
+    @Override
     public boolean isRequestedSessionIdFromURL()
     {
         throw new UnimplementedAPIException();
     }
 
+    @Override
     public boolean isRequestedSessionIdFromUrl()
     {
         throw new UnimplementedAPIException();
@@ -965,6 +1015,7 @@
     /* (non-Javadoc)
      * @see java.lang.Object#toString()
      */
+    @Override
     public String toString()
     {
         if (m_method != null && m_uri != null)
@@ -974,4 +1025,40 @@
 
         return super.toString();
     }
+
+    /* (non-Javadoc)
+     * @see javax.servlet.ServletRequest#getLocalAddr()
+     */
+    @Override
+    public String getLocalAddr()
+    {
+        return m_socket.getLocalAddress().getHostAddress();
+    }
+
+    /* (non-Javadoc)
+     * @see javax.servlet.ServletRequest#getLocalName()
+     */
+    @Override
+    public String getLocalName()
+    {
+        return m_socket.getLocalAddress().getHostName();
+    }
+
+    /* (non-Javadoc)
+     * @see javax.servlet.ServletRequest#getLocalPort()
+     */
+    @Override
+    public int getLocalPort()
+    {        
+        return m_socket.getLocalPort();
+    }
+
+    /* (non-Javadoc)
+     * @see javax.servlet.ServletRequest#getRemotePort()
+     */
+    @Override
+    public int getRemotePort()
+    {        
+        return m_socket.getPort();
+    }
 }
\ No newline at end of file
diff --git a/httplite/src/main/java/org/apache/felix/http/lightweight/servlet/ServletContextImpl.java b/httplite/src/main/java/org/apache/felix/http/lightweight/servlet/ServletContextImpl.java
index ca325a1..f0161e2 100644
--- a/httplite/src/main/java/org/apache/felix/http/lightweight/servlet/ServletContextImpl.java
+++ b/httplite/src/main/java/org/apache/felix/http/lightweight/servlet/ServletContextImpl.java
@@ -67,7 +67,8 @@
     /* (non-Javadoc)
      * @see javax.servlet.ServletContext#getContext(java.lang.String)
      */
-    public ServletContext getContext(String uripath)
+    @Override
+	public ServletContext getContext(String uripath)
     {
         return null;
     }
@@ -75,7 +76,8 @@
     /* (non-Javadoc)
      * @see javax.servlet.ServletContext#getMajorVersion()
      */
-    public int getMajorVersion()
+    @Override
+	public int getMajorVersion()
     {
         return 2;
     }
@@ -83,7 +85,8 @@
     /* (non-Javadoc)
      * @see javax.servlet.ServletContext#getMinorVersion()
      */
-    public int getMinorVersion()
+    @Override
+	public int getMinorVersion()
     {
         return 4;
     }
@@ -91,7 +94,8 @@
     /* (non-Javadoc)
      * @see javax.servlet.ServletContext#getMimeType(java.lang.String)
      */
-    public String getMimeType(String file)
+    @Override
+	public String getMimeType(String file)
     {
         return m_httpContext.getMimeType(file);
     }
@@ -99,7 +103,8 @@
     /* (non-Javadoc)
      * @see javax.servlet.ServletContext#getResourcePaths(java.lang.String)
      */
-    public Set getResourcePaths(String path)
+    @Override
+	public Set getResourcePaths(String path)
     {
         return null;
     }
@@ -107,7 +112,8 @@
     /* (non-Javadoc)
      * @see javax.servlet.ServletContext#getResource(java.lang.String)
      */
-    public URL getResource(String path) throws MalformedURLException
+    @Override
+	public URL getResource(String path) throws MalformedURLException
     {
         return m_httpContext.getResource(path);
     }
@@ -115,7 +121,8 @@
     /* (non-Javadoc)
      * @see javax.servlet.ServletContext#getResourceAsStream(java.lang.String)
      */
-    public InputStream getResourceAsStream(String path)
+    @Override
+	public InputStream getResourceAsStream(String path)
     {
         try
         {
@@ -132,7 +139,8 @@
     /* (non-Javadoc)
      * @see javax.servlet.ServletContext#getRequestDispatcher(java.lang.String)
      */
-    public RequestDispatcher getRequestDispatcher(String path)
+    @Override
+	public RequestDispatcher getRequestDispatcher(String path)
     {
         return null;
     }
@@ -140,7 +148,8 @@
     /* (non-Javadoc)
      * @see javax.servlet.ServletContext#getNamedDispatcher(java.lang.String)
      */
-    public RequestDispatcher getNamedDispatcher(String name)
+    @Override
+	public RequestDispatcher getNamedDispatcher(String name)
     {
         return null;
     }
@@ -148,32 +157,38 @@
     /* (non-Javadoc)
      * @see javax.servlet.ServletContext#getServlet(java.lang.String)
      */
-    public Servlet getServlet(String name) throws ServletException
+    @Override
+	public Servlet getServlet(String name) throws ServletException
     {
         return null;
     }
 
-    public Enumeration getServlets()
+    @Override
+	public Enumeration getServlets()
     {
         return null;
     }
 
-    public Enumeration getServletNames()
+    @Override
+	public Enumeration getServletNames()
     {
         return null;
     }
 
-    public void log(String msg)
+    @Override
+	public void log(String msg)
     {
         m_logger.log(Logger.LOG_INFO, msg);
     }
 
-    public void log(Exception exception, String msg)
+    @Override
+	public void log(Exception exception, String msg)
     {
         m_logger.log(Logger.LOG_ERROR, msg, exception);
     }
 
-    public void log(String message, Throwable throwable)
+    @Override
+	public void log(String message, Throwable throwable)
     {
         m_logger.log(Logger.LOG_ERROR, message, throwable);
     }
@@ -181,7 +196,8 @@
     /* (non-Javadoc)
      * @see javax.servlet.ServletContext#getRealPath(java.lang.String)
      */
-    public String getRealPath(String path)
+    @Override
+	public String getRealPath(String path)
     {
         return path;
     }
@@ -189,7 +205,8 @@
     /* (non-Javadoc)
      * @see javax.servlet.ServletContext#getServerInfo()
      */
-    public String getServerInfo()
+    @Override
+	public String getServerInfo()
     {
         return HttpConstants.SERVER_INFO;
     }
@@ -197,7 +214,8 @@
     /* (non-Javadoc)
      * @see javax.servlet.ServletContext#getInitParameter(java.lang.String)
      */
-    public String getInitParameter(String name)
+    @Override
+	public String getInitParameter(String name)
     {
         if (m_initparams != null)
         {
@@ -215,7 +233,8 @@
     /* (non-Javadoc)
      * @see javax.servlet.ServletContext#getInitParameterNames()
      */
-    public Enumeration getInitParameterNames()
+    @Override
+	public Enumeration getInitParameterNames()
     {
         if (m_initparams != null)
         {
@@ -228,7 +247,8 @@
     /* (non-Javadoc)
      * @see javax.servlet.ServletContext#getAttribute(java.lang.String)
      */
-    public Object getAttribute(String name)
+    @Override
+	public Object getAttribute(String name)
     {
         if (m_attributes != null)
         {
@@ -241,7 +261,8 @@
     /* (non-Javadoc)
      * @see javax.servlet.ServletContext#getAttributeNames()
      */
-    public Enumeration getAttributeNames()
+    @Override
+	public Enumeration getAttributeNames()
     {
         if (m_attributes != null)
         {
@@ -254,7 +275,8 @@
     /* (non-Javadoc)
      * @see javax.servlet.ServletContext#setAttribute(java.lang.String, java.lang.Object)
      */
-    public void setAttribute(String name, Object object)
+    @Override
+	public void setAttribute(String name, Object object)
     {
         if (m_attributes == null)
         {
@@ -267,7 +289,8 @@
     /* (non-Javadoc)
      * @see javax.servlet.ServletContext#removeAttribute(java.lang.String)
      */
-    public void removeAttribute(String name)
+    @Override
+	public void removeAttribute(String name)
     {
         if (m_attributes != null)
         {
@@ -278,8 +301,17 @@
     /* (non-Javadoc)
      * @see javax.servlet.ServletContext#getServletContextName()
      */
-    public String getServletContextName()
+    @Override
+	public String getServletContextName()
     {
         return m_name;
     }
+
+	/* (non-Javadoc)
+	 * @see javax.servlet.ServletContext#getContextPath()
+	 */
+	@Override
+	public String getContextPath() {	
+		return m_name;
+	}
 }