You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Felix Meschberger <fm...@gmail.com> on 2009/01/23 21:52:57 UTC

JAX-RS Support (was: Script Naming Convention)

Hi Jim,

Sorry for the delay ...

Jim White schrieb:
> Felix Meschberger wrote:
> 
>> Hi Jim,
>>
>> Jim White schrieb:
>>
>>> Hi gang!
>>>
>>> The way I'd like to provide path mapping for classes is with JAX-RS
>>> (Jersey) annontations.
>>
>> Support for this would be a great addition to Sling IMHO.
> 
> Great minds and all... ;-)
> 
>>> That should be pretty straightforward for compiled bundles, but I think
>>> it can work for scripts too (at least Groovy scripts anyhow).
>>
>> For scripts (in general) it is a bit more problematic and I think a
>> different problem scope. Let me take a quick tour how Sling works.
>> ...
> 
> If I wanted to have a mechanism so that whenever a script is
> added/updated (and probably on server startup too) in the repository
> (presumably in some designated part of the tree) that it gets executed,
> where should I look for API and/or related code?
> 
> My thought is basically a script-based extension mechanism rather than
> requiring bundles.

If I understand you correctly, you would designate a location, say
/apps/jax-rs, where you would put the scripts with JAX-RS annotations.
Then some listener would pick the script up, interpret the tags for the
path and the methods and would register them as Resources in a similar
way as the ServletResolver does with the ServletResourceProvider.

In other words: You need a JAXRSResourceProvider, which observes (by JCR
observation) a special location for entries. For each entry, the JAX-RS
annotations are analyzed and respective Resources are provided through
the JAXRSResourceProvider.

> 
> The use case being once Jersey is integrated (which would be with a
> bundle I expect - although we've been using Ivy with Groovy to
> dynamically load dependencies for Groovy scripts), I could add/update
> services by just editing a Groovy script with JAX-RS annotations.

Yes, I would assume JAX-RS support would probably be implemented in a
bundle. Though I am not sure right now, how much we would have to
integrate it with the servlet resolver...

Regards
Felix