Skip to content

Add a Delegation Hook to the Core Framework - #77

Open
laeubi wants to merge 3 commits into
osgi:mainfrom
laeubi:design/970
Open

laeubi wants to merge 3 commits into
osgi:mainfrom
laeubi:design/970

Conversation

@laeubi

@laeubi laeubi commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Add a Delegation Hook to the Core Framework

Adds org.osgi.framework.hooks.delegation 1.0 with DelegationHook.
The framework consults it as a last step of the Overall Search Order, after nothing was found.
Hooks can only add classes and resources, never replace or hide what the wiring provides.

Motivation is osgi/osgi#970: extensions such as Java SPI mediation (osgi/osgi#372) need to contribute classes and resources across bundles without weaving or framework internals.

Commits

  1. .design/requirements-970.md
  2. .design/design-970.md
  3. API (DelegationHook), new specification chapter, and the search order paragraph in the module layer chapter

Key points

  • findClass and findResource are used only if the search order found nothing; findResources results are always appended.
  • Not consulted for java.* or for packages the bundle imports, requires or exports.
  • Hooks run in ranking order, without framework locks, and a throwing hook leads to a FrameworkEvent.ERROR.
  • A class taken from another bundle makes the asking bundle part of the provider's refresh dependency closure.
  • Registration requires ServicePermission[DelegationHook, REGISTER]; extension bundles can register it from their ExtensionBundle-Activator.

Open points

  • Plain dependency versus a real wire for provider classes.
  • Chapter number (58 is a placeholder).
  • No TCK yet.

Implementation

Prototypes in both major open source frameworks show the feasibility:

Describe an additive framework hook that lets extensions contribute classes and resources after the bundle Search Order found nothing, as needed by Java SPI mediation (osgi/osgi#970).

Signed-off-by: Christoph Läubrich <laeubi@laeubi-soft.de>
Define DelegationHook with findClass, findResource and findResources, consulted after the Search Order, with a refresh dependency instead of a wire.

Signed-off-by: Christoph Läubrich <laeubi@laeubi-soft.de>
Add org.osgi.framework.hooks.delegation 1.0 with DelegationHook, a new specification chapter, and the additional last step in the Overall Search Order.

Signed-off-by: Christoph Läubrich <laeubi@laeubi-soft.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant