You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Daniel Bimschas <bi...@itm.uni-luebeck.de> on 2009/11/18 10:52:25 UTC

Usage of "legacy" OSGi services as resource providers

Hi all!

I wonder if there's a possibility to re-use existing OSGi services as resource providers for Sling? These services could be of arbitrary type, i.e. some could be a facade for a database, some would do data mining, providing their results as resources and so on. Which interfaces would I have to implement and how would I have to configure Sling to find the service-based resource provider?

Another question that arose is if I can use existing JAX-RS (Jersey)-based code in Sling? This would fit perfectly regarding the REST architecture, even if the philosophies of the frameworks seem different.

Searching the archives I didn't find any answer to my question even if I'm sure somebody must have asked before ;-) So I'm sorry if there was a thread about the topic before...

Kind regards and thanks for you help!
Daniel Bimschas


-- 
M.Sc. Daniel Bimschas
Institute of Telematics, University of Lübeck
http://www.itm.uni-luebeck.de/users/bimschas
Ratzeburger Allee 160, 23538 Lübeck, Germany
Phone: +49 451 500 5389


Re: Usage of "legacy" OSGi services as resource providers

Posted by Daniel Bimschas <bi...@itm.uni-luebeck.de>.
Am 19.11.2009 um 11:35 schrieb Felix Meschberger:

> Hi,
> 
> Daniel Bimschas schrieb:
>> Am 18.11.2009 um 12:57 schrieb Felix Meschberger:
>> 
>>> Hi,
>>> 
>>> Daniel Bimschas schrieb:
>>>> I wonder if there's a possibility to re-use existing OSGi services as resource providers for Sling? These services could be of arbitrary type, i.e. some could be a facade for a database, some would do data mining, providing their results as resources and so on. Which interfaces would I have to implement and how would I have to configure Sling to find the service-based resource provider?
>>> Yes, I this should certainly be possible.
>>> 
>>> Resource providers are hooked into the resource tree by means of
>>> ResourceProvider services (see the ResourceProvider[1] service interface).
>>> 
>>> If you have an existing OSGi service you would probably have to
>>> implement a bridge: The bridge would be the ResourceProvider service
>>> making the data of the existing OSGi service available as Resource
>>> instances.
>>> 
>>> For an example of a simple resource provider, you might want to look at
>>> the Filesystem Resource Provider [2], which provides plattform files and
>>> folders as resources.
>>> 
>>> For an example of a bridging ResourceProvider you might want to look at
>>> the Servlet Resolver bundle [3], which has a
>>> ServletResourceProviderFactory which takes registered Servlet services
>>> and wraps them into ServletResourceProvider instances which are
>>> registered as ResourceProvider services.
>> 
>> Thanks for the information! I'll try out soon. It now seems perfectly clear to me what I have to do :-)
>> 
>>>> Another question that arose is if I can use existing JAX-RS (Jersey)-based code in Sling? This would fit perfectly regarding the REST architecture, even if the philosophies of the frameworks seem different.
>>>> 
>>>> Searching the archives I didn't find any answer to my question even if I'm sure somebody must have asked before ;-) So I'm sorry if there was a thread about the topic before...
>>> There has been a question or two about integrating JAX-RS (JSR-311) with
>>> Sling. I can only repeat, what I said back then: I think that it would
>>> probably be a good thing, if we could integrate JSR-311 into Sling. In
>>> fact, I have the impression, that Sling could perfectly well provide an
>>> implementation of JAX-RS for JAX-RS applications to be deployed into Sling.
>>> 
>>> But, well, noone really picked up this idea as of yet... So you would be
>>> very welcome to contribute such a thing ;-)
>> 
>> In fact, I'm thinking about "paying back" something to one of the Apache projects by contributing as I've already had so much profit through using them :-) This contribution will be on the very top of my list of choices!
> 
> Great ! Looking forward to it.
> 
> 
> Regards
> Felix

FYI: The Jersey development team plans to make Jersey OSGi-friendly in the next release. That would lower the barriers to provide JAX-RS integration into Sling. I'll keep that tracked and try to provide a Bridge as you called as soon as it's possible for me.

