remm 01/03/16 15:31:01
Modified: catalina/src/share/org/apache/catalina/core
ApplicationContext.java
Log:
- Add new servlet API call : getResourcePaths(String path) which can be used
to get an immutable Set listing the members of a collection.
Revision Changes Path
1.16 +55 -4
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.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- ApplicationContext.java 2001/02/05 05:41:57 1.15
+++ ApplicationContext.java 2001/03/16 23:30:58 1.16
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ApplicationContext.java,v
1.15 2001/02/05 05:41:57 remm Exp $
- * $Revision: 1.15 $
- * $Date: 2001/02/05 05:41:57 $
+ * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ApplicationContext.java,v
1.16 2001/03/16 23:30:58 remm Exp $
+ * $Revision: 1.16 $
+ * $Date: 2001/03/16 23:30:58 $
*
* ====================================================================
*
@@ -111,7 +111,7 @@
*
* @author Craig R. McClanahan
* @author Remy Maucherat
- * @version $Revision: 1.15 $ $Date: 2001/02/05 05:41:57 $
+ * @version $Revision: 1.16 $ $Date: 2001/03/16 23:30:58 $
*/
public final class ApplicationContext
@@ -574,6 +574,34 @@
/**
+ * Return a Set containing the resource paths of resources member of the
+ * specified collection. Each path will be a String starting with
+ * a "/" character. The returned set is immutable.
+ *
+ * @param path Collection path
+ */
+ public Set getResourcePaths(String path) {
+
+ ResourceSet set = new ResourceSet();
+ DirContext resources = context.getResources();
+ if (resources == null) {
+ set.setLocked(true);
+ return (set);
+ }
+
+ try {
+ listCollectionPaths(set, resources, path);
+ } catch (NamingException e) {
+ // Ignore
+ }
+
+ set.setLocked(true);
+ return (set);
+
+ }
+
+
+ /**
* Return the name and version of the servlet container.
*/
public String getServerInfo() {
@@ -828,6 +856,29 @@
if (object instanceof DirContext) {
listPaths(set, resources, childPath);
}
+ }
+
+ }
+
+
+ /**
+ * List resource paths (recursively), and store all of them in the given
+ * Set.
+ */
+ private static void listCollectionPaths
+ (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;
+ Object object = binding.getObject();
+ if (object instanceof DirContext) {
+ childPath = childPath + "/";
+ }
+ set.add(childPath);
}
}