experimenting with felix I found that dynamic dependencies are not
injected while the acivate method is being executed.

The experiment code

/**
*  @scr.component
 * @scr.reference name="component" cardinality="0..n" policy="dynamic"
 *                interface="java.lang.Object" target="(testing=true)"
 */
public class Main {

    protected void bindComponent(Object component) {
        System.out.print("binding component");
    }

    protected void unbindComponent(Object component) {
        System.out.print("unbinding component");
    }

    protected void activate(ComponentContext context) {
        System.out.print("starting");
        try {
            Thread.sleep(30 * 1000);
        } catch (InterruptedException ex) {
            ex.printStackTrace();
        }
        System.out.print("finished starting");
    }
}

when I activate the above component and an injectable component
immediately after, the output "binding component" will only appear after
"finished starting".

Is this a felix specific behaviour that is not guaranteed by the
specifications?

Regards,
Reto



Neil Bartlett said the following on 03/05/2009 11:09 AM:
> It depends. If your component uses the "static policy" then the
> binds/unbinds will not happen concurrently with the
> activate/deactivate methods.
>
> However, if you use "dynamic" policy then they certainly can happen
> concurrently and you need to write your component to be thread-safe.
>
> Regards
> Neil
>
> On Thu, Mar 5, 2009 at 9:52 AM, Reto Bachmann-Gmür
> <reto.bachm...@trialox.org> wrote:
>   
>> I guess a simple question: is it guaranteed that the
>> activate,deactivate, the bind- and unbind methods of a component are not
>> called synchronously?
>>
>> Cheers,
>> Reto
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@felix.apache.org
>> For additional commands, e-mail: users-h...@felix.apache.org
>>
>>
>>     
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@felix.apache.org
> For additional commands, e-mail: users-h...@felix.apache.org
>
>   


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

Reply via email to