Skip to content

Conversation

@findepi
Copy link

@findepi findepi commented Dec 30, 2025

Some applications exports mbeans in one place, from one class loader,
and so they do not need namespacing as class name-generated mbean names
do not collide. Some applications use multiple class loaders and
therefore require additional configuration for exporting mbeans safely.
The MBeanModule provides sufficient configuration options, allowing
users to bind ObjectNameGenerator, but its default behavior turned out
to be error-prone at least in projects such as Trino. It seems safer to
require explicit opt-in into unnamespaced exports.

This commit deprecates MBeanModule constructor in favor of named
factory methods for explicit declaration whether default
ObjectNameGenerator should be used, or custom one will be provided.

The "for custom" factory creates a module that will fail to load unless
a custom ObjectNameGenerator is bound.

The "for unnamespaced" creates a module with default
ObjectNameGenerator. The factory name is meant to be thought-provoking
and therefore the name generator bound this way is not rebindable.

The new MBeanModule() constructor is kept, but deprecated. It supports
the original behavior allowing users to rebind name generator.

Motivation

Some applications exports mbeans in one place, from one class loader,
and so they do not need namespacing as class name-generated mbean names
do not collide. Some applications use multiple class loaders and
therefore require additional configuration for exporting mbeans safely.
The `MBeanModule` provides sufficient configuration options, allowing
users to bind `ObjectNameGenerator`, but its default behavior turned out
to be error-prone at least in projects such as Trino. It seems safer to
require explicit opt-in into unnamespaced exports.

This commit deprecates `MBeanModule` constructor in favor of named
factory methods for explicit declaration whether default
`ObjectNameGenerator` should be used, or custom one will be provided.

The "for custom" factory creates a module that will fail to load unless
a custom `ObjectNameGenerator` is bound.

The "for unnamespaced" creates a module with default
`ObjectNameGenerator`. The factory name is meant to be thought-provoking
and therefore the name generator bound this way is not rebindable.

The `new MBeanModule()` constructor is kept, but deprecated. It supports
the original behavior allowing users to rebind name generator.
@wendigo
Copy link
Contributor

wendigo commented Jan 7, 2026

@martint ptal

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.

2 participants