Uh oh!
There was an error while loading. Please reload this page.
feat(GH-188): Implement package type providers - #223
Conversation
This uses the Java Service Provider Interface via `ServiceLoader` to register new types, where each type gets its own class.
My 2 cents about the API changes:
|
@ppkarwasz I made most of the changes you suggested, but I need to know how to update the [WARNING] bnd.bnd [0:0]: jpms.jarname calculated module names from file name: [org.osgi.resource-1.0.0, org.osgi.service.serviceloader-1.0.0][ERROR] bnd.bnd [0:0]: Requirement osgi.extender resolution not correct[ERROR] bnd.bnd [0:0]: Requirement osgi.serviceloader cardinality not correct[ERROR] bnd.bnd [0:0]: Requirement osgi.serviceloader resolution not correct |
dwalluck
commented
Mar 27, 2025
@ppkarwasz There seems to be duplicated classes between this and |
dwalluck
commented
Mar 27, 2025
@ppkarwasz I think it's better to auto-generate this file if we can. |
| value = PackageTypeProvider.class, | ||
| resolution = Requirement.Resolution.MANDATORY, | ||
| cardinality = Requirement.Cardinality.MULTIPLE) | ||
| public final class PackageTypeFactory implements PackageTypeProvider { |
There was a problem hiding this comment.
It bothers me to have the factory class also implementing some type of provider, since it's not actually added to the set of providers.
This is trying to provider the default normalization that needs to happen before all type-specific normalization.
But, maybe there is a better way to do this (add it to the list in the first position?).
| try { | ||
| PackageURL packageURL = normalize(); | ||
| namespace = packageURL.getNamespace(); | ||
| name = packageURL.getName(); | ||
| version = packageURL.getVersion(); | ||
| qualifiers = packageURL.getQualifiers(); | ||
| subpath = packageURL.getSubpath(); | ||
| } catch (MalformedPackageURLException e) { | ||
| throw new ValidationException("Normalization failed", e); | ||
| } | ||
There was a problem hiding this comment.
This is kind of a hack right now.
dwalluck
commented
Apr 4, 2025
@ppkarwasz I am stuck on the OSGi errors. I don't have experience creating a bnd file manually as opposed to plugins that generate the |
ppkarwasz
commented
Apr 4, 2025
I'll check it out. |
ppkarwasz
left a comment
There was a problem hiding this comment.
The BND errors are due to the wrong constants being used.
| import org.osgi.annotation.bundle.Requirement.Cardinality; | ||
| import org.osgi.annotation.bundle.Requirement.Resolution; |
There was a problem hiding this comment.
| importorg.osgi.annotation.bundle.Requirement.Cardinality; | |
| importorg.osgi.annotation.bundle.Requirement.Resolution; | |
| importaQute.bnd.annotation.Cardinality; | |
| importaQute.bnd.annotation.Resolution; |
There was a problem hiding this comment.
Thanks! I was using something from aQute, but it said deprecated use the OSGi ones, but now I can't find it.
| import java.util.Map; | ||
| import org.jspecify.annotations.NonNull; | ||
| import org.jspecify.annotations.Nullable; | ||
| import org.osgi.annotation.bundle.Requirement.Resolution; |
There was a problem hiding this comment.
| importorg.osgi.annotation.bundle.Requirement.Resolution; | |
| importaQute.bnd.annotation.Resolution; |
ppkarwasz
commented
Apr 8, 2025
What bothers me a little with the current proposal is that type-specific normalization and validation only occurs when
I deduce that the components should only and always be stored in normalized form (and be valid). So the |
jeremylong
commented
May 6, 2025
I like this approach - each type can implement the |
This uses the Java Service Provider Interface via
ServiceLoaderto register new types, where each type gets its own class.