You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Jerome Pommier <je...@yahoo.fr.INVALID> on 2020/05/12 15:17:48 UTC

Dynamic binding trouble ?

A component Son is defined as a factory:

*@Component(
        factory = « SON »)
public class Son implements …  {

    @Reference(cardinality = ReferenceCardinality.OPTIONAL)
    volatile Filter aFilter;
…*

The Component Son is instantiated within activate method of Father
component:

*@Component
public class Father implements Filter {
…
	@Activate
	public void valid(){
	   …
	   Instantiation of Son and others from Factories
	}*

I observed that the « aFilter » field in Son instance is never updated as I
think it should.
I changed that« aFilter » field in Son  by requiring a service reference:

*    @Reference(cardinality = ReferenceCardinality.OPTIONAL)
    volatile ServiceReference<Filter> aServiceFilter;*

Doing that , during the activation of Father but BEFORE the component Son
was activated I can see  (e.g. by implementing binding method) that the
« aServiceFilter » is updated.
This implies that I need a bundle context  to dereference the field, but
while the activate method of Son component is not yet
avalaible, I must modified its activate method by adding:

*	@Activate	
		…
		aFilter= context.getService(aServiceFilter);*

That trick is working, so my question is  « Is that a bug or normal
behavior  ? » and where can I find some insight.

Thanks in advance.

J.Pommier




--
Sent from: http://apache-felix.18485.x6.nabble.com/Apache-Felix-Users-f4833200.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org