Hello every one;
I am wondering if it's possible to reconfigure a Service Component
without restarting it at all !
Here is my use case: I have a Service Component which is activated by
the Declarative Service. The corresponding DS xml is:
<?xml version="1.0" encoding="utf-8"?>
<component name="hello">
<implementation class="test.HelloComponent"/>
</component>
Now, my HelloComponent's activate method is defined as this:
public class HelloComponent {
protected void activate(ComponentContext ctx) {
// initialize our HelloComponent using ctx.getProperties()
}
}
if I create a Configuration using the Config Admin Service with a pid
equals to the
HelloComponent's name (that is: "*hello*"), then my HelloComponent will
retrieve its
properties from the *ComponentContext.getProperties*() method. So far,
all is working like a charm.
Now here is my question: Is there a way for my HelloComponent to
register a ManagedService in order
to be notified when properties are updated by the Configuration Admin
Service ?
I ask this question because I have observed that SCR *REACTIVATES* the
HelloComponent, when the
properties are updated by the Config Admin Service. That is: when Config
Admin updates the
configuration, my HelloComponent is deactivated (it is removed from the
OSGi servide registry), and
then re-activated (my activate method is invoked again).
The problem here is that my HelloComponent is actually a "crutial"
component which must not be *shutdown* when
properties are modified (because I don't wan't to interrupt the service
while re-activating my
HelloComponent).
/Pierre