You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by fm...@apache.org on 2007/09/28 22:31:39 UTC

svn commit: r580478 - /felix/trunk/http.jetty/src/main/java/org/apache/felix/http/jetty/ServletContextGroup.java

Author: fmeschbe
Date: Fri Sep 28 13:31:39 2007
New Revision: 580478

URL: http://svn.apache.org/viewvc?rev=580478&view=rev
Log:
FELIX-382 ServletContext.getResource[AsStream] not working correctly

Modified:
    felix/trunk/http.jetty/src/main/java/org/apache/felix/http/jetty/ServletContextGroup.java

Modified: felix/trunk/http.jetty/src/main/java/org/apache/felix/http/jetty/ServletContextGroup.java
URL: http://svn.apache.org/viewvc/felix/trunk/http.jetty/src/main/java/org/apache/felix/http/jetty/ServletContextGroup.java?rev=580478&r1=580477&r2=580478&view=diff
==============================================================================
--- felix/trunk/http.jetty/src/main/java/org/apache/felix/http/jetty/ServletContextGroup.java (original)
+++ felix/trunk/http.jetty/src/main/java/org/apache/felix/http/jetty/ServletContextGroup.java Fri Sep 28 13:31:39 2007
@@ -15,8 +15,8 @@
 package org.apache.felix.http.jetty;
 
 
+import java.io.IOException;
 import java.io.InputStream;
-import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.Dictionary;
 import java.util.Enumeration;
@@ -178,25 +178,40 @@
 
     public String getRealPath( String path )
     {
-        return m_hdlr.getServletContext().getRealPath( path );
+        // resources are contained in the bundle and thus are not
+        // available as normal files in the platform filesystem
+        return null;
     }
 
 
-    public RequestDispatcher getRequestDispatcher( String uri )
+    public URL getResource( String path )
     {
-        return m_hdlr.getServletContext().getRequestDispatcher( uri );
+        return m_osgiHttpContext.getResource( path );
     }
 
 
-    public URL getResource( String path ) throws MalformedURLException
+    public InputStream getResourceAsStream( String path )
     {
-        return m_hdlr.getServletContext().getResource( path );
+        URL res = getResource( path );
+        if ( res != null )
+        {
+            try
+            {
+                return res.openStream();
+            }
+            catch ( IOException ignore )
+            {
+                // might want to log, but actually don't care here
+            }
+        }
+
+        return null;
     }
 
 
-    public InputStream getResourceAsStream( String path )
+    public RequestDispatcher getRequestDispatcher( String uri )
     {
-        return m_hdlr.getServletContext().getResourceAsStream( path );
+        return m_hdlr.getServletContext().getRequestDispatcher( uri );
     }