bcritch
Jun 5th, 2006, 10:36 AM
I have a bean that needs to be created on the fly (thus non-singleton) while my application is loading. I am trying to have Spring auto-detect the non-singleton bean and wrap each instance so that I can monitor them (each instance is an event queue), but what I have noticed is that Spring seems to instantiates an instance of the bean that it uses to export as the mbean, and the other instances that are created by bean lookup in my application are not exported as mbeans. I looked at the code in for MBeanExporter and it looks like if the bean is not lazy-init enabled, it will create an instance via bean lookup. As non-singleton beans cannot be marked lazy-init I am not sure what to do. I appreciate any help.
<bean id="eventProcessorImpl" singleton="false" class="com.xyz.tomahawk.core.EventProcessorImpl">
<constructor-arg index="0"><value>100000</value></constructor-arg>
</bean>
<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
<property name="autodetect" value="true"/>
<property name="assembler" ref="assembler"/>
<property name="namingStrategy" ref="namingStrategy"/>
</bean>
<bean id="attributeSource" class="org.springframework.jmx.export.annotation.Annotati onJmxAttributeSource"/>
<bean id="assembler" class="org.springframework.jmx.export.assembler.MetadataM BeanInfoAssembler">
<property name="attributeSource" ref="attributeSource"/>
</bean>
<bean id="namingStrategy" class="org.springframework.jmx.export.naming.MetadataNami ngStrategy">
<property name="attributeSource" ref="attributeSource"/>
</bean>
<bean id="eventProcessorImpl" singleton="false" class="com.xyz.tomahawk.core.EventProcessorImpl">
<constructor-arg index="0"><value>100000</value></constructor-arg>
</bean>
<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
<property name="autodetect" value="true"/>
<property name="assembler" ref="assembler"/>
<property name="namingStrategy" ref="namingStrategy"/>
</bean>
<bean id="attributeSource" class="org.springframework.jmx.export.annotation.Annotati onJmxAttributeSource"/>
<bean id="assembler" class="org.springframework.jmx.export.assembler.MetadataM BeanInfoAssembler">
<property name="attributeSource" ref="attributeSource"/>
</bean>
<bean id="namingStrategy" class="org.springframework.jmx.export.naming.MetadataNami ngStrategy">
<property name="attributeSource" ref="attributeSource"/>
</bean>