I wouldn't push this into DS, since it is meant to be simple. You could
probably implement something like this as a layer on top using service
registry hooks. Also, iPOJO supports a dynamic priority policy, where
the service with the highest ranking is injected dynamically.
-> richard
On 1/27/14, 04:55 , Ioannis Canellos wrote:
Quite often I am coming across the same problem again and again and I
was wondering what's the best way to deal with it.
The problem is that I have multiple components (say A and B) that are
providing similar piece of functionality. At any given time I want
only one of the two components to be "active". Something like:
if only A is satisfied -> activate A.
if only B is satisfied -> activate B.
if A and B are satisfied -> activate B
if A is activated and later on B gets satisfied -> deactivate A and activate B.
If those components are providing a Service I can use service ranking
to deal with it. But some times this is not enough and I also need to
deactivate the component too. In this case I can do it using the
enable()/disable() methods on the component.
I am wondering if there are better ways to implement something like
"mutually" exclusive components.
Would it make sense to introduce the concept of "component ranking"
that would allow having multiple components with the same name but
only activate the one with the highest ranking?
Thanks.
_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev