felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From walk...@apache.org
Subject svn commit: r704136 - in /felix/trunk/http.jetty: pom.xml src/main/java/org/apache/felix/http/jetty/HttpServiceImpl.java src/main/java/org/apache/felix/http/jetty/ServletContextGroup.java src/main/java/org/mortbay/jetty/servlet/OsgiResourceHolder.java
Date Mon, 13 Oct 2008 14:30:44 GMT
Author: walkerr
Date: Mon Oct 13 07:30:43 2008
New Revision: 704136

URL: http://svn.apache.org/viewvc?rev=704136&view=rev
Log:
FELIX-763 - improvements to alias resolution mechanism. Closer to standard, but still poss
not quite right. 

Alias "matching" uses the underlying Jetty path matching approach. The fixes in this version
seem to avoid errant matches i.e. resource contexts with a completely different alias are
no longer called, and matching aliases are now called correctly. There are possibly still
deviations from standard.

Modified:
    felix/trunk/http.jetty/pom.xml
    felix/trunk/http.jetty/src/main/java/org/apache/felix/http/jetty/HttpServiceImpl.java
    felix/trunk/http.jetty/src/main/java/org/apache/felix/http/jetty/ServletContextGroup.java
    felix/trunk/http.jetty/src/main/java/org/mortbay/jetty/servlet/OsgiResourceHolder.java

Modified: felix/trunk/http.jetty/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/http.jetty/pom.xml?rev=704136&r1=704135&r2=704136&view=diff
==============================================================================
--- felix/trunk/http.jetty/pom.xml (original)
+++ felix/trunk/http.jetty/pom.xml Mon Oct 13 07:30:43 2008
@@ -49,17 +49,17 @@
         <dependency>
             <groupId>org.mortbay.jetty</groupId>
             <artifactId>servlet-api-2.5</artifactId>
-            <version>6.1.7</version>
+            <version>6.1.12.rc3</version>
         </dependency>
         <dependency>
             <groupId>org.mortbay.jetty</groupId>
             <artifactId>jetty</artifactId>
-            <version>6.1.7</version>
+            <version>6.1.12.rc3</version>
         </dependency>
         <dependency>
             <groupId>org.mortbay.jetty</groupId>
             <artifactId>jetty-util</artifactId>
-            <version>6.1.7</version>
+            <version>6.1.12.rc3</version>
         </dependency>
     </dependencies>
     <build>

Modified: felix/trunk/http.jetty/src/main/java/org/apache/felix/http/jetty/HttpServiceImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/http.jetty/src/main/java/org/apache/felix/http/jetty/HttpServiceImpl.java?rev=704136&r1=704135&r2=704136&view=diff
==============================================================================
--- felix/trunk/http.jetty/src/main/java/org/apache/felix/http/jetty/HttpServiceImpl.java
(original)
+++ felix/trunk/http.jetty/src/main/java/org/apache/felix/http/jetty/HttpServiceImpl.java
Mon Oct 13 07:30:43 2008
@@ -136,7 +136,12 @@
 
         if ( !aliasValid( alias ) )
         {
-            throw new IllegalArgumentException( "malformed alias" );
+            throw new IllegalArgumentException( "malformed alias: " + alias);
+        }
+        
+        if ( !nameValid( name ) )
+        {
+            throw new IllegalArgumentException( "malformed name: " + name);
         }
 
         // add alias with null details
@@ -238,7 +243,28 @@
 
     protected boolean aliasValid( String alias )
     {
-        if ( !alias.equals( "/" ) && ( !alias.startsWith( "/" ) || alias.endsWith(
"/" ) ) )
+        if (alias == null)
+        {
+            return false;
+        }
+            
+        if (!alias.equals( "/" ) && ( !alias.startsWith( "/" ) || alias.endsWith(
"/" ) ) )
+        {
+            return false;
+        }
+
+        return true;
+    }
+    
+    
+    protected boolean nameValid( String name )
+    {
+        if (name == null)
+        {
+            return false;
+        }
+            
+        if (name.endsWith( "/" ))
         {
             return false;
         }

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=704136&r1=704135&r2=704136&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
Mon Oct 13 07:30:43 2008
@@ -122,7 +122,7 @@
     void addResource( String alias, String path )
     {
         String wAlias = aliasWildcard( alias );
-        ServletHolder holder = new OsgiResourceHolder( m_hdlr, path, this );
+        ServletHolder holder = new OsgiResourceHolder( m_hdlr, alias, path, this );
         m_hdlr.addOsgiServletHolder( wAlias, holder );
         Activator.debug( " adding resources for " + wAlias + " at: " + path );
     }

Modified: felix/trunk/http.jetty/src/main/java/org/mortbay/jetty/servlet/OsgiResourceHolder.java
URL: http://svn.apache.org/viewvc/felix/trunk/http.jetty/src/main/java/org/mortbay/jetty/servlet/OsgiResourceHolder.java?rev=704136&r1=704135&r2=704136&view=diff
==============================================================================
--- felix/trunk/http.jetty/src/main/java/org/mortbay/jetty/servlet/OsgiResourceHolder.java
(original)
+++ felix/trunk/http.jetty/src/main/java/org/mortbay/jetty/servlet/OsgiResourceHolder.java
Mon Oct 13 07:30:43 2008
@@ -51,9 +51,10 @@
     private ServletContextGroup m_servletContextGroup;
     private HttpContext m_osgiHttpContext;
     private AccessControlContext m_acc;
+    private String m_path;
 
 
-    public OsgiResourceHolder( ServletHandler handler, String name, ServletContextGroup servletContextGroup
)
+    public OsgiResourceHolder( ServletHandler handler, String name, String path, ServletContextGroup
servletContextGroup )
     {
         super();
 
@@ -62,7 +63,12 @@
 
         m_servletContextGroup = servletContextGroup;
         m_osgiHttpContext = servletContextGroup.getOsgiHttpContext();
-
+        m_path = path;
+        if (m_path == null)
+        {
+            m_path = "";
+        }
+        
         if ( System.getSecurityManager() != null )
         {
             m_acc = AccessController.getContext();
@@ -91,11 +97,17 @@
         // get the relative path (assume empty path if there is no path info)
         // (FELIX-503)
         String target = request.getPathInfo();
-        if (target == null) {
+        if (target == null) 
+        {
             target = "";
         }
+        
+        if (!target.startsWith("/"))
+        {
+            target += "/" + target;
+        }
 
-        Activator.debug( "handle for name:" + getName() + "(path=" + target + ")" );
+        Activator.debug( "handle for name:" + m_path + " (path=" + target + ")" );
 
         if ( !m_osgiHttpContext.handleSecurity( request, response ) )
         {
@@ -103,7 +115,7 @@
         }
 
         // Create resource based name and see if we can resolve it
-        String resName = getName() + target;
+        String resName = m_path + target;
         Activator.debug( "** looking for: " + resName );
         URL url = m_osgiHttpContext.getResource( resName );
 
@@ -267,11 +279,14 @@
     {
         long lastModified = 0;
         
+        System.out.println("url: " + resUrl);
+        
         try 
         {
             // Get last modified time
             URLConnection conn = resUrl.openConnection();
             lastModified = conn.getLastModified();
+            System.out.println("modified - " + lastModified);
         } 
         catch (Exception e) 
         {



Mime
View raw message