You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Josh Holtzman <jh...@berkeley.edu> on 2009/03/25 23:18:42 UTC

OSGI Transport

I'm trying to deploy CXF-based webservices on Apache Felix.  I've got 
almost everything working, thanks to the generous help of Guillaume 
Nodet (thanks again!).  The one piece I haven't figured out is how to 
configure a JAX-WS endpoint to use the existing osgi http service (I'm 
using Pax).  I've deployed the "Apache ServiceMix CXF Transport for OSGi 
(4.0.0)" bundle, but since I'm not using spring-dm, it doesn't seem to 
do anything for me.  I'm trying to do this with minimal dependencies, so 
I'd like to leave spring-dm out of the picture if possible.

Does anyone have a recipe for configuring CXF to allow multiple JAX-WS 
endpoints to use the servlet container created by the osgi http 
service?  Right now, I'm doing:

Endpoint.publish("http://localhost:8080/sample", new 
SampleWebServiceImpl());

And because I've got an existing osgi http service on 8080, I get 
"Address already in use"

Thanks,
Josh

-- 
Josh Holtzman
Educational Technology Services, UC Berkeley
jholtzman@berkeley.edu
510.529.9225


RE: Re: OSGI Transport

Posted by Sergey Beryozkin <sb...@progress.com>.
Hi

> Is there an equivalent technique for registering jax-rs endpoints with
the same osgi http service?


This code should do the trick:

import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;

JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setResourceClasses(BookStore.class);
sf.setResourceProvider(BookStore.class,
              new SingletonResourceProvider(new BookStore()));

sf.setAddress("http://localhost:9080/");
sf.create();

Please note, in CXF 2.1.4 a jettison bundle [1] will need to be
registered first even if JSON is not needed for JAXRS endpoints to work

As a side note, this code will need to be updated slightly to work in
DOSGI, AegisProvider will just need to be registered, and the object
will already be there...

Cheers, Sergey 

[1]
http://www.springsource.com/repository/app/bundle/version/detail?name=co
m.springsource.org.codehaus.jettison&version=1.0.1&searchType=bundlesByS
ymbolicName&searchQuery=Jettison


-----Original Message-----
From: Josh Holtzman [mailto:jholtzman@berkeley.edu] 
Sent: 27 March 2009 22:46
To: users@cxf.apache.org
Subject: Re: Re: OSGI Transport

Thanks David, this helps a lot!  Is there an equivalent technique for 
registering jax-rs endpoints with the same osgi http service?    I want 
it all, of course... a war, ws endpoint, and a jax-rs endpoint.  I'm 
greedy ;)

Josh

David Bosschaert wrote:
> Hi Josh,
>
> We are doing this in the CXF-base Distributed OSGi implementation
> (http://cxf.apache.org/distributed-osgi.html), have a look at the
> following file:
>
http://svn.apache.org/repos/asf/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/jav
a/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandler.
java
>
> Have a look at the createServer method, it creates a
> CXFNonSpringServlet for this purpose and registers that with the OSGi
> HTTP Service. As the name suggest, it does not use Spring.
>
> BTW if you want to try this out, in the following blog article this
> functionality is used to host both a .WAR file and an CXF Endpoint on
> the same host/port through the OSGi HTTP Service:
>
http://coderthoughts.blogspot.com/2009/02/distributed-osgi-powered-ajax-
webapp.html
>
> Hope this helps,
>
> David
>
> 2009/3/25 Josh Holtzman <jh...@berkeley.edu>:
>   
>> I'm trying to deploy CXF-based webservices on Apache Felix.  I've got
almost
>> everything working, thanks to the generous help of Guillaume Nodet
(thanks
>> again!).  The one piece I haven't figured out is how to configure a
JAX-WS
>> endpoint to use the existing osgi http service (I'm using Pax).  I've
>> deployed the "Apache ServiceMix CXF Transport for OSGi (4.0.0)"
bundle, but
>> since I'm not using spring-dm, it doesn't seem to do anything for me.
I'm
>> trying to do this with minimal dependencies, so I'd like to leave
spring-dm
>> out of the picture if possible.
>>
>> Does anyone have a recipe for configuring CXF to allow multiple
JAX-WS
>> endpoints to use the servlet container created by the osgi http
service?
>>  Right now, I'm doing:
>>
>> Endpoint.publish("http://localhost:8080/sample", new
>> SampleWebServiceImpl());
>>
>> And because I've got an existing osgi http service on 8080, I get
"Address
>> already in use"
>>
>> Thanks,
>> Josh
>>
>> --
>> Josh Holtzman
>> Educational Technology Services, UC Berkeley
>> jholtzman@berkeley.edu
>> 510.529.9225
>>
>>
>>     
>
>   

-- 
Josh Holtzman
Educational Technology Services, UC Berkeley
jholtzman@berkeley.edu
510.529.9225


Re: Re: OSGI Transport

Posted by Josh Holtzman <jh...@berkeley.edu>.
Thanks David, this helps a lot!  Is there an equivalent technique for 
registering jax-rs endpoints with the same osgi http service?    I want 
it all, of course... a war, ws endpoint, and a jax-rs endpoint.  I'm 
greedy ;)

Josh

David Bosschaert wrote:
> Hi Josh,
>
> We are doing this in the CXF-base Distributed OSGi implementation
> (http://cxf.apache.org/distributed-osgi.html), have a look at the
> following file:
> http://svn.apache.org/repos/asf/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandler.java
>
> Have a look at the createServer method, it creates a
> CXFNonSpringServlet for this purpose and registers that with the OSGi
> HTTP Service. As the name suggest, it does not use Spring.
>
> BTW if you want to try this out, in the following blog article this
> functionality is used to host both a .WAR file and an CXF Endpoint on
> the same host/port through the OSGi HTTP Service:
> http://coderthoughts.blogspot.com/2009/02/distributed-osgi-powered-ajax-webapp.html
>
> Hope this helps,
>
> David
>
> 2009/3/25 Josh Holtzman <jh...@berkeley.edu>:
>   
>> I'm trying to deploy CXF-based webservices on Apache Felix.  I've got almost
>> everything working, thanks to the generous help of Guillaume Nodet (thanks
>> again!).  The one piece I haven't figured out is how to configure a JAX-WS
>> endpoint to use the existing osgi http service (I'm using Pax).  I've
>> deployed the "Apache ServiceMix CXF Transport for OSGi (4.0.0)" bundle, but
>> since I'm not using spring-dm, it doesn't seem to do anything for me.  I'm
>> trying to do this with minimal dependencies, so I'd like to leave spring-dm
>> out of the picture if possible.
>>
>> Does anyone have a recipe for configuring CXF to allow multiple JAX-WS
>> endpoints to use the servlet container created by the osgi http service?
>>  Right now, I'm doing:
>>
>> Endpoint.publish("http://localhost:8080/sample", new
>> SampleWebServiceImpl());
>>
>> And because I've got an existing osgi http service on 8080, I get "Address
>> already in use"
>>
>> Thanks,
>> Josh
>>
>> --
>> Josh Holtzman
>> Educational Technology Services, UC Berkeley
>> jholtzman@berkeley.edu
>> 510.529.9225
>>
>>
>>     
>
>   

-- 
Josh Holtzman
Educational Technology Services, UC Berkeley
jholtzman@berkeley.edu
510.529.9225


Re: OSGI Transport

Posted by David Bosschaert <da...@gmail.com>.
Hi Josh,

We are doing this in the CXF-base Distributed OSGi implementation
(http://cxf.apache.org/distributed-osgi.html), have a look at the
following file:
http://svn.apache.org/repos/asf/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandler.java

Have a look at the createServer method, it creates a
CXFNonSpringServlet for this purpose and registers that with the OSGi
HTTP Service. As the name suggest, it does not use Spring.

BTW if you want to try this out, in the following blog article this
functionality is used to host both a .WAR file and an CXF Endpoint on
the same host/port through the OSGi HTTP Service:
http://coderthoughts.blogspot.com/2009/02/distributed-osgi-powered-ajax-webapp.html

Hope this helps,

David

2009/3/25 Josh Holtzman <jh...@berkeley.edu>:
> I'm trying to deploy CXF-based webservices on Apache Felix.  I've got almost
> everything working, thanks to the generous help of Guillaume Nodet (thanks
> again!).  The one piece I haven't figured out is how to configure a JAX-WS
> endpoint to use the existing osgi http service (I'm using Pax).  I've
> deployed the "Apache ServiceMix CXF Transport for OSGi (4.0.0)" bundle, but
> since I'm not using spring-dm, it doesn't seem to do anything for me.  I'm
> trying to do this with minimal dependencies, so I'd like to leave spring-dm
> out of the picture if possible.
>
> Does anyone have a recipe for configuring CXF to allow multiple JAX-WS
> endpoints to use the servlet container created by the osgi http service?
>  Right now, I'm doing:
>
> Endpoint.publish("http://localhost:8080/sample", new
> SampleWebServiceImpl());
>
> And because I've got an existing osgi http service on 8080, I get "Address
> already in use"
>
> Thanks,
> Josh
>
> --
> Josh Holtzman
> Educational Technology Services, UC Berkeley
> jholtzman@berkeley.edu
> 510.529.9225
>
>