Regards,
Daniel

> 
>> 
>>> Regards
>>> Felix
>>> 
>>> [1]
>>> http://sling.apache.org/apidocs/sling5/org/apache/sling/api/resource/ResourceProvider.html
>>> [2]
>>> http://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/fsresource
>>> [3]
>>> http://svn.apache.org/repos/asf/sling/trunk/bundles/servlets/resolver
>> 

-- 
M.Sc. Daniel Bimschas
Institute of Telematics, University of Lübeck
http://www.itm.uni-luebeck.de/users/bimschas
Ratzeburger Allee 160, 23538 Lübeck, Germany
Phone: +49 451 500 5389


Re: Usage of "legacy" OSGi services as resource providers

Posted by Felix Meschberger <fm...@gmail.com>.
Hi,

Daniel Bimschas schrieb:
> Am 18.11.2009 um 12:57 schrieb Felix Meschberger:
> 
>> Hi,
>>
>> Daniel Bimschas schrieb:
>>> I wonder if there's a possibility to re-use existing OSGi services as resource providers for Sling? These services could be of arbitrary type, i.e. some could be a facade for a database, some would do data mining, providing their results as resources and so on. Which interfaces would I have to implement and how would I have to configure Sling to find the service-based resource provider?
>> Yes, I this should certainly be possible.
>>
>> Resource providers are hooked into the resource tree by means of
>> ResourceProvider services (see the ResourceProvider[1] service interface).
>>
>> If you have an existing OSGi service you would probably have to
>> implement a bridge: The bridge would be the ResourceProvider service
>> making the data of the existing OSGi service available as Resource
>> instances.
>>
>> For an example of a simple resource provider, you might want to look at
>> the Filesystem Resource Provider [2], which provides plattform files and
>> folders as resources.
>>
>> For an example of a bridging ResourceProvider you might want to look at
>> the Servlet Resolver bundle [3], which has a
>> ServletResourceProviderFactory which takes registered Servlet services
>> and wraps them into ServletResourceProvider instances which are
>> registered as ResourceProvider services.
> 
> Thanks for the information! I'll try out soon. It now seems perfectly clear to me what I have to do :-)
> 
>>> Another question that arose is if I can use existing JAX-RS (Jersey)-based code in Sling? This would fit perfectly regarding the REST architecture, even if the philosophies of the frameworks seem different.
>>>
>>> Searching the archives I didn't find any answer to my question even if I'm sure somebody must have asked before ;-) So I'm sorry if there was a thread about the topic before...
>> There has been a question or two about integrating JAX-RS (JSR-311) with
>> Sling. I can only repeat, what I said back then: I think that it would
>> probably be a good thing, if we could integrate JSR-311 into Sling. In
>> fact, I have the impression, that Sling could perfectly well provide an
>> implementation of JAX-RS for JAX-RS applications to be deployed into Sling.
>>
>> But, well, noone really picked up this idea as of yet... So you would be
>> very welcome to contribute such a thing ;-)
> 
> In fact, I'm thinking about "paying back" something to one of the Apache projects by contributing as I've already had so much profit through using them :-) This contribution will be on the very top of my list of choices!

Great ! Looking forward to it.


Regards
Felix

> 
>> Regards
>> Felix
>>
>> [1]
>> http://sling.apache.org/apidocs/sling5/org/apache/sling/api/resource/ResourceProvider.html
>> [2]
>> http://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/fsresource
>> [3]
>> http://svn.apache.org/repos/asf/sling/trunk/bundles/servlets/resolver
> 

Re: Usage of "legacy" OSGi services as resource providers

Posted by Daniel Bimschas <bi...@itm.uni-luebeck.de>.
Am 18.11.2009 um 12:57 schrieb Felix Meschberger:

> Hi,
> 
> Daniel Bimschas schrieb:
>> I wonder if there's a possibility to re-use existing OSGi services as resource providers for Sling? These services could be of arbitrary type, i.e. some could be a facade for a database, some would do data mining, providing their results as resources and so on. Which interfaces would I have to implement and how would I have to configure Sling to find the service-based resource provider?
> 
> Yes, I this should certainly be possible.
> 
> Resource providers are hooked into the resource tree by means of
> ResourceProvider services (see the ResourceProvider[1] service interface).
> 
> If you have an existing OSGi service you would probably have to
> implement a bridge: The bridge would be the ResourceProvider service
> making the data of the existing OSGi service available as Resource
> instances.
> 
> For an example of a simple resource provider, you might want to look at
> the Filesystem Resource Provider [2], which provides plattform files and
> folders as resources.
> 
> For an example of a bridging ResourceProvider you might want to look at
> the Servlet Resolver bundle [3], which has a
> ServletResourceProviderFactory which takes registered Servlet services
> and wraps them into ServletResourceProvider instances which are
> registered as ResourceProvider services.

Thanks for the information! I'll try out soon. It now seems perfectly clear to me what I have to do :-)

> 
>> 
>> Another question that arose is if I can use existing JAX-RS (Jersey)-based code in Sling? This would fit perfectly regarding the REST architecture, even if the philosophies of the frameworks seem different.
>> 
>> Searching the archives I didn't find any answer to my question even if I'm sure somebody must have asked before ;-) So I'm sorry if there was a thread about the topic before...
> 
> There has been a question or two about integrating JAX-RS (JSR-311) with
> Sling. I can only repeat, what I said back then: I think that it would
> probably be a good thing, if we could integrate JSR-311 into Sling. In
> fact, I have the impression, that Sling could perfectly well provide an
> implementation of JAX-RS for JAX-RS applications to be deployed into Sling.
> 
> But, well, noone really picked up this idea as of yet... So you would be
> very welcome to contribute such a thing ;-)

In fact, I'm thinking about "paying back" something to one of the Apache projects by contributing as I've already had so much profit through using them :-) This contribution will be on the very top of my list of choices!

> 
> Regards
> Felix
> 
> [1]
> http://sling.apache.org/apidocs/sling5/org/apache/sling/api/resource/ResourceProvider.html
> [2]
> http://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/fsresource
> [3]
> http://svn.apache.org/repos/asf/sling/trunk/bundles/servlets/resolver

-- 
M.Sc. Daniel Bimschas
Institute of Telematics, University of Lübeck
http://www.itm.uni-luebeck.de/users/bimschas
Ratzeburger Allee 160, 23538 Lübeck, Germany
Phone: +49 451 500 5389


Re: Usage of "legacy" OSGi services as resource providers

Posted by Vidar Ramdal <vi...@idium.no>.
On Wed, Dec 2, 2009 at 12:09 PM, Daniel Bimschas
<bi...@itm.uni-luebeck.de> wrote:
> another question just popped into my head ;-) Would it be possible to use one of the scripting languages to
> directly communicate with OSGi service, e.g. through having a reference to the OSGi service registry available?

You can get an OSGi service from a script by calling
sling.getService(), where 'sling' is the SlingScriptHelper.
See http://cwiki.apache.org/SLING/scripting-variables.html

-- 
Vidar S. Ramdal <vi...@idium.no> - http://www.idium.no
Sommerrogata 13-15, N-0255 Oslo, Norway
+ 47 22 00 84 00 / +47 21 531941, ext 2070

Re: Usage of "legacy" OSGi services as resource providers

Posted by Daniel Bimschas <bi...@itm.uni-luebeck.de>.
Hi,

another question just popped into my head ;-) Would it be possible to use one of the scripting languages to directly communicate with OSGi service, e.g. through having a reference to the OSGi service registry available?

Regards,
Daniel

Am 18.11.2009 um 12:57 schrieb Felix Meschberger:

> Hi,
> 
> Daniel Bimschas schrieb:
>> I wonder if there's a possibility to re-use existing OSGi services as resource providers for Sling? These services could be of arbitrary type, i.e. some could be a facade for a database, some would do data mining, providing their results as resources and so on. Which interfaces would I have to implement and how would I have to configure Sling to find the service-based resource provider?
> 
> Yes, I this should certainly be possible.
> 
> Resource providers are hooked into the resource tree by means of
> ResourceProvider services (see the ResourceProvider[1] service interface).
> 
> If you have an existing OSGi service you would probably have to
> implement a bridge: The bridge would be the ResourceProvider service
> making the data of the existing OSGi service available as Resource
> instances.
> 
> For an example of a simple resource provider, you might want to look at
> the Filesystem Resource Provider [2], which provides plattform files and
> folders as resources.
> 
> For an example of a bridging ResourceProvider you might want to look at
> the Servlet Resolver bundle [3], which has a
> ServletResourceProviderFactory which takes registered Servlet services
> and wraps them into ServletResourceProvider instances which are
> registered as ResourceProvider services.
> 
>> 
>> Another question that arose is if I can use existing JAX-RS (Jersey)-based code in Sling? This would fit perfectly regarding the REST architecture, even if the philosophies of the frameworks seem different.
>> 
>> Searching the archives I didn't find any answer to my question even if I'm sure somebody must have asked before ;-) So I'm sorry if there was a thread about the topic before...
> 
> There has been a question or two about integrating JAX-RS (JSR-311) with
> Sling. I can only repeat, what I said back then: I think that it would
> probably be a good thing, if we could integrate JSR-311 into Sling. In
> fact, I have the impression, that Sling could perfectly well provide an
> implementation of JAX-RS for JAX-RS applications to be deployed into Sling.
> 
> But, well, noone really picked up this idea as of yet... So you would be
> very welcome to contribute such a thing ;-)
> 
> Regards
> Felix
> 
> [1]
> http://sling.apache.org/apidocs/sling5/org/apache/sling/api/resource/ResourceProvider.html
> [2]
> http://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/fsresource
> [3]
> http://svn.apache.org/repos/asf/sling/trunk/bundles/servlets/resolver

-- 
M.Sc. Daniel Bimschas
Institute of Telematics, University of Lübeck
http://www.itm.uni-luebeck.de/users/bimschas
Ratzeburger Allee 160, 23538 Lübeck, Germany
Phone: +49 451 500 5389


Re: Usage of "legacy" OSGi services as resource providers

Posted by Felix Meschberger <fm...@gmail.com>.
Hi,

Daniel Bimschas schrieb:
> I wonder if there's a possibility to re-use existing OSGi services as resource providers for Sling? These services could be of arbitrary type, i.e. some could be a facade for a database, some would do data mining, providing their results as resources and so on. Which interfaces would I have to implement and how would I have to configure Sling to find the service-based resource provider?

Yes, I this should certainly be possible.

Resource providers are hooked into the resource tree by means of
ResourceProvider services (see the ResourceProvider[1] service interface).

If you have an existing OSGi service you would probably have to
implement a bridge: The bridge would be the ResourceProvider service
making the data of the existing OSGi service available as Resource
instances.

For an example of a simple resource provider, you might want to look at
the Filesystem Resource Provider [2], which provides plattform files and
folders as resources.

For an example of a bridging ResourceProvider you might want to look at
the Servlet Resolver bundle [3], which has a
ServletResourceProviderFactory which takes registered Servlet services
and wraps them into ServletResourceProvider instances which are
registered as ResourceProvider services.

> 
> Another question that arose is if I can use existing JAX-RS (Jersey)-based code in Sling? This would fit perfectly regarding the REST architecture, even if the philosophies of the frameworks seem different.
> 
> Searching the archives I didn't find any answer to my question even if I'm sure somebody must have asked before ;-) So I'm sorry if there was a thread about the topic before...

There has been a question or two about integrating JAX-RS (JSR-311) with
Sling. I can only repeat, what I said back then: I think that it would
probably be a good thing, if we could integrate JSR-311 into Sling. In
fact, I have the impression, that Sling could perfectly well provide an
implementation of JAX-RS for JAX-RS applications to be deployed into Sling.

But, well, noone really picked up this idea as of yet... So you would be
very welcome to contribute such a thing ;-)

Regards
Felix

[1]
http://sling.apache.org/apidocs/sling5/org/apache/sling/api/resource/ResourceProvider.html
[2]
http://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/fsresource
[3]
http://svn.apache.org/repos/asf/sling/trunk/bundles/servlets/resolver