SLING-872 : Use manifest header parser to parse entries and handle new path directive if available.
git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk@747467 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceProvider.java b/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceProvider.java
index 2cbee15..8f8e1f2 100644
--- a/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceProvider.java
+++ b/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceProvider.java
@@ -24,7 +24,6 @@
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
-import java.util.StringTokenizer;
import javax.servlet.http.HttpServletRequest;
@@ -32,6 +31,7 @@
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceProvider;
import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.commons.osgi.ManifestHeader;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
@@ -54,12 +54,15 @@
*/
public BundleResourceProvider(Bundle bundle, String rootList) {
this.bundle = new BundleResourceCache(bundle);
-
- StringTokenizer pt = new StringTokenizer(rootList, ", \t\n\r\f");
List<MappedPath> prefixList = new ArrayList<MappedPath>();
- while (pt.hasMoreTokens()) {
- String resourceRoot = pt.nextToken();
- if (resourceRoot.length() > 0) {
+
+ final ManifestHeader header = ManifestHeader.parse(rootList);
+ for(final ManifestHeader.Entry entry : header.getEntries()) {
+ final String resourceRoot = entry.getValue();
+ final String pathDirective = entry.getDirectiveValue("path");
+ if ( pathDirective != null ) {
+ prefixList.add(new MappedPath(resourceRoot, pathDirective));
+ } else {
prefixList.add(MappedPath.create(resourceRoot));
}
}
@@ -69,7 +72,7 @@
void registerService(BundleContext context) {
Dictionary<String, Object> props = new Hashtable<String, Object>();
props.put(Constants.SERVICE_DESCRIPTION,
- "Provider of Bundle based Resources");
+ "Provider of bundle based resources");
props.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation");
props.put(ROOTS, getRoots());