You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stanbol.apache.org by Fabian Christ <ch...@googlemail.com> on 2011/03/28 11:33:47 UTC
Refactor HTTP Endpoint
Hi,
I'm working on https://issues.apache.org/jira/browse/STANBOL-120
The idea is to have a commons web bundle as the central point to
manage and handle all JAXRS resources that are provided by other
bundles. New bundles can register theirs JAXRS resources at the
commons web bundle. The commons web bundle makes all resources
available.
For this, the commons web bundle needs to load static resources (e.g.
templates) from other bundles. As I am not that familiar with OSGI
yet, here is my question about OSGI and class loading. Is it possible
to load resources from another bundle via classpath? Is it possible to
export e.g. the META-INF folder of a bundle and make it available to
other bundles?
--
Fabian
Re: Refactor HTTP Endpoint
Posted by Fabian Christ <ch...@googlemail.com>.
Hi,
2011/3/28 Olivier Grisel <ol...@ensta.org>:
> 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);
Yes, this is similar to what I had in mind. Thank you.
> 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).
Okay, I was not sure if exporting the package this way is enough. Cool.
> 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.
Agreed, from my side.
- Fabian
Re: Refactor HTTP Endpoint
Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi,
On Mon, Mar 28, 2011 at 12:24 PM, Olivier Grisel
<ol...@ensta.org> wrote:
> ...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);
Sounds good to me for now, thanks for clarifying!
-Bertrand
Re: Refactor HTTP Endpoint
Posted by Olivier Grisel <ol...@ensta.org>.
2011/3/28 Olivier Grisel <ol...@ensta.org>:
> 2011/3/28 Bertrand Delacretaz <bd...@apache.org>:
>> Hi,
>>
>> On Mon, Mar 28, 2011 at 11:57 AM, Olivier Grisel
>> <ol...@ensta.org> wrote:
>>> 2011/3/28 Rupert Westenthaler <ru...@gmail.com>:
>>>>... 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
Re: Refactor HTTP Endpoint
Posted by Olivier Grisel <ol...@ensta.org>.
2011/3/28 Bertrand Delacretaz <bd...@apache.org>:
> Hi,
>
> On Mon, Mar 28, 2011 at 11:57 AM, Olivier Grisel
> <ol...@ensta.org> wrote:
>> 2011/3/28 Rupert Westenthaler <ru...@gmail.com>:
>>>... 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.
--
Olivier
http://twitter.com/ogrisel - http://github.com/ogrisel
Re: Refactor HTTP Endpoint
Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi,
On Mon, Mar 28, 2011 at 11:57 AM, Olivier Grisel
<ol...@ensta.org> wrote:
> 2011/3/28 Rupert Westenthaler <ru...@gmail.com>:
>>... 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?
Contributing bundles could then supply a service that gives access to
those resources.
-Bertrand
Re: Refactor HTTP Endpoint
Posted by Olivier Grisel <ol...@ensta.org>.
2011/3/28 Rupert Westenthaler <ru...@gmail.com>:
> Hi
>
> 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.
--
Olivier
http://twitter.com/ogrisel - http://github.com/ogrisel
Re: Refactor HTTP Endpoint
Posted by Rupert Westenthaler <ru...@gmail.com>.
Hi
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.
best
Rupert Westenthaler
On Mon, Mar 28, 2011 at 11:33 AM, Fabian Christ
<ch...@googlemail.com> wrote:
> Hi,
>
> I'm working on https://issues.apache.org/jira/browse/STANBOL-120
>
> The idea is to have a commons web bundle as the central point to
> manage and handle all JAXRS resources that are provided by other
> bundles. New bundles can register theirs JAXRS resources at the
> commons web bundle. The commons web bundle makes all resources
> available.
>
> For this, the commons web bundle needs to load static resources (e.g.
> templates) from other bundles. As I am not that familiar with OSGI
> yet, here is my question about OSGI and class loading. Is it possible
> to load resources from another bundle via classpath? Is it possible to
> export e.g. the META-INF folder of a bundle and make it available to
> other bundles?
>
> --
> Fabian
>
--
| Rupert Westenthaler rupert.westenthaler@gmail.com
| Bodenlehenstraße 11 ++43-699-11108907
| A-5500 Bischofshofen