Lazy activation and deactivation of unused services is a core feature of DS - and in general for the average HC this should not pose any problems. For those services who need to keep state, the immediate flag forces the service to be activated immediately and stay there until the bundle is stopped.
The other option is you register your service instance by hand through the bundle context. Carsten 2014/1/16 Bertrand Delacretaz <[email protected]> > Hi, > > Playing with my SlowHealthCheckSample [1] I noticed that a new > instance is created for each execution, as a result of > HealthCheckFuture getting and ungetting the service every time. > > Is there a way to tell the OSGi framework to create a single instance > of the service and reuse it? I thought this is what would happen in > this case, but it's not, maybe because there are no more users of the > service after HealthCheckFuture calls unget. > > Without that it's hard to keep state in the HC - an HC that checks > external systems, for example, will need to be aware of previous > failures. > > -Bertrand > > [1] > https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/healthcheck/samples/src/main/java/org/apache/sling/hc/samples/impl/SlowHealthCheckSample.java > -- Carsten Ziegeler [email protected]
