org.apache.sling.servlets.resolver.internal.helper
Class AbstractResourceCollector

java.lang.Object
  extended by org.apache.sling.servlets.resolver.internal.helper.AbstractResourceCollector
Direct Known Subclasses:
NamedScriptResourceCollector, ResourceCollector

public abstract class AbstractResourceCollector
extends Object

The ResourceCollector class provides a single public method - getServlets(ResourceResolver) - which is used to find an ordered collection of Resource instances which may be used to find a servlet or script to handle a request to the given resource.


Field Summary
protected  String baseResourceType
           
protected  String[] executionPaths
           
protected  String extension
           
protected  int hashCode
           
protected  String resourceSuperType
           
protected  String resourceType
           
protected  String workspaceName
           
 
Constructor Summary
AbstractResourceCollector(String baseResourceType, String resourceType, String resourceSuperType, String workspaceName, String extension, String[] executionPaths)
           
 
Method Summary
protected  void addWeightedResource(Set<Resource> resources, Resource resource, int numSelectors, int methodPrefixWeight)
          Creates a WeightedResource and adds it to the set of resources.
 boolean equals(Object obj)
           
protected  Resource getResource(ResourceResolver resolver, String path)
          Returns a resource for the given path.
 Collection<Resource> getServlets(ResourceResolver resolver)
           
protected abstract  void getWeightedResources(Set<Resource> resources, Resource location)
           
 int hashCode()
           
protected  boolean isPathAllowed(String path)
           
static boolean isPathAllowed(String path, String[] executionPaths)
          This method checks whether a path is allowed to be executed.
protected  boolean stringEquals(String s1, String s2)
          Helper method to compare two strings which can possibly be null
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

baseResourceType

protected final String baseResourceType

extension

protected final String extension

hashCode

protected int hashCode

resourceType

protected final String resourceType

resourceSuperType

protected final String resourceSuperType

executionPaths

protected final String[] executionPaths

workspaceName

protected final String workspaceName
Constructor Detail

AbstractResourceCollector

public AbstractResourceCollector(String baseResourceType,
                                 String resourceType,
                                 String resourceSuperType,
                                 String workspaceName,
                                 String extension,
                                 String[] executionPaths)
Method Detail

getServlets

public final Collection<Resource> getServlets(ResourceResolver resolver)

getWeightedResources

protected abstract void getWeightedResources(Set<Resource> resources,
                                             Resource location)

addWeightedResource

protected final void addWeightedResource(Set<Resource> resources,
                                         Resource resource,
                                         int numSelectors,
                                         int methodPrefixWeight)
Creates a WeightedResource and adds it to the set of resources. The number of resources already present in the set is used as the ordinal number for the newly created resource.

Parameters:
resources - The set of resource to which the WeightedResource is added.
resource - The Resource on which the WeightedResource is based.
numSelectors - The number of request selectors which are matched by the name of the resource.
methodPrefixWeight - The method/prefix weight assigned to the resource according to the resource name.

getResource

protected final Resource getResource(ResourceResolver resolver,
                                     String path)
Returns a resource for the given path. If no resource exists at the given path a SyntheticResource is returned.

Parameters:
resolver - The ResourceResolver used to access the resource.
path - The absolute path of the resource to return.
Returns:
The actual resource at the given path or a synthetic resource representing the path location.

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

stringEquals

protected boolean stringEquals(String s1,
                               String s2)
Helper method to compare two strings which can possibly be null


isPathAllowed

protected boolean isPathAllowed(String path)

isPathAllowed

public static boolean isPathAllowed(String path,
                                    String[] executionPaths)
This method checks whether a path is allowed to be executed.



Copyright © 2007-2013 The Apache Software Foundation. All Rights Reserved.