Hi Marco, I think your reference is mandatory by default. This means your service is deactivated as soon as the need reference vanishes. Try to make your service optional.
Kind regards, Thomas 2017-11-16 17:06 GMT+01:00 MarcoF90 <marco.fierimo...@gmail.com>: > Hi, > > I am using Declarative Services in Apache Karaf 4.1.3. I notice that in all > @Component using @Reference with policy DYNAMIC on attributes cause > Component deactivate on service changes. This is an example: > > @Component(immediate = true) > public class Test3 { > > private static final Logger logger = LoggerFactory.getLogger(Test3. > class); > > private GreetService greetService; > > @Activate > public void activate(BundleContext bundleContext) { > logger.info("activate() - IN - input: bundleContext = > [{}]", > bundleContext); > logger.info("activate() - OUT"); > } > > @Deactivate > public void deactivate() { > logger.info("deactivate() - IN"); > logger.info("deactivate() - OUT"); > } > > // ----------------------------- greet service > --------------------------------- // > @Reference(policy = ReferencePolicy.DYNAMIC, policyOption = > ReferencePolicyOption.GREEDY) > public void setGreetService(GreetService greetService) { > logger.info("setGreetService() - NOTIFY - msg: > greetService = [{}]", > greetService); > this.greetService = greetService; > } > > public void unsetGreetService(GreetService greetService) { > logger.info("unsetGreetService() - NOTIFY - msg: > greetService = [{}]", > greetService); > } > > public GreetService getGreetService() { > return greetService; > } > > } > > When I deactivate GreetService I'd like to unset it in method > unsetGreetService() without DISABLE the entire component calling > deactivate() method. Is this possible? I am able to obtain this behaviour > only with @Reference properties DYNAMIC and MULTIPLE. Thanks for help. > > Marco > > > > -- > Sent from: http://apache-felix.18485.x6.nabble.com/Apache-Felix-Users- > f4833200.html > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@felix.apache.org > For additional commands, e-mail: users-h...@felix.apache.org > > -- M.Sc. Thomas Driessen Software Methodologies for Distributed Systems Institute of Computer Science University of Augsburg Universitätsstr. 6a 86135 Augsburg, Germany Tel: +49 821 598-2486 email: thomas.dries...@informatik.uni-augsburg.de