I am using Spring in conjunction with its MBeanExporter
. I have a prototype bean definition which should only be instantiated when a call to ApplicationContext.getBean()
is made. However, the MBeanExporter
is (incorrectly) instantiating an instance of the prototype bean when bootstrapping the container.
I found this bug report from ages ago, with no notable response.
This seems to me like it must be a common scenario, so I feel like I must be missing something. It's important that my prototype not be instantiated ahead of time, and that I can use MBeanExporter
to make my JMX integration simpler. Can anyone explain what I'm doing wrong?
For reference, my spring config looks like this:
<bean id="foo" class="MyPrototypeClassName" scope="prototype"/>
<bean id="namingStrategy" class="org.springframework.jmx.export.naming.IdentityNamingStrategy"/>
<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
<property name="namingStrategy" ref="namingStrategy"/>
<property name="autodetect" value="true"/>
</bean>