Hi, Your Network component is registered as a service and the connect method is not called from the component activator, right ?
In this case, I would suggest you don't declare the Network component as a service towards Declarative Service. Rather I would register the Network component as part of the connect() method. This way, the Network service will only be bound to the Login component when the Network actually connects. Of course, you will have to implement a deactivate() method in the Network component, which makes sure that (a) the network is disconnected and (b) the service is unregistered again. Most naturally, there would probably be a disconnect method, which unregisters the service before actually disconnecting. HTH Regards Felix Luciana Alvite schrieb: > 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
