Resource Resolution PluginsPage added by Felix MeschbergerResource Resolution PluginsStatus: DRAFT IntroductionThe current support for flexible resource resolution as described in Mappings for Resource Resolution only supports simple regular expressions for mapping Request URLs into resource paths. These mappings do not take into consideration any request headers – e.g. the Accept-Language header – or any request parameters. There might be use cases which require more flexibility. For example SLING-1198 proposes an enhancement for the matching algorithm. This page provides a proposal to enhance the resource resolution by defining plugin interfaces. ConceptCurrently each entry below /etc/map may contain the following configuration:
This allows for the current regular _expression_ based mapping. I propose to define a new property which allows for the specification of a plugin: sling:plugin – This (single-value) property defines the service reference filter to use to find a resource resolution plugin. If this is a simple string it is used to find a resource resolution plugin whose sling.plugin service property is set to this string. The resource resolution plugin is actually a factory for the actual plugin instances used during the resolution procies. The resource resolution plugin addressed by the sling:plugin property must be registered as an OSGi service with the service name ResourceResolutionPlugin. If the sling:plugin property is not set, the default resource resolution plugin, which is the current regular _expression_ based mapping. Upon reading the configuration from /etc/map (and other sources like the current sling:vanityPath properties and the existing configurtion) a list of resource resolution plugins is built. When resolving a request URL to a resource, the list is walked and each plugin is in turn asked, whether it matches the request and can provide a resource mapping. Likewise when mapping resource paths to request URLs the list is walked and the plugin is asked whether it matches the path and can provide a mapped URL. InterfacesResourceResolutionPlugin.java public interface ResourceResolutionPlugin { static final String SERVICE = "ResourceResolutionPlugin"; /** * Return a new resource resolution plugin instance configured * from the given configuration. This ValueMap is created from the * resource below /etc/map which instructs this plugin to be used. */ ResourceResolutionInstance newInstance(ValueMap configuration); } ResourceResolutionInstance.java public interface ResourceResolutionInstance { /** * Return redirect information with respect to the * request and the path or null if this instance * cannot handle the path. */ RedirectInfo resolve(ResourceResolver resolver, HttpServletRequest request, String path); /** * Return an URL string or null if this instance cannot * map the path. */ String map(ResourceResolver resolver, HttpServletRequest request, String path); } RedirectInfo.java // this may also be a class ... public interface RedirectInfo { /** * Returns the resource to which the path resolved. This must * only return a non-null value if getRedirect() returns null. */ Resource getResource(); /** * Returns the redirect target to which the path resolved. This * must only return a non-null value if getResource() returns * null. */ String getRedirect(); /** * The HTTP status code to use for the redirect to the target * given by getRedirect(). This should only be considered valid * if getRedirect() returns a non-null value. int getStatus(); }
Change Notification Preferences
View Online
|
Add Comment
|
- [CONF] Apache Sling > Resource Resolution Plugins confluence
