-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core: Add support for ServiceLoader to the Core Framework #372
Comments
I would support that as well, because the ServiceLoader Mediator requires its Capabilities to work properly. |
I once tried to use that but it seems not fitting very well because it seem to be limited to the use of ServiceLoader.load() calls but I must confess I never wanted to use it that way but the other way round: Accessing ServiceLoader specified services in an OSGi way
I once written a extender-bundle that simply discovers SPI in
Jakarta can uses an OSGi-aware serviceloader that works quite well. I just always wondered why they did not simply delegate to standard java ServiceLoader.load() if nothing is found (it instead returns null then) this requires some care on the caller-side, but maybe this can server as an inspiration? So if the |
Service Loader Mediator automatically makes services OSGi service already provided you set the Furthermore, since the last few versions SPI Fly can be used without metadata in the provider/consumer bundles in question. You can force bundle(s) which do not have SLM requirements or capabilities using framework properties: org.apache.aries.spifly.auto.consumers=<comma_delimited_bsn_globs>
org.apache.aries.spifly.auto.providers=<comma_delimited_bsn_globs> #here you can add service properties using OSGi package attribute syntax All this needs better docs for sure. |
@rotty3000 probably yes... I just failed to get it setup and the aries stuff often pulls in a lot of stuff, much more effort I want to spend for a simple lookup :-) At least this "automatically makes services OSGi service already provided" has not worked well starting without a managed setup (e.g. karaf). |
SPI Fly can have as little as itself and OSGi as a dependency. (See org.apache.aries.spifly:org.apache.aries.spifly.dynamic.framework.extension:1.3.4). You do not need a managed setup for everything described above. You do however have to have the correct metadata. |
@rotty3000 I'll give it another try nex time it becomes relevant, maybe I can use this for pax-jpa as well, maybe its just a matter of
are you a developer of the spi-fly project as well? |
yes I am, sadly I'm not in love with the tech Aries has migrated to for documentation. I find it very painful and this didn't help the fact that a lot of Aries docs were already extremely out of date. But that isn't your problem and it's not an excuse for poor docs... |
@rotty3000 currently using JAXB in OSGi requires an OSGi-aware serviceloader do you think you can help the eclipse-ee4j people to add appropriate headers so it works with the spifly instead? I'm also interested in replacing pax-jpa tracker with using spifly would that be possible? |
Hey @laeubi sorry for the delayed answer but I wanted to make a first pass to fix the SPI Fly documentation [1] so that I could use it to answer your question :D Please review it to see if that helps you with JAXB (it's not very long). I've been using SPI Fly's auto properties [2] to handle JAXB in Aries JAX-RS whiteboard [3] successfully ever since this was implemented. In other words I didn't go the route of modifying the JAXB API or Implementation to add SLM requirements&capabilities but I still get a working system. [1] https://aries.apache.org/documentation/modules/spi-fly.html |
No problem, I'll try to give it a try the next days, the documentation is much clearer now I think. I'm just a bit uncertain about JAX weaving versus the OSGi-Serviceloader, but this sounds interesting for cases where the consumer is not aware of OSGi.. There is just one use-case I feel missing (I hope it is ok to discuss this in the context of this issue, if not let me know a better place): According to the docs I need to provide some framework properties, this seems rather "static" and I need to know the name of the bundles beforehand, also I don't see a way to limit the registration to some SPI interface. What would be useful I think would be the following:
|
Hi @laeubi I think this is an interesting conversation. Could we take over to the Aries dev mail list or possibly in Aries JIRA? |
I have created https://issues.apache.org/jira/browse/ARIES-2071 |
how to solve this error iam working on with the open jpa it requires the geronimo and the geronimo pom.xml has the require capability of osgi.serviceLoader @rotty3000 @bjhargrave @laeubi @maho7791 how to solve this |
@muthukumar1756 - please open a new issue for usage questions. This issue is a design discussion for a new feature in the OSGi core specification. |
may be done together with #685 |
We have a Service Loader Mediator spec. But it is not built into the framework and currently depends upon weaving.
I would like to explore adding support directly unto the framework for the Service Loader model. JPMS has direct support for the Service Loader model via
uses
andprovides
in the module-info file. JPMS has advantages since it is built into the java runtime, so we may not be able to do as well. But I suspect we can do better than the current Service Loader Mediator spec by building this function into the core framework.The text was updated successfully, but these errors were encountered: