|
Page Edited :
SLING :
URL to Script Resolution
URL to Script Resolution has been edited by Alexander Klimetschek (Jul 14, 2008). Content:
This page explains how Sling maps URLs to a script or and servlet. First of all Sling looks up the resource identified by the URL - typically a path inside the JCR repository, which is annotated by the sling:resourceType property which defines the resource type of that resource. Using this resource type (which is kind of a relative path, eg. "myblog/comment"), scripts or servlets are looked up. Scripts and servlets are itself resource in Sling and thus have a resource path: this is either the location in the JCR repository, the resource type in a servlet component configuration or the "virtual" bundle resource path (if a script is provided inside a bundle without being installed into the JCR repository). TODO: explain super types, servlet path mappings, node type resource types (my:type -> my/type) (0) Fundamental: Scripts and Servlets are equalIn the following discussion, I will write about scripts. This will always include servlets as well. In fact, internally, Sling only handles with Servlets, whereas scripts are packed inside a Servlet wrapping and representing the script. (I) Base: Resource Type InheritanceWhile not exactly part of our discussion, resource type inheritance as implemented for SLING-278 Each resource type may have a resource super type, which may be defined in various ways. One example is having a sling:resourceSuperType property in the node addressed by the resource type. See http://www.mail-archive.com/[EMAIL PROTECTED]/msg02365.html If a resource type has no explicit resource super type, the resource super type is assumed to be "sling/servlet/default". That is the resource type used for default script selection is also acting as a basic resource type much like java.lang.Object does for other types in the Java language. (II) Script LocationsScripts are looked up in a series of locations defined by the ResourceResolver.getSearchPath() and the resource type (and resource super types) of the requested resource: {scriptPathPrefix}/{resourceTypePath}
The pseudo code for iterating the locations would be something like:
The constituents of these script names are as follows:
(V) PriorityThe rules for script path priorization is defined as follows:
(VI) ExamplesTaking up again the list of potential script paths for a request of a resource whose resource type is sling:sample and the request selectors are "print.a4" and the request extension is "html" could be:
The priority of script selection would (6) - (4) - (5) - (3) - (2) - (1) - (0). Note that (4) is a better match than (5) because it matches more selectors even though (5) has an extension match where (4) does not. |
Unsubscribe or edit your notifications preferences
