-
Notifications
You must be signed in to change notification settings - Fork 104
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
Use OSGi service loader mediator instead of osgi resource locator #630
Comments
Having found the usage of hk2 to be implemented only partially, I have patched the In Require-Capability: osgi.extender;filter:="(osgi.extender=osgi.servicelo
ader.processor)";resolution:=optional,osgi.ee;filter:="(&(osgi.ee=JavaS
E)(version=1.8))" In Provide-Capability: osgi.serviceloader;osgi.serviceloader="jakarta.mail.
util.StreamProvider"
Require-Capability: osgi.extender;filter:="(osgi.extender=osgi.servicelo
ader.registrar)",osgi.extender;filter:="(osgi.extender=osgi.serviceload
er.processor)";resolution:=optional,osgi.ee;filter:="(&(osgi.ee=JavaSE)
(version=1.8))" And in Provide-Capability: osgi.serviceloader;osgi.serviceloader="jakarta.mail.
Provider"
Require-Capability: osgi.extender;filter:="(osgi.extender=osgi.servicelo
ader.registrar)",osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))" Note that adding these headers completely obsoletes the need for hk2. |
Until all OSGi related issues are fixed (see jakartaee/mail-api#629, jakartaee/mail-api#630, jakartaee/mail-api#631).
In my opinion that new PR will be better. Also because there is a process to approve new dependencies (actually in APIs it is forbidden non-jakarta libs). |
* Fix for #630. * Service loader mediator without annotations. * HK2 is a special, not the general OSGi solution. * Keep HK2 service loader optional.
To separate the API and the implementation, the service loader pattern is used. This perfectly well suited mechanism is known to have problems in OSGi environments.
An attempt has been made in the jakarta mail api implementation to solve the problems with org.glassfish.hk2.osgi-resource-locator, which requires lots of special coding.
The "service loader and OSGi" problem has actually successfully been addressed before by http://docs.osgi.org/specification/osgi.enterprise/7.0.0/service.loader.html with the reference implementation (with an easier to read description) SPI Fly. What it boils down to is that instead of having to maintain the complicated code, you can simply use the service locator after adding some statements to MANIFEST.MF.
While this is not a runtime bug, because you can use Jakarta mail api in an OSGi environment (once you have found out that you need to include the hk2 jar and once #629 will be fixed), I think it is a bug with respect to the design.
The text was updated successfully, but these errors were encountered: