Heiko
Your question is a good one. Having looked at the spec I do not see any
mention of the activate/deactivate methods executing atomically, or
whether you are required to provide synchronization. I would encourage you
to add a bug report requesting some clarification on this matter:
Members...
https://www.osgi.org/members/bugzilla/enter_bug.cgi?product=Service%20Platform&component=Compendium%20Spec
Non-members...
https://www.osgi.org/bugzilla/enter_bug.cgi?product=OSGi%20Specification&component=Compendium
Nevertheless, my reading of the spec is as follows:
- While the activate method is executing you can be certain that the
deactivate method will not be called. Likewise, while the deactivate
method is called you can be certain that the activate method will not be
called.
- Regarding the binding/unbinding of referenced services, I believe that
using the "static" policy ensures that bind/unbind methods are never
called while the activate method is executing. Looking in the spec
compendium I have found the following from section 112.3.3:
"The static policy is the most simple policy and is the default policy. A
component instance never sees any of the dynamics. Component
configurations are deactivated before any bound service for a reference
having a static policy becomes unavailable. If a target service is
available to replace the bound service which became unavailable, the
component configuration must be reactivated and bound to the replacement
service. A reference with a static policy is called a static reference."
When using the "dynamic" policy I believe that the bind/unbind methods can
be called at anytime. By anytime I mean, before, during and after the
activate/deactivate methods are called.
"The dynamic policy is slightly more complex since the component
implementation must properly handle changes in the set of bound services.
With the dynamic policy, SCR can change the set of bound services without
deactivating a component configuration. If the component uses the event
strategy to access services, then the component instance will be notified
of changes in the set of bound services by calls to the bind and unbind
methods. A reference with a dynamic policy is called a dynamic reference."
Then, section 112.3.7 also mentions the bind and unbind methods:
"bind – The name of a method in the component implementation class that is
used to notify that a service is bound to the component configuration. For
static references, this method is only called before the activate method.
For dynamic references, this method can also be called while the component
configuration is active."
"unbind – Same as bind, but is used to notify the component configuration
that the service is unbound. For static references, the method is only
called after the deactivate method. For dynamic references, this method
can also be called while the component configuration is active."
I hope this helps.
Simon
http://equinoxosgi.blogspot.com/
_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev