Added support for "/" bundle resources as requested in FELIX-383. Not
super useful, but...
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@588499 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/searchpolicy/ContentLoaderImpl.java b/framework/src/main/java/org/apache/felix/framework/searchpolicy/ContentLoaderImpl.java
index 667d733..574e363 100644
--- a/framework/src/main/java/org/apache/felix/framework/searchpolicy/ContentLoaderImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/searchpolicy/ContentLoaderImpl.java
@@ -130,8 +130,15 @@
{
URL url = null;
- // Remove leading slash, if present.
- if (name.startsWith("/"))
+ // Remove leading slash, if present, but special case
+ // "/" so that it returns a root URL...this isn't very
+ // clean or meaninful, but the Spring guys want it.
+ if (name.equals("/"))
+ {
+ // Just pick a class path index since it doesn't really matter.
+ url = getURLPolicy().createURL(1, name);
+ }
+ else if (name.startsWith("/"))
{
name = name.substring(1);
}
@@ -154,24 +161,37 @@
{
Vector v = new Vector();
- // Remove leading slash, if present.
- if (name.startsWith("/"))
+ // Special case "/" so that it returns a root URLs for
+ // each bundle class path entry...this isn't very
+ // clean or meaninful, but the Spring guys want it.
+ if (name.equals("/"))
{
- name = name.substring(1);
- }
-
- // Check the module class path.
- for (int i = 0; i < getClassPath().length; i++)
- {
- if (getClassPath()[i].hasEntry(name))
+ for (int i = 0; i < getClassPath().length; i++)
{
- // Use the class path index + 1 for creating the path so
- // that we can differentiate between module content URLs
- // (where the path will start with 0) and module class
- // path URLs.
v.addElement(getURLPolicy().createURL(i + 1, name));
}
}
+ else
+ {
+ // Remove leading slash, if present.
+ if (name.startsWith("/"))
+ {
+ name = name.substring(1);
+ }
+
+ // Check the module class path.
+ for (int i = 0; i < getClassPath().length; i++)
+ {
+ if (getClassPath()[i].hasEntry(name))
+ {
+ // Use the class path index + 1 for creating the path so
+ // that we can differentiate between module content URLs
+ // (where the path will start with 0) and module class
+ // path URLs.
+ v.addElement(getURLPolicy().createURL(i + 1, name));
+ }
+ }
+ }
return v.elements();
}