You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@aries.apache.org by Bengt Rodehav <be...@rodehav.com> on 2011/12/10 10:24:31 UTC

Enable/disable blueprint services

I'm currently using iPOJO to publish OSGi services. The main reason why I'm
using iPOJO (instead of blueprint) is that I can easily disable/enable my
services by using iPOJO's @Controller annotation. To enable my service I
just change a configuration property to false and to enable it I set it to
true again.

I would like to use blueprint instead. Mainly because:

a) Blueprint comes out-of-the-box with Apache Karaf
b) Blueprint feels more like a standard
c) Blueprint does not require any manipulation

Is there a way to achieve the same functionality with blueprint (to
enble/disable services using a configuration property)?

/Bengt

Re: Enable/disable blueprint services

Posted by Bengt Rodehav <be...@rodehav.com>.
Thanks for your reply David,

I actually assumed that Aries Blueprint supported managed service factories
- although I haven't tried myself. If you look at slide number 61 in
Guillaume's presentation (
http://www.slideshare.net/gnodet/osgi-blueprint-services-1622424) it does
look like it's supported. But perhaps he is describing the specification
and not Aries implementation...

Anyway, just supporting service factories is not enough for the
functionality I was looking for. I use the service factory pattern with
iPOJO today and it is very convenient. In our case we use Karaf+Camel as an
integration platform. E g I have a filetransfer component that is highly
configurable for our purposes. In runtime I have several of those active at
the same time, each instantiated by configuration admin by adding a new
configuration file.

However, if you only rely on configuration admin, then the only way (I
think) to disable the service is to completely remove the configuration.
Then there is no way to see the configuration anymore becuase it doesn't
exist. iPOJO offers something called a lifecycle controller that allows me
to control whether the service is started or not via a configuration
property (true/false). This allows me to always have the configurations
present and editable e g via the Karaf web console or my own web gui. I can
still enable/disable the service just by changing a simple configuration
property  (the controller property). It is really very convenient.

Like I said, I assumed that managed service factories are supported by
Aries Blueprint but was looking for some equivalent to iPOJO's lifecycle
controller. I guess it is part of the iPOJO component model and not part of
the OSGi blueprint standard. (Something like this should be added to
blueprint IMO).

The closest to this functionality that I can think of is to completely
remove a mandatory property. This would probably (I haven't tested) cause
the blueprint service to stop. By then adding it again the service would
propably start. Not as nice though.

/Bengt


2011/12/10 David Jencks <da...@yahoo.com>

> I have not tired this and don't know if in fact Aries blueprint supports
> managed service factories yet, although I think it is a goal to do so.
>
> If you can figure out how to set up your blueprint stuff as one or more
> managed service factories, then nothing will be created by default, but for
> each configuration with the appropriate factory pid you will get a copy of
> your blueprint components..
>
> I have figured out how to use managed service factories with declarative
> services and find it very handy for this kind of scenario.
>
> hope this helps and someone who knows if aries blueprint supports managed
> service factories can explain more.
>
> thanks
> david jencks
>
> On Dec 10, 2011, at 1:24 AM, Bengt Rodehav wrote:
>
> > I'm currently using iPOJO to publish OSGi services. The main reason why
> I'm using iPOJO (instead of blueprint) is that I can easily disable/enable
> my services by using iPOJO's @Controller annotation. To enable my service I
> just change a configuration property to false and to enable it I set it to
> true again.
> >
> > I would like to use blueprint instead. Mainly because:
> >
> > a) Blueprint comes out-of-the-box with Apache Karaf
> > b) Blueprint feels more like a standard
> > c) Blueprint does not require any manipulation
> >
> > Is there a way to achieve the same functionality with blueprint (to
> enble/disable services using a configuration property)?
> >
> > /Bengt
>
>

Re: Enable/disable blueprint services

Posted by David Jencks <da...@yahoo.com>.
I have not tired this and don't know if in fact Aries blueprint supports managed service factories yet, although I think it is a goal to do so.

If you can figure out how to set up your blueprint stuff as one or more managed service factories, then nothing will be created by default, but for each configuration with the appropriate factory pid you will get a copy of your blueprint components..

I have figured out how to use managed service factories with declarative services and find it very handy for this kind of scenario.

hope this helps and someone who knows if aries blueprint supports managed service factories can explain more.

thanks
david jencks

On Dec 10, 2011, at 1:24 AM, Bengt Rodehav wrote:

> I'm currently using iPOJO to publish OSGi services. The main reason why I'm using iPOJO (instead of blueprint) is that I can easily disable/enable my services by using iPOJO's @Controller annotation. To enable my service I just change a configuration property to false and to enable it I set it to true again.
> 
> I would like to use blueprint instead. Mainly because:
> 
> a) Blueprint comes out-of-the-box with Apache Karaf
> b) Blueprint feels more like a standard
> c) Blueprint does not require any manipulation
> 
> Is there a way to achieve the same functionality with blueprint (to enble/disable services using a configuration property)?
> 
> /Bengt