I would add a service property "isConnected" to the Network service
and make a dependency from your Login service to a Network service
with a property isConnected = true.
I'm not sure if DS allows this. If not, either manually track it using
a ServiceTracker or use (for example) the Apache Felix Dependency
Manager. Probably iPOJO (also part of Apache Felix) would work too.
Greetings, Marcel
On Sep 25, 2009, at 21:30 , Luciana Alvite wrote:
Hello dear fellow OSGi devs,
I have the following simplified scenario in my Declarative Services
based project:
2 Components: Network and Login
Login depends on 1..1 Network component. Network takes care of
connecting and disconnecting from a given network.
I would like to make the Login component dependency on Network
satisfied only when the Network is actually connected, meaning the
component would only be activated after the "network.connect()"
method is successfully executed.
Approaches I have tried:
- ConfigAdmin > Setting a property "isConnected" for the Network
component using the ConfigAdmin when the "connect" method is
successfully executed
Result: Does not work, since changing the properties will require a
reactivation of the Network component, therefore recreating the
component and losing the connection.
- Events > Make login implement EventHandler and listen to Network
events. When event is "connected", react accordingly. the problem
here is that the component must be enabled to be able to actually
receive events. and this goes against the goal of only activating
the component AFTER the network is connected..
I have tried google, read the specs several times but could not yet
think of any suitable implementation , any ideas of how I could
solve this?
Thanks in advance for any help or pointers!
--
Best Regards
Luciana Alvite _______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev
_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev