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

Add classpath: scheme support (similar to Spring) #1141

Open
magicprinc opened this issue Mar 22, 2024 · 0 comments
Open

Add classpath: scheme support (similar to Spring) #1141

magicprinc opened this issue Mar 22, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@magicprinc
Copy link

magicprinc commented Mar 22, 2024

In Spring, one can (or rather have to) add classpath: scheme-prefix to a resource name to specify search of the resource in the ClassPath.

In SmallRyeConfig, "no prefix" means a ClassPath search.

Could you add additional/optional classpath: scheme-prefix support
(AbstractLocationConfigSourceLoader#loadConfigSources):

  • it makes using of SmallRyeConfig with Spring more pleasant and
  • it allows disabling search in the file system, if only the class path search is required.

See also: #1101

~

protected List<ConfigSource> loadConfigSources(final String[] locations, final int ordinal, final ClassLoader classLoader) {
  if (locations == null || locations.length == 0) {
    return Collections.emptyList();
  }

  final List<ConfigSource> configSources = new ArrayList<>();
  for (String location : locations) {
    final URI uri = URI_CONVERTER.convert(location);
    if (uri.getScheme() == null) {
      configSources.addAll(tryFileSystem(uri, ordinal));
      configSources.addAll(tryClassPath(uri, ordinal, classLoader));
    } else if ("classpath".equals(uri.getScheme())) {
      uri = new URI(uri.toString().substring(10));
      configSources.addAll(tryClassPath(uri, ordinal, classLoader));
    } else if (uri.getScheme().equals("file")) {
      configSources.addAll(tryFileSystem(uri, ordinal));
    } else if (uri.getScheme().equals("jar")) {
      configSources.addAll(tryJar(uri, ordinal));
    } else if (uri.getScheme().startsWith("http")) {
      configSources.addAll(tryHttpResource(uri, ordinal));
    } else {
      throw ConfigMessages.msg.schemeNotSupported(uri.getScheme());
    }
  }
  return configSources;
}```
@radcortez radcortez added the enhancement New feature or request label Sep 20, 2024
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