Skip to content

Prototype: support the OSGi DelegationHook - #591

Draft
laeubi wants to merge 1 commit into
apache:masterfrom
laeubi:delegation-hook-prototype
Draft

laeubi wants to merge 1 commit into
apache:masterfrom
laeubi:delegation-hook-prototype

Conversation

@laeubi

@laeubi laeubi commented Nov 4, 2026

Copy link
Copy Markdown

Prototype: support the OSGi DelegationHook

Implements the proposed org.osgi.framework.hooks.delegation.DelegationHook in the Felix framework.
Spec proposal: osgi/org.osgi.framework#77, background osgi/osgi#970.
Equinox prototype: eclipse-equinox/equinox#1395.

Changes

  • Add the org.osgi.framework.hooks.delegation API and export it from the framework and main bundles.
  • DelegationHookSupport calls the hooks in ranking order.
    A hook that throws is reported as FrameworkEvent.ERROR and not called again.
  • BundleWiringImpl consults the hooks as the last step of the search order, after dynamic imports.
    This covers classes, single resources and resource enumerations.
    Hooks are skipped for java.* and for imported, required or exported packages.
  • BundleRevisionDependencies tracks classes taken from another bundle as a non-wire dependency, so the asking bundle is part of the provider's refresh closure.

Status

Prototype to show feasibility and surface spec questions, not a complete implementation.
DelegationHookTest covers class lookup with the dependency closure, the java.* skip, resource handling and a throwing hook.
No permission checks on registration yet, and the skip for imported, required and exported packages is not tested.

Findings for the spec discussion

  • Felix tracks the dependency as a plain refresh dependency, not a wire.
    This relates to the open point in the spec PR about a plain dependency versus a wire.
  • The dependency affects refresh only and does not stop a provider from being uninstalled.
  • Felix's re-entrancy guard is keyed by name only, so it also blocks a class and a resource lookup that share a name.
  • The hook runs inside the class-loading call.
    No global framework lock is held there, but the loader's own class-loading lock stays held.

Implements the proposed org.osgi.framework.hooks.delegation.DelegationHook
(osgi/org.osgi.framework#77) to show feasibility in Felix, analogous to
eclipse-equinox/equinox#1395.

- Add the DelegationHook API and export it from the framework and main bundles
- Consult hooks as the last step of the search order for classes, resources
  and resource enumerations; skip java.* and imported, required or exported
  packages
- Track classes provided by another bundle as a non-wire dependency so the
  asking bundle is part of the provider's refresh closure
- Report throwing hooks as FrameworkEvent.ERROR and blacklist them

Prototype only: no permission checks on registration and limited tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant