You must never write code like this in OSGi. It is a serious error to assume that a service will be available immediately after a bundle has started, you must always listen for the service becoming available (which may happen a long time in the future).
I’m not sure what it is that you’re doing which requires you to use the low-level API like this. I would not recommend directly interacting with the bundle context, but instead using a dependency management container such as Declarative Services to inject you with the service when it becomes available. Using the low level API is typically a good way to ensure that your code is complex and unreadable. Regards, Tim > On 31 Jan 2018, at 13:59, SAI3292 <[email protected]> wrote: > > Hi > > I am trying the update the resolved bundle and then starting it which is > providing implementation for Interface I. Afterwards immediately getting the > service reference for the Interface I. Interface I is in different module > which is started. > Following is the code: > > Bundle bundle = bundleContext.getBundle(mvn:path); > bundle.update(); > bundle.start(); > Collection<ServiceReference<I>> referenceList = bundleContext > > .getServiceReferences(I.class, null); > > Is that when i am getting service reference of the interface, the bundle > start is not yet registered the implementation of the Interface I in > Activator. Is that an Asynchronous call. > > Can anybody help > > Regards > Sai > > > > -- > Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
