On Thu, Apr 26, 2018 at 5:08 PM, Tim Ward via osgi-dev < osgi-dev@mail.osgi.org> wrote:
> Hi Scott, > > The answer is really that it depends. The OSGi service registry supports > the registration of service instances and service factories. This means > that when you see a service registered in the service registry the instance > may already exist, or it may only exist as a result of you getting the > service. You can also have services registered with prototype scope, > meaning that new instances are created each time you request one. > > If you’re using Declarative Services then the most likely scenario is that > the service is registered before it is injected and activated. This is > because DS components are lazy by default. > > Regards, > > Tim > > On 26 Apr 2018, at 16:23, Leschke, Scott via osgi-dev < > osgi-dev@mail.osgi.org> wrote: > > Question. When a service is created and activated, at what point is it > available for lookup via the service registry, before or after the service > is injected into services depending on it? I could see arguments for either? > > To clarify, if a service is created programmatically, and the new service > is then retrieved from the registry, has any injection of the service > already occurred at that point or the more likely scenario I think, you > don’t really know? > > Regards, > > Scott > _______________________________________________ > OSGi Developer Mail List > osgi-dev@mail.osgi.org > https://mail.osgi.org/mailman/listinfo/osgi-dev > > > > _______________________________________________ > OSGi Developer Mail List > osgi-dev@mail.osgi.org > https://mail.osgi.org/mailman/listinfo/osgi-dev > Actually unless I have misinterpreted the question, I think the answer is "always before". The exact question was: "at what point is it [a service] available for lookup via the service registry, before or after the service is injected into services depending on it?". The service HAS to be available for lookup before it can be injected into anything. Before the service is published to the service registry, no other bundle knows that the service exists so they have nothing that they can possibly inject. Tim: I believe you have answered a slightly different question about injections of dependencies into a DS component that is going to be published. You have answered it correctly of course. Scott: it would help if you clarified your question in more precise language. Bear in mind that a service is not "created and activated", it is only ever registered or unregistered. A Service is really only an entry in the Service Registry, and it doesn't have to have a real object behind it, which is the key to the lazy instantiation of some components in DS. Regards, Neil
_______________________________________________ OSGi Developer Mail List osgi-dev@mail.osgi.org https://mail.osgi.org/mailman/listinfo/osgi-dev