in src/main/java/org/apache/sling/servlets/resolver/internal/helper/ResourceCollector.java [245:305]
protected void getWeightedResources(final Set<WeightedResource> resources, final Resource location) {
final ResourceResolver resolver = location.getResourceResolver();
Resource current = location;
String parentName = current.getName();
int selIdx = 0;
String selector;
do {
selector = (selIdx < numRequestSelectors) ? requestSelectors[selIdx] : null;
List<Resource> children = getChildrenList(current, isDefaultExtension);
for (Resource child : children) {
if (!SlingServletResolver.isPathAllowed(child.getPath(), this.executionPaths)) {
continue;
}
String scriptName = child.getName();
int lastDot = scriptName.lastIndexOf('.');
if (lastDot < 0) {
// no extension in the name, this is not a script
continue;
}
scriptName = scriptName.substring(0, lastDot);
if (isGet
&& checkScriptName(scriptName, selector, parentName, suffExt, null, resources, child, selIdx)) {
continue;
}
if (checkScriptName(
scriptName, selector, parentName, suffExtMethod, suffMethod, resources, child, selIdx)) {
continue;
}
// SLING-754: Not technically really correct because
// the request extension is only optional in the script
// name for HTML methods, but we keep this for backwards
// compatibility.
if (selector != null && matches(scriptName, selector, suffMethod)) {
addWeightedResource(resources, child, selIdx + 1, WeightedResource.WEIGHT_NONE);
continue;
}
if (scriptName.equals(methodName)) {
addWeightedResource(resources, child, selIdx, WeightedResource.WEIGHT_NONE);
}
}
if (selector != null) {
current = resolver.getResource(current, selector);
parentName = selector;
selIdx++;
}
} while (selector != null && current != null);
// special treatment for servlets registered with neither a method
// name nor extensions and selectors
addLocationServlet(resources, location);
}