Browse Source

Explicit note on FactoryBean resolution with MBeanExporter

Closes gh-21676
pull/31496/head
Juergen Hoeller 2 years ago
parent
commit
d58e48d9f5
  1. 17
      framework-docs/modules/ROOT/pages/integration/jmx/exporting.adoc

17
framework-docs/modules/ROOT/pages/integration/jmx/exporting.adoc

@ -183,18 +183,21 @@ as the following example shows:
If you configure a bean with an `MBeanExporter` that is also configured for lazy If you configure a bean with an `MBeanExporter` that is also configured for lazy
initialization, the `MBeanExporter` does not break this contract and avoids initialization, the `MBeanExporter` does not break this contract and avoids
instantiating the bean. Instead, it registers a proxy with the `MBeanServer` and instantiating the bean. Instead, it registers a proxy with the `MBeanServer` and defers
defers obtaining the bean from the container until the first invocation on the proxy obtaining the bean from the container until the first invocation on the proxy occurs.
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]] [[jmx-exporting-auto]]
== Automatic Registration of MBeans == Automatic Registration of MBeans
Any beans that are exported through the `MBeanExporter` and are already valid MBeans are Any beans that are exported through the `MBeanExporter` and are already valid MBeans
registered as-is with the `MBeanServer` without further intervention from Spring. You can cause MBeans are registered as-is with the `MBeanServer` without further intervention from Spring.
to be automatically detected by the `MBeanExporter` by setting the `autodetect` You can cause MBeans to be automatically detected by the `MBeanExporter` by setting
property to `true`, as the following example shows: the `autodetect` property to `true`, as the following example shows:
[source,xml,indent=0,subs="verbatim,quotes"] [source,xml,indent=0,subs="verbatim,quotes"]
---- ----

Loading…
Cancel
Save