Skip to content

Commit

Permalink
Explicit note on FactoryBean resolution with MBeanExporter
Browse files Browse the repository at this point in the history
Closes gh-21676
  • Loading branch information
jhoeller committed Aug 8, 2023
1 parent 8973d1a commit d58e48d
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions framework-docs/modules/ROOT/pages/integration/jmx/exporting.adoc
Expand Up @@ -183,18 +183,21 @@ as the following example shows:

If you configure a bean with an `MBeanExporter` that is also configured for lazy
initialization, the `MBeanExporter` does not break this contract and avoids
instantiating the bean. Instead, it registers a proxy with the `MBeanServer` and
defers obtaining the bean from the container until the first invocation on the proxy
occurs.
instantiating the bean. Instead, it registers a proxy with the `MBeanServer` and defers
obtaining the bean from the container until the first invocation on the proxy occurs.

This also affects `FactoryBean` resolution where `MBeanExporter` will regularly
introspect the produced object, effectively triggering `FactoryBean.getObject()`.
In order to avoid this, mark the corresponding bean definition as lazy-init.


[[jmx-exporting-auto]]
== Automatic Registration of MBeans

Any beans that are exported through the `MBeanExporter` and are already valid MBeans are
registered as-is with the `MBeanServer` without further intervention from Spring. You can cause MBeans
to be automatically detected by the `MBeanExporter` by setting the `autodetect`
property to `true`, as the following example shows:
Any beans that are exported through the `MBeanExporter` and are already valid MBeans
are registered as-is with the `MBeanServer` without further intervention from Spring.
You can cause MBeans to be automatically detected by the `MBeanExporter` by setting
the `autodetect` property to `true`, as the following example shows:

[source,xml,indent=0,subs="verbatim,quotes"]
----
Expand Down

0 comments on commit d58e48d

Please sign in to comment.