path-based resource types: JcrDefaultResourceTypeProvider service

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

path-based resource types: JcrDefaultResourceTypeProvider service

Bertrand Delacretaz
Hi,

Two of my colleagues are working on apps where path-based resource
types would be useful.

The typical use case is existing content in a JCR repository, where it
is not practical to add a sling:resourceType property to each node,
but where paths can be used to infer resource types.

Another use case is for simple examples and tutorials, where for
example nodes under /content/blog can be mapped to scripts found under
/apps/blog without requiring a sling:resourceType property (which
would be explained in a later phase of the tutorial).

I had a brief chat with Felix about this, we suggest adding a
JcrDefaultResourceTypeProvider interface (in o.a.s.jcr.resource), with
a getResourceTypeForItem(Item) method.

JcrDefaultResourceTypeProvider can then be used as an OSGi service, to
define the resourceType of a JCR Item being loaded, as follows:

1) Use the sling:resourceType if provided (unchanged)

2) Else, use the JcrDefaultResourceTypeProvider service if present

3) Else, use the node's primary type name (unchanged)

A default JcrDefaultResourceTypeProvider implementation is provided by
Sling (in a separate bundle, to make it easy to replace), which maps
Node paths to resource types using a configurable expression, for
paths that match another configurable regexp.

Comments are welcome - I'll create a first implementation today, but
that can of course change if there are better ideas.

-Bertrand

Reply | Threaded
Open this post in threaded view
|

Re: path-based resource types: JcrDefaultResourceTypeProvider service

Bertrand Delacretaz
On Tue, Mar 25, 2008 at 11:09 AM, Bertrand Delacretaz
<[hidden email]> wrote:

> ...I'll create a first implementation today...

see https://issues.apache.org/jira/browse/SLING-340

-Bertrand