You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently there is not really an easy / convenient way to simply enumerate all service providers of all bundles, and as we all know this is maybe even bad and one should better use Service, DI and all kind of cool OSGi stuff.
On the other hand as a matter of fact there are uses of ServiceLoader around that will likely never migrate (most prominent JakartaEE) and technologies like ServiceLoader Mediator have there shortcomings as they require special configuration, care and knowledge of users (also know as "OSGi is to complex for us").
In JakartaEE on the other hand they are trying really hard to support all different kind of things (not only OSGi specific) and one think is they use (indirectly) a special bundle the osgi-resource-locator what has ResourceFinderImpl and a ServiceLoaderImpl that the simply scan all bundles for resources and classes.
This then is used inServiceLoader#lookupProviderInstances
I think it would be good do have something official in OSGi for such use case, that works the following
There is some static method e.g. FrameworkUtil#lookupProviderInstances
If running inside an OSGi Framework (e.g. getBundle of the caller return non null or using the bundle of the framework util) it performs a lookup in all active bundles
If not running inside OSGi it delegates to the default java meachnism
That way one would have some very low barrier way for mixed users to tell them to use this method and it will work inside OSGi and outside with just a small additional jar (osgi-core) and internally it can do what ever is the best for OSGi, no runtime classweaving or static weaving required, no "magic" osgiresourcelocator that is called by reflections and so on and no configuration.
The text was updated successfully, but these errors were encountered:
Currently there is not really an easy / convenient way to simply enumerate all service providers of all bundles, and as we all know this is maybe even bad and one should better use Service, DI and all kind of cool OSGi stuff.
On the other hand as a matter of fact there are uses of ServiceLoader around that will likely never migrate (most prominent JakartaEE) and technologies like ServiceLoader Mediator have there shortcomings as they require special configuration, care and knowledge of users (also know as "OSGi is to complex for us").
In JakartaEE on the other hand they are trying really hard to support all different kind of things (not only OSGi specific) and one think is they use (indirectly) a special bundle the osgi-resource-locator what has ResourceFinderImpl and a ServiceLoaderImpl that the simply scan all bundles for resources and classes.
This then is used inServiceLoader#lookupProviderInstances
I think it would be good do have something official in OSGi for such use case, that works the following
FrameworkUtil#lookupProviderInstances
That way one would have some very low barrier way for mixed users to tell them to use this method and it will work inside OSGi and outside with just a small additional jar (osgi-core) and internally it can do what ever is the best for OSGi, no runtime classweaving or static weaving required, no "magic" osgiresourcelocator that is called by reflections and so on and no configuration.
The text was updated successfully, but these errors were encountered: