Skip to content
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

Change Request: opening API for BundleSchemeResourceFinderFactory.SCHEMES class attribute #5820

Open
ffays opened this issue Dec 17, 2024 · 6 comments
Labels
enhancement New feature or request

Comments

@ffays
Copy link

ffays commented Dec 17, 2024

Could you please open the implementation of the attribute SCHEMES of the class org.glassfish.jersey.server.internal.scanning.BundleSchemeResourceFinderFactory to allow runtime modifications, e.g.

public static final Set<String> SCHEMES =  new TreeSet<>(Collections.singleton("bundle"));

So library users can programmatically add other schemes, e.g.

BundleSchemeResourceFinderFactory.SCHEMES.add("bundleentry");

A use case is for the Eclipse plugins, that are OSGi bundles, were the scheme can be bundleentry as well.


Otherwise, could you please at least add bundleentry to the Set, e.g.

private static final Set<String> SCHEMES =  Set.of("bundle", "bundleentry");
@jansupol jansupol added the enhancement New feature or request label Dec 18, 2024
@jansupol
Copy link
Contributor

What Jersey are you on?

@ffays
Copy link
Author

ffays commented Dec 18, 2024

Jersey 3.1.9

@ffays
Copy link
Author

ffays commented Dec 18, 2024

Note this request applies to Jersey 4 branch as well.
As I would like to have this functionality enabled from Jersey 3.1 onwards.

Thank you!

@ffays
Copy link
Author

ffays commented Jan 7, 2025

Any update?

@jansupol
Copy link
Contributor

jansupol commented Jan 7, 2025

I would assume the comment was meant as the place for an extension. Would it suit your use-case?

@ffays
Copy link
Author

ffays commented Jan 9, 2025

Thank you for your follow-up.

It seems elegant.

Now we have to assess if that will not lead to a dependency dead-end.

Explanation:

It implies that my bundle will have to provide a custom UriSchemeResourceFinderFactory service.
So my bundle will need a dependency to org.glassfish.jersey.core.jersey-server bundle in order to extend UriSchemeResourceFinderFactory class.
On the other hand when instantiating a PackageNamesScanner, the org.glassfish.jersey.core.jersey-server bundle will need to have my bundle available to find my custom UriSchemeResourceFinderFactory service ...
Therefore it may work depending on the sequence.

Note that you can still do all the proposals, i.e.

  1. Add bundleentry value to SCHEMES attribute of BundleSchemeResourceFinderFactory, i.e. using Eclipse Equinox, to access a resource within a jar, the bundleentry scheme must be used. (Whereas when the bundle is expanded on the File System, bundle scheme must be used). So in both case it is about resources in a Bundle, therefore to my point of view, it make totally sense that it is part of the BundleSchemeResourceFinderFactory.
  2. To open the org.glassfish.jersey.core.jersey-server to custom UriSchemeResourceFinderFactory factories as you suggest.
  3. ... And possibly still make public the SCHEMES attribute of BundleSchemeResourceFinderFactory, assigned with a mutable Set instance. Why to tighten the API and close possibilities to library users? I.e. when I make a java library, I never use the private keyword, at most I use the protected keyword, doing so it ease extension possibilities for the library users!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants