Defining Your Own MBeans in an Extension

You can also expose JMX interfaces for your own beans. Expose them by editing the Data Hub extension's Spring XML configuration file to specify which beans should be exposed.

First, the class instance should be defined as a spring bean in the extension's Spring XML configuration file (see first entry in the following example). Next, the newly defined spring bean is added to the map of beans configured in the MBeanExporter (see second entry in the following example).

my-extension-datahub-extension-spring.xml
<bean id="myExtension" class="com.mycompany.MyExtension">
   <property name="order" value="1" />
</bean>
 
<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter" lazy-init="false">
   <property name="beans">
      <map>
         <entry key="bean:name=testBean1" value-ref="myExtension" />
      </map>
   </property>
</bean>
At this point, the use of Spring @ManagedResource annotations is not supported for extensions.