Mandatory references are always injected before activate.
Optional references can be injected either before or after activate.

On 13/10/16 23:00, Daghan ACAY wrote:
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 appreciated.



Sent by MailWise <> – See your
emails as clean, short chats.

OSGi Developer Mail List

Ferry Huberts
OSGi Developer Mail List

Reply via email to