Child pages
  • Resource Resolution Plugins
Skip to end of metadata
Go to start of metadata

Resource Resolution Plugins

Status: DRAFT
Created: 30. November 2009
Author: fmeschbe
JIRA: –
References: Mappings for Resource Resolution, SLING-1198
Update: –

Introduction

The 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.

Concept

Currently each entry below /etc/map may contain the following configuration:

Property

Description

sling:match

This property when set on a node in the /etc/map tree (see below) defines a partial regular expression which is used instead of the node's name to match the incoming request. This property is only needed if the regular expression includes characters which are not valid JCR name characters. The list of invalid characters for JCR names is: /, :, ,, *, ', ", | and any whitespace except blank space. In addition a name without a name space may not be . or .. and a blank space is only allowed inside the name.

sling:redirect

This property when set on a node in the /etc/map tree (see below) causes a redirect response to be sent to the client, which causes the client to send in a new request with the modified location. The value of this property is applied to the actual request and sent back as the value of Location response header.

sling:status

This property defines the HTTP status code sent to the client with the sling:redirect response. If this property is not set, it defaults to 302 (Found). Other status codes supported are 300 (Multiple Choices), 301 (Moved Permanently), 303 (See Other), and 307 (Temporary Redirect).

sling:internalRedirect

This property when set on a node in the /etc/map tree (see below) causes the current path to be modified internally to continue with resource resoltion.

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.

Interfaces

ResourceResolutionPlugin.java
ResourceResolutionInstance.java
RedirectInfo.java
  • No labels

1 Comment

  1. It's sounds good you described the Resolver plugin interface. Could I start to ipmlement this interface as you described? Some of my real application project need it. (Or I can hack it - but I don't like to hack (smile)