You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2017/05/08 13:48:57 UTC
svn commit: r1794371 - in /sling/trunk/bundles/extensions/bundleresource:
pom.xml
src/main/java/org/apache/sling/bundleresource/impl/BundleResourceProvider.java
src/main/java/org/apache/sling/bundleresource/impl/BundleResourceWebConsolePlugin.java
Author: cziegeler
Date: Mon May 8 13:48:57 2017
New Revision: 1794371
URL: http://svn.apache.org/viewvc?rev=1794371&view=rev
Log:
SLING-6842 : Migrate to parent pom 30
Modified:
sling/trunk/bundles/extensions/bundleresource/pom.xml
sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceProvider.java
sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceWebConsolePlugin.java
Modified: sling/trunk/bundles/extensions/bundleresource/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/bundleresource/pom.xml?rev=1794371&r1=1794370&r2=1794371&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/bundleresource/pom.xml (original)
+++ sling/trunk/bundles/extensions/bundleresource/pom.xml Mon May 8 13:48:57 2017
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.sling</groupId>
<artifactId>sling</artifactId>
- <version>26</version>
+ <version>30</version>
<relativePath/>
</parent>
@@ -59,32 +59,24 @@
<Bundle-Activator>
org.apache.sling.bundleresource.impl.Activator
</Bundle-Activator>
- <Private-Package>
- org.apache.sling.bundleresource.*,
- org.osgi.util.tracker
- </Private-Package>
</instructions>
</configuration>
</plugin>
- </plugins>
- </build>
- <reporting>
- <plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<excludePackageNames>
- org.apache.sling.bundleresource
+ org.apache.sling.bundleresource.impl
</excludePackageNames>
</configuration>
</plugin>
</plugins>
- </reporting>
+ </build>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
+ <artifactId>javax.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
@@ -100,12 +92,7 @@
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <scope>compile</scope>
+ <artifactId>osgi.core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.jackrabbit</groupId>
Modified: sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceProvider.java?rev=1794371&r1=1794370&r2=1794371&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceProvider.java (original)
+++ sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceProvider.java Mon May 8 13:48:57 2017
@@ -47,14 +47,30 @@ public class BundleResourceProvider impl
private ServiceRegistration serviceRegistration;
+ public static MappedPath[] getRoots(final Bundle bundle, final String rootList) {
+ List<MappedPath> prefixList = new ArrayList<>();
+
+ 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));
+ }
+ }
+ return prefixList.toArray(new MappedPath[prefixList.size()]);
+ }
+
/**
* Creates Bundle resource provider accessing entries in the given Bundle an
* supporting resources below root paths given by the rootList which is a
* comma (and whitespace) separated list of absolute paths.
*/
- public BundleResourceProvider(Bundle bundle, String rootList) {
+ public BundleResourceProvider(final Bundle bundle, final String rootList) {
this.bundle = new BundleResourceCache(bundle);
- List<MappedPath> prefixList = new ArrayList<MappedPath>();
+ List<MappedPath> prefixList = new ArrayList<>();
final ManifestHeader header = ManifestHeader.parse(rootList);
for (final ManifestHeader.Entry entry : header.getEntries()) {
@@ -66,13 +82,13 @@ public class BundleResourceProvider impl
prefixList.add(MappedPath.create(resourceRoot));
}
}
- this.roots = prefixList.toArray(new MappedPath[prefixList.size()]);
+ this.roots = getRoots(bundle, rootList);
}
//---------- Service Registration
-
+
long registerService(BundleContext context) {
- Dictionary<String, Object> props = new Hashtable<String, Object>();
+ Dictionary<String, Object> props = new Hashtable<>();
props.put(Constants.SERVICE_DESCRIPTION,
"Provider of bundle based resources");
props.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation");
@@ -88,9 +104,10 @@ public class BundleResourceProvider impl
serviceRegistration.unregister();
}
}
-
+
// ---------- ResourceProvider interface
+ @Override
public Resource getResource(ResourceResolver resourceResolver,
HttpServletRequest request, String path) {
return getResource(resourceResolver, path);
@@ -101,6 +118,7 @@ public class BundleResourceProvider impl
* bundle of this provider. The JcrResourceResolver is ignored by this
* implementation.
*/
+ @Override
public Resource getResource(ResourceResolver resourceResolver, String path) {
MappedPath mappedPath = getMappedPath(path);
if (mappedPath != null) {
@@ -111,13 +129,14 @@ public class BundleResourceProvider impl
return null;
}
+ @Override
public Iterator<Resource> listChildren(final Resource parent)
throws SlingException {
- if (parent instanceof BundleResource && ((BundleResource)parent).getBundle() == this.bundle) {
+ if (parent instanceof BundleResource && ((BundleResource)parent).getBundle() == this.bundle) {
// bundle resources can handle this request directly when the parent
// resource is in the same bundle as this provider.
- return ((BundleResource) parent).listChildren();
+ return ((BundleResource) parent).listChildren();
}
// ensure this provider may have children of the parent
Modified: sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceWebConsolePlugin.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceWebConsolePlugin.java?rev=1794371&r1=1794370&r2=1794371&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceWebConsolePlugin.java (original)
+++ sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceWebConsolePlugin.java Mon May 8 13:48:57 2017
@@ -49,7 +49,7 @@ class BundleResourceWebConsolePlugin ext
private ServiceTracker providerTracker;
- private List<BundleResourceProvider> provider = new ArrayList<BundleResourceProvider>();
+ private List<BundleResourceProvider> provider = new ArrayList<>();
//--------- setup and shutdown
@@ -172,11 +172,10 @@ class BundleResourceWebConsolePlugin ext
};
providerTracker.open();
- Dictionary<String, Object> props = new Hashtable<String, Object>();
+ Dictionary<String, Object> props = new Hashtable<>();
props.put(Constants.SERVICE_DESCRIPTION,
"Web Console Plugin for Bundle Resource Providers");
props.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation");
- props.put(Constants.SERVICE_PID, getClass().getName());
props.put("felix.webconsole.label", LABEL);
props.put("felix.webconsole.title", "Bundle Resource Provider");
props.put("felix.webconsole.category", "Sling");
@@ -198,7 +197,7 @@ class BundleResourceWebConsolePlugin ext
}
private String getName(Bundle bundle) {
- String name = (String) bundle.getHeaders().get(Constants.BUNDLE_NAME);
+ String name = bundle.getHeaders().get(Constants.BUNDLE_NAME);
if (name == null) {
name = bundle.getSymbolicName();
if (name == null) {