In your case simply inject the ttnMqttClient in the @Reference and do the
subscribe in @Activate when you get the config and the unsubscribe in
2016-10-13 23:00 GMT+02:00 Daghan ACAY <daghana...@hotmail.com>:
> Hi all,
> I am trying to create a component that is instantiated by ConfigAdmin and
> uses multiple references to operate. Basically the component should
> instantiate through a factory configuration and use that configuration to
> set up its own @Reference s. You can see the code here:
> All the mentioned @Reference ed components are instantiated by
> configuration as well, so at a given time the @Reference might not be
> available but my own component should still work. yet should the Reference
> available then it should be injected, basic 0-1 strategy.
> Problem I am facing with the current form of the code is that, the
> @Reference injection is happening before the @Activate method is called.
> This leads to NPE in the @Reference method due to null configuration. Is it
> possible to make this code work such that config is provided to the
> component before the dependency injection?
> I have tried annotating the class fields and set them "volatile". I even
> make them a list and use the class fields in the activate method this time
> the class fields were null due to 0-1 strategy. so I end up with annotating
> the methods.
> I might have designed this all wrong, so any help simple or fundamental is
> Sent by MailWise <http://www.mail-wise.com/installation/2> – See your
> emails as clean, short chats.
> OSGi Developer Mail List
Open Source Architect
OSGi Developer Mail List