remm        01/01/24 14:39:57

  Modified:    catalina/src/share/org/apache/catalina/core
                        ApplicationContext.java
  Log:
  - Reimplement ServletContext.getResourcePaths() using directory contexts
    (instead of Resources).
  
  Revision  Changes    Path
  1.12      +36 -13    
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ApplicationContext.java
  
  Index: ApplicationContext.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ApplicationContext.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ApplicationContext.java   2001/01/23 06:14:20     1.11
  +++ ApplicationContext.java   2001/01/24 22:39:56     1.12
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ApplicationContext.java,v
 1.11 2001/01/23 06:14:20 remm Exp $
  - * $Revision: 1.11 $
  - * $Date: 2001/01/23 06:14:20 $
  + * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ApplicationContext.java,v
 1.12 2001/01/24 22:39:56 remm Exp $
  + * $Revision: 1.12 $
  + * $Date: 2001/01/24 22:39:56 $
    *
    * ====================================================================
    *
  @@ -75,6 +75,8 @@
   import java.util.HashMap;
   import java.util.HashSet;
   import java.util.Set;
  +import javax.naming.NamingException;
  +import javax.naming.Binding;
   import javax.naming.directory.DirContext;
   import javax.servlet.RequestDispatcher;
   import javax.servlet.Servlet;
  @@ -105,7 +107,7 @@
    *
    * @author Craig R. McClanahan
    * @author Remy Maucherat
  - * @version $Revision: 1.11 $ $Date: 2001/01/23 06:14:20 $
  + * @version $Revision: 1.12 $ $Date: 2001/01/24 22:39:56 $
    */
   
   public final class ApplicationContext
  @@ -475,19 +477,18 @@
       public Set getResourcePaths() {
   
           ResourceSet set = new ResourceSet();
  -        // FIXME !
  -        /*
  -        Resources resources = context.getResources();
  +        DirContext resources = context.getResources();
           if (resources == null) {
               set.setLocked(true);
               return (set);
  +        }
  +        
  +        try {
  +            listPaths(set, resources, "");
  +        } catch (NamingException e) {
  +            // Ignore
           }
  -        String paths[] = resources.getResourcePaths();
  -        if (paths == null)
  -            paths = new String[0];
  -        for (int i = 0; i < paths.length; i++)
  -            set.add(paths[i]);
  -        */
  +        
           set.setLocked(true);
           return (set);
   
  @@ -728,6 +729,28 @@
               }
           }
           parameters = results;
  +
  +    }
  +
  +
  +    /**
  +     * List resource paths (recursively), and store all of them in the given 
  +     * Set.
  +     */
  +    private static void listPaths(Set set, DirContext resources, String path) 
  +        throws NamingException {
  +
  +        Enumeration childPaths = resources.listBindings(path);
  +        while (childPaths.hasMoreElements()) {
  +            Binding binding = (Binding) childPaths.nextElement();
  +            String name = binding.getName();
  +            String childPath = path + "/" + name;
  +            set.add(childPath);
  +            Object object = binding.getObject();
  +            if (object instanceof DirContext) {
  +                listPaths(set, resources, childPath);
  +            }
  +        }
   
       }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to