You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ra...@apache.org on 2020/04/03 21:15:56 UTC
[sling-org-apache-sling-scripting-bundle-tracker] branch master
updated: SLING-9330 - Path registrations override the servlet resources for
parent resource types
This is an automated email from the ASF dual-hosted git repository.
radu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-bundle-tracker.git
The following commit(s) were added to refs/heads/master by this push:
new 26fdcfb SLING-9330 - Path registrations override the servlet resources for parent resource types
26fdcfb is described below
commit 26fdcfb28436ebe9fa5cd09bf8e57297d078b572
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Fri Apr 3 23:15:01 2020 +0200
SLING-9330 - Path registrations override the servlet resources for parent resource types
* register servlet by path only if the executable is provided by the current bundle
or if the current capability indicates a path registration
---
.../tracker/internal/BundledScriptTracker.java | 27 ++++++++++------------
1 file changed, 12 insertions(+), 15 deletions(-)
diff --git a/src/main/java/org/apache/sling/scripting/bundle/tracker/internal/BundledScriptTracker.java b/src/main/java/org/apache/sling/scripting/bundle/tracker/internal/BundledScriptTracker.java
index 73c7cf2..5d51820 100644
--- a/src/main/java/org/apache/sling/scripting/bundle/tracker/internal/BundledScriptTracker.java
+++ b/src/main/java/org/apache/sling/scripting/bundle/tracker/internal/BundledScriptTracker.java
@@ -173,7 +173,15 @@ public class BundledScriptTracker implements BundleTrackerCustomizer<List<Servic
List<ServiceRegistration<Servlet>> regs = new ArrayList<>();
if (executable != null) {
- properties.put(ServletResolverConstants.SLING_SERVLET_PATHS, executable.getPath());
+ Executable finalExecutable = executable;
+ servletCapability.getResourceTypes().forEach(resourceType -> {
+ if (finalExecutable.getPath().startsWith(resourceType.toString() + "/")) {
+ properties.put(ServletResolverConstants.SLING_SERVLET_PATHS, finalExecutable.getPath());
+ }
+ });
+ if (executable.getPath().equals(servletCapability.getPath())) {
+ properties.put(ServletResolverConstants.SLING_SERVLET_PATHS, executable.getPath());
+ }
regs.add(
bundle.getBundleContext().registerService(
Servlet.class,
@@ -384,20 +392,9 @@ public class BundledScriptTracker implements BundleTrackerCustomizer<List<Servic
if (extendedResourceType.equals(resourceType.getType())) {
Bundle providingBundle = wire.getProvider().getBundle();
providers.add(new TypeProvider(wiredCapability, providingBundle));
- for (BundleWire providedWire : wire.getProvider().getWiring().getRequiredWires(NS_SLING_SERVLET)) {
- ServletCapability servletCapability =
- ServletCapability.fromBundleCapability(providedWire.getCapability());
- String capabilityExtends = servletCapability.getExtendedResourceType();
- for (ResourceType providedResourceType : servletCapability.getResourceTypes()) {
- if (providedResourceType.getType().equals(extendedResourceType) && servletCapability.getSelectors().isEmpty()) {
- if (StringUtils.isNotEmpty(capabilityExtends)) {
- collectProvidersChain(providers, providedWire.getProvider().getBundle().adapt(BundleWiring.class),
- capabilityExtends);
- } else {
- providers.add(new TypeProvider(servletCapability, providedWire.getProvider().getBundle()));
- }
- }
- }
+ String wiredExtends = wiredCapability.getExtendedResourceType();
+ if (StringUtils.isNotEmpty(wiredExtends)) {
+ collectProvidersChain(providers, wire.getProviderWiring(), wiredExtends);
}
}
}