2011/3/28 Olivier Grisel <[email protected]>:
> 2011/3/28 Bertrand Delacretaz <[email protected]>:
>> Hi,
>>
>> On Mon, Mar 28, 2011 at 11:57 AM, Olivier Grisel
>> <[email protected]> wrote:
>>> 2011/3/28 Rupert Westenthaler <[email protected]>:
>>>>... I would suggest to define a "stanbol.home" and interpret such path
>>>> relative to this folder.
>>>> Bundles that use the commons.web bundle would than to make sure (e.g.
>>>> in the activate method) to copy such files to the specified directory.
>>>
>>> Yes it's probably simpler to copy all the contributed static resources
>>> ( JS, css, logos and style images ...), and freemarker templates into
>>> a two dedicated folders under the sling folder of the stanbol instance
>>> at bundle activation time and register those folders for static
>>> resource lookup and for the FreemarkerViewProcessor....
>>
>> This sounds mildly scary - what happens for example when a bundle is
>> removed, or upgraded?
>>
>> I'm not too familiar with how JAX-RS accesses its resources, couldn't
>> that be delegated to an OSGi service?
>
> I have to check for the static resources. For the Freemarker
> templates, the lookup is completely pluggable and could therefore be
> delegated to an OSGi service that implements the template loader
> interface:
>
> http://freemarker.sourceforge.net/docs/pgui_config_templateloading.html
>
> It could furthermore leverage the MultiTemplateLoader implementation
> to delegate the lookup to ClassTemplateLoader for each contribution in
> order of registration.
For the static resource we use:
httpService.registerResources(staticUrlRoot, staticClasspath, null);
where currently staticUrlRoot is "/static" and staticClasspath is
"/META-INF/static".
One could have each contribution host their static resources in a
specific named java package (e.g.
org.apache.stanbol.enhancer.jersey.static) and register this package
name incrementally on a dedicated URL prefix:
httpService.registerResources("/static/enhancer",
"org/apache/stanbol/enhancer/jersey/static", null);
httpService.registerResources("/static/entithub",
"org/apache/stanbol/entityhub/jersey/static", null);
Note that the org.apache.stanbol.enhancer.jersey.static package must
be marked in the list list of OSGi exported packages (Export-Package)
of the the org.apache.stanbol.enhancer.jersey bundle (using the
maven-bundle-plugin as usual).
Note that this scheme does not allow for contributions to partially
override previously registered resources though. But I think this
scheme is simple enough to get us started. We will refactor later if
we need to somehow implement some kind of incremental overrides.
--
Olivier
http://twitter.com/ogrisel - http://github.com/ogrisel