osgi icon indicating copy to clipboard operation
osgi copied to clipboard

Enhance Resolver Service with SPI Support

Open laeubi opened this issue 2 months ago • 1 comments

Enables obtaining resolver instances outside OSGi frameworks using Java SPI, similar to FrameworkFactory

Problem

Resolvers are needed in many scenarios before/outside OSGi:

  • Framework initialization
  • Build tools (Maven, Gradle, bnd)
  • IDEs analyzing dependencies
  • Provisioning tools
  • Feature launchers

Currently requires referencing specific implementation classes.

Solution

New ResolverFactory interface using Java Service Provider mechanism, plus osgi.resolver.class framework property for resolver selection.

Changes

  • ResolverFactory.java: New interface for creating resolvers
  • Constants.java: Added FRAMEWORK_RESOLVER_CLASS constant
  • service.resolver.xml: New "Obtaining Resolvers Outside OSGi" section
  • framework.lifecycle.xml: Added osgi.resolver.class property documentation

Usage

ServiceLoader<ResolverFactory> loader = 
    ServiceLoader.load(ResolverFactory.class);
Resolver resolver = loader.findFirst()
    .map(ResolverFactory::getResolver)
    .orElseThrow();

Benefits

  • Standard, discoverable way to obtain resolvers
  • Frameworks expose resolvers for tooling
  • Same resolution algorithm in dev and runtime
  • Pluggable resolver implementations
  • Optional logging for debugging

laeubi avatar Nov 18 '25 14:11 laeubi

@tjwatson I (hopefully) addressed your review comments now that is:

  1. Using Resolver as the SPI interface directly, no factory
  2. Removing any changes in the core spec, focus on Resolver spec only.

laeubi avatar Dec 16 '25 11:12 laeubi