Skip to content

Document PluginManager.getExtensions instantiation #293 - #681

Merged
decebals merged 2 commits into
pf4j:masterfrom
AzazelSensei:docs-293-get-extensions
Sep 2, 2026
Merged

decebals merged 2 commits into
pf4j:masterfrom
AzazelSensei:docs-293-get-extensions

Conversation

@AzazelSensei

Copy link
Copy Markdown
Contributor

The getExtensions methods on PluginManager had almost no API docs.

I documented the current DefaultPluginManager / AbstractExtensionFinder behavior:

  • instances are created on getExtensions, not at load/start
  • only STARTED plugins contribute (null pluginId is the application classpath)
  • DefaultExtensionFactory makes a new instance each call; SingletonExtensionFactory reuses
  • unknown plugin id or missing type returns an empty list

Fixes #293

Describe when instances are created, which plugin states contribute,
whether repeated calls reuse instances, and that unknown ids or types
return an empty list.

Fixes pf4j#293
@decebals

decebals commented Sep 2, 2026

Copy link
Copy Markdown
Member

Thanks, this closes a gap that has been open since 2019, and the behaviour you describe matches the code. I checked each claim against AbstractExtensionFinder and AbstractPluginManager: the wrappers are rebuilt on every find, a plugin that is not started contributes nothing, a null plugin id reads the application classpath, and an instantiation failure is wrapped in a PluginRuntimeException that getExtensions logs and skips. Javadoc builds clean with the new links.

One thing to fix before this can go in: the changelog entry uses [#293] but the link definition at the bottom of the file is missing, so it renders as plain text. Please add

[#293]: https://github.com/pf4j/pf4j/issues/293

with the others, they are kept in descending order.

@decebals

decebals commented Sep 2, 2026

Copy link
Copy Markdown
Member

Following up on my own review, I looked at what the claims say and not at where they sit, and I think part of this belongs one layer down.

PluginManager does not reference an implementation anywhere today, and this would be the first place naming DefaultPluginManager, DefaultExtensionFactory and SingletonExtensionFactory. An interface also cannot promise that something gets logged.

Could you keep on the interface what any implementation has to honour: never null, an empty list for an unknown id or a type with no extensions, a null plugin id meaning the application classpath, and that instances come from the ExtensionFactory, which decides whether they are shared or created per call.

The rest, that instances are created on the call rather than at load or start, that only started plugins contribute, the two factories, and the logging, reads well on the AbstractPluginManager overrides, where that behaviour actually lives. #293 asks for exactly that distinction, it accepts "implementation defined" as an answer.

If you would rather not come back to this, say so and we will do the move in a follow-up, the content is yours either way.

Sorry for coming back with this after approving the substance.

Keep the interface contract (never null, empty list, null plugin id,
ExtensionFactory identity) and document started-plugin, factory, and
logging behaviour on AbstractPluginManager. Add the pf4j#293 changelog link.
@AzazelSensei

Copy link
Copy Markdown
Contributor Author

Moved the DefaultPluginManager / factory / logging bits onto the AbstractPluginManager overrides and left the interface at the contract you listed (never null, empty list, null plugin id, ExtensionFactory identity). Added the [#293] changelog link.

@decebals

decebals commented Sep 2, 2026

Copy link
Copy Markdown
Member

Thanks for the contribution, and for the quick turnaround. This is what I meant, and the changelog link is in the right place.

@decebals
decebals merged commit 25a20fb into pf4j:master Sep 2, 2026
1 check passed
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.

Document how Extensions are instantiated

2 participants