You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Javier Delgadillo <jd...@esri.com> on 2012/06/05 02:05:58 UTC

Dynamically Adding/Removing services

All,

I'd like a little advice from the CXF users. Here's my setup.

Karaf 2.2.7
CXF 2.6.0

I've got several bundles implementing various interfaces that I expose as JAX-RS endpoints.  Currently, I've got one bundle that configures a jaxrs bean which depends on all of the implementing bundles.  This works fine as long as all of the bundles are installed and created.  What I'd like to do is selectively add and/or remove some bundles (ie functionality) and have the REST endpoint adjust accordingly.  The main advantage of this approach is the ability to configure interceptors in one location.  I'd like to continue to manage the interceptors (currently authentication and exception handling) in one place without having to copy the same configuration to all of the implementing modules.

Currently, the REST endpoint is at /cxf/core/<feature>

Within Karaf, I'd like to issue the command
                features:uninstall feature
and have /cxf/core endpoint continue to function (even after a restart) with the remaining endpoints/beans.

Likewise, I'd like issue the Karaf command:
                features:install feature2
and have the REST endpoing for feature2 enabled under /cxf/core/<feature2>

Has anyone tried to do this?  Most of the documentation and samples I've seen have a hard-coded set of implementing beans, but I've yet to run into something that let's you add/remove JAX-RS beans in this manner.  Am I missing something obvious?

--
Javier Delgadillo
Esri / Implementation Services


Re: Dynamically Adding/Removing services

Posted by Daniel Kulp <dk...@apache.org>.
On Friday, June 08, 2012 09:36:47 AM Javier Delgadillo wrote:
> Any links or sample code?  Would I do something like what's configured in
> this sample (using my auth/exception handlers)?  Anyone know if defining
> a CXF Bus in one bundle will make it the bus for all CXF services?

The answer to that last question is almost always no.   Each spring-dm 
context or blueprint context will normally create it's own Bus.   

There's a couple things you could try depending on what you need to 
accomplish:

1) Leave it as is.   You should be able to deploy multiple bundles with 
various services and have them all hang off the OSGi http servlet configured 
on /cxf just fine, despite having their own bus, configs, etc....  

2) If you do need to configure things on a more global level,  SOME things 
like HTTPs settings and workqueue things are settable via config:admin.   

3) Next option would be to write a bean that implements 
org.apache.cxf.buslifecycle.BusCreationListener and register that into the 
OSGi service registry.   Whenever a Bus is created, your listener would be 
called and you can hook in whatever added functionality you need.   
Likewise, various other listeners and features can be added to ALL bus's the 
same way.

4) I've never tried this:  All Bus's created in OSGi are registered as an 
OSGi service.   Thus, you COULD possible get things to use a "global" bus by 
having a common bundle create/configure the Bus.  The other bundles, instead 
of using a default created bus could lookup that bus from OSGi.  In theory, 
that should work, I think. 

Dan



> 
> -Javier
> 
> -----Original Message-----
> From: Johan Edstrom [mailto:seijoed@gmail.com]
> Sent: Monday, June 04, 2012 5:16 PM
> To: users@cxf.apache.org
> Subject: Re: Dynamically Adding/Removing services
> 
> I'd peek at a managed service factory and some services around the Bus.
> 
> On Jun 4, 2012, at 6:05 PM, Javier Delgadillo wrote:
> > All,
> > 
> > I'd like a little advice from the CXF users. Here's my setup.
> > 
> > Karaf 2.2.7
> > CXF 2.6.0
> > 
> > I've got several bundles implementing various interfaces that I expose
> > as JAX-RS endpoints.  Currently, I've got one bundle that configures a
> > jaxrs bean which depends on all of the implementing bundles.  This
> > works fine as long as all of the bundles are installed and created. 
> > What I'd like to do is selectively add and/or remove some bundles (ie
> > functionality) and have the REST endpoint adjust accordingly.  The main
> > advantage of this approach is the ability to configure interceptors in
> > one location.  I'd like to continue to manage the interceptors
> > (currently authentication and exception handling) in one place without
> > having to copy the same configuration to all of the implementing
> > modules.
> > 
> > Currently, the REST endpoint is at /cxf/core/<feature>
> > 
> > Within Karaf, I'd like to issue the command
> > 
> >                features:uninstall feature and have /cxf/core endpoint
> > 
> > continue to function (even after a restart) with the remaining
> > endpoints/beans.> 
> > Likewise, I'd like issue the Karaf command:
> >                features:install feature2 and have the REST endpoing
> > 
> > for feature2 enabled under /cxf/core/<feature2>
> > 
> > Has anyone tried to do this?  Most of the documentation and samples I've
> > seen have a hard-coded set of implementing beans, but I've yet to run
> > into something that let's you add/remove JAX-RS beans in this manner. 
> > Am I missing something obvious?
> > 
> > --
> > Javier Delgadillo
> > Esri / Implementation Services
-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com


RE: Dynamically Adding/Removing services

Posted by Javier Delgadillo <jd...@esri.com>.
Any links or sample code?  Would I do something like what's configured in this sample (using my auth/exception handlers)?  Anyone know if defining a CXF Bus in one bundle will make it the bus for all CXF services?

-Javier 

-----Original Message-----
From: Johan Edstrom [mailto:seijoed@gmail.com] 
Sent: Monday, June 04, 2012 5:16 PM
To: users@cxf.apache.org
Subject: Re: Dynamically Adding/Removing services

I'd peek at a managed service factory and some services around the Bus.

On Jun 4, 2012, at 6:05 PM, Javier Delgadillo wrote:

> All,
> 
> I'd like a little advice from the CXF users. Here's my setup.
> 
> Karaf 2.2.7
> CXF 2.6.0
> 
> I've got several bundles implementing various interfaces that I expose as JAX-RS endpoints.  Currently, I've got one bundle that configures a jaxrs bean which depends on all of the implementing bundles.  This works fine as long as all of the bundles are installed and created.  What I'd like to do is selectively add and/or remove some bundles (ie functionality) and have the REST endpoint adjust accordingly.  The main advantage of this approach is the ability to configure interceptors in one location.  I'd like to continue to manage the interceptors (currently authentication and exception handling) in one place without having to copy the same configuration to all of the implementing modules.
> 
> Currently, the REST endpoint is at /cxf/core/<feature>
> 
> Within Karaf, I'd like to issue the command
>                features:uninstall feature and have /cxf/core endpoint 
> continue to function (even after a restart) with the remaining endpoints/beans.
> 
> Likewise, I'd like issue the Karaf command:
>                features:install feature2 and have the REST endpoing 
> for feature2 enabled under /cxf/core/<feature2>
> 
> Has anyone tried to do this?  Most of the documentation and samples I've seen have a hard-coded set of implementing beans, but I've yet to run into something that let's you add/remove JAX-RS beans in this manner.  Am I missing something obvious?
> 
> --
> Javier Delgadillo
> Esri / Implementation Services
> 



Re: Dynamically Adding/Removing services

Posted by Johan Edstrom <se...@gmail.com>.
I'd peek at a managed service factory and some services around the Bus.

On Jun 4, 2012, at 6:05 PM, Javier Delgadillo wrote:

> All,
> 
> I'd like a little advice from the CXF users. Here's my setup.
> 
> Karaf 2.2.7
> CXF 2.6.0
> 
> I've got several bundles implementing various interfaces that I expose as JAX-RS endpoints.  Currently, I've got one bundle that configures a jaxrs bean which depends on all of the implementing bundles.  This works fine as long as all of the bundles are installed and created.  What I'd like to do is selectively add and/or remove some bundles (ie functionality) and have the REST endpoint adjust accordingly.  The main advantage of this approach is the ability to configure interceptors in one location.  I'd like to continue to manage the interceptors (currently authentication and exception handling) in one place without having to copy the same configuration to all of the implementing modules.
> 
> Currently, the REST endpoint is at /cxf/core/<feature>
> 
> Within Karaf, I'd like to issue the command
>                features:uninstall feature
> and have /cxf/core endpoint continue to function (even after a restart) with the remaining endpoints/beans.
> 
> Likewise, I'd like issue the Karaf command:
>                features:install feature2
> and have the REST endpoing for feature2 enabled under /cxf/core/<feature2>
> 
> Has anyone tried to do this?  Most of the documentation and samples I've seen have a hard-coded set of implementing beans, but I've yet to run into something that let's you add/remove JAX-RS beans in this manner.  Am I missing something obvious?
> 
> --
> Javier Delgadillo
> Esri / Implementation Services
>