Thanks everyone for your help.  I have decided to stay with blueprint and
pass references to OSGi services to the resource classes via the
constructor.  Something like this:

IN BLUEPRINT:
​​<reference id="dbFactory"
interface="com.mycompany.grid.database.DatabaseHelperFactory"
/>

<bean id="playRestTwo" class="com.mycompany.grid.play.two.impl.PlayRestTwo">
   <argument ref="dbFactory" />
   <argument ref="blueprintBundleContext" />
</bean>

<jaxrs:server id="server" address="/rest2/playTwo">
   <jaxrs:serviceBeans>
      <ref component-id="playRestTwo" />
   </jaxrs:serviceBeans>

IN RESOURCE CLASS:

@Produces(MediaType.APPLICATION_JSON)
@Path("/playTwo")
public class PlayRestTwo {

private DatabaseHelperFactory dbFactory;
private String transactionProc;

public PlayRestTwo(BundleContext bundleContext, DatabaseHelperFactory
dbFactory) {
   this.bundleContext = bundleContext;
   this.dbFactory = dbFactory;
}

​Marc

​

On Mon, Aug 15, 2016 at 2:45 PM, Tim Ward <[email protected]> wrote:

> If the services that you're looking to provide use JAX-RS the there is a
> specification proposal for OSGi R7 that you should look at. Prototyping
> work is starting in Apache Aries now.
>
> Tim
>
> Sent from my iPhone
>
> On 15 Aug 2016, at 18:56, Scott Lewis <[email protected]> wrote:
>
> On 8/15/2016 10:28 AM, Christian Schneider wrote:
>
> <stuff deleted>
>
> ECF also supports CXF now but I am not sure at what level of CXF features.
>
>
> This provider [1], will support all of the jax-rs
> Configurable/Configuration capabilities that CXF supports.   It will also
> be possible to extend [1] to create a custom provider, which are of course
> free use any of CXF's APIs.   Same with Jersey.
>
> Scott
>
> [1] https://github.com/ECF/JaxRSProviders/tree/master/
> bundles/org.eclipse.ecf.provider.cxf.server
>
>
> Christian
>
> 2016-08-15 17:21 GMT+02:00 Marc Durand <[email protected]>:
>
>> Hello,
>> I was following Christian's tutorial here:
>> http://liquid-reality.de/display/liquid/2011/12/22/Karaf+
>> Tutorial+Part+4+-+CXF+Services+in+OSGi
>>
>> And I also found come blog posts from JB that show how to deploy RESTful
>> services using blueprint.
>>
>> What I couldn't find was an example on how to deploy a RESTful service
>> where
>> the resource class is an OSGi service (to take advantage of SCR references
>> to other services in the resource class).  I was able to do it by using a
>> <reference> element instead of a <bean> element in the blueprint file.  Is
>> this approach correct or will it lead to other problems down the road?
>>
>> Thanks!
>> Marc
>>
>>
>>
>>
>> --
>> View this message in context: http://karaf.922171.n3.nabble.
>> com/RESTful-web-service-in-Karaf-using-CXF-and-blueprint-tp4047529.html
>> Sent from the Karaf - User mailing list archive at Nabble.com
>> <http://nabble.com>.
>>
>
>
>
> --
> --
> Christian Schneider
> http://www.liquid-reality.de
> <https://owa.talend.com/owa/redir.aspx?C=3aa4083e0c744ae1ba52bd062c5a7e46&URL=http%3a%2f%2fwww.liquid-reality.de>
>
> Open Source Architect
> http://www.talend.com
> <https://owa.talend.com/owa/redir.aspx?C=3aa4083e0c744ae1ba52bd062c5a7e46&URL=http%3a%2f%2fwww.talend.com>
>
>
>

Reply via email to