Our application has requirement to limit user access to subset of JMX attributes and operations for a given MBean. e.g. the C3P0 MBean exposes a lot of attributes/operations. Let's say we don't want users to change min pool size. Hence we would like to suppress the setter of that attribute in the JMX console.
Looking at the Spring doc, I thought it would be possible: http://docs.spring.io/spring/docs/current/spring-framework-reference/html/jmx.html
Below is my tryst with Hibernate MBean:
<bean id="hibernateStatisticsMBean" class="org.hibernate.jmx.StatisticsService">
<property name="statisticsEnabled" value="true" />
<property name="sessionFactory" value="#{myEntityManagerFactory.sessionFactory}" />
</bean>
<bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServerFactoryBean">
<property name="locateExistingServerIfPossible" value="true" />
</bean>
<bean id="jmxExporter" class="org.springframework.jmx.export.MBeanExporter" lazy-init="false">
<property name="server" ref="mbeanServer" />
<property name="beans">
<map>
<entry key="Hibernate:name=hibernateStatistics" value-ref="hibernateStatisticsMBean" />
</map>
</property>
<property name="assembler">
<bean class="org.springframework.jmx.export.assembler.MethodNameBasedMBeanInfoAssembler">
<property name="managedMethods">
<list>
<value>clear</value>
</list>
</property>
</bean>
</property>
</bean>
I was hoping that only clear method will show up for Hibernate MBean in JMX console. However the above config is exposing all the original Hibernate MBean methods.
Secondly, C3P0 Mbean is exposed by default, and I do not need Spring bean to expose it. That MBean shows up in console as "PooledDataSource[2spw3u98bqgqeg1697gnx|73302995]". I am not sure what would be the right way to expose only a subset of attributes & operations for that MBean.
Your help/pointers are appreciated. Thanks.