I have a problem with persistence of my config MBean. My configuration:
<bean id="adminMBean" class="pl.mobileexperts.catchme.mbeans.AdminSettingsMBean"></bean>
<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
<property name="assembler" ref="assembler" />
<property name="autodetect" value="true" />
<property name="namingStrategy" ref="namingStrategy"/>
</bean>
<bean id="attributeSource" class="org.springframework.jmx.export.annotation.AnnotationJmxAttributeSource" />
<bean id="namingStrategy" class="org.springframework.jmx.export.naming.MetadataNamingStrategy">
<property name="attributeSource" ref="attributeSource" />
</bean>
<bean id="assembler" class="org.springframework.jmx.export.assembler.MetadataMBeanInfoAssembler">
<property name="attributeSource" ref="attributeSource" />
</bean>
@ManagedResource(objectName = "pl.mobileexperts.catchme:name=adminMBean",
description ="admin settings",
persistPolicy = "OnUpdate",
persistLocation = "c:/", persistName = "adminSettings.jmx")
public class AdminSettingsMBean {
private boolean moderatorModeEnabled;
public AdminSettingsMBean() {
}
@ManagedAttribute(persistPolicy = "OnUpdate")
public boolean isModeratorModeEnabled() {
return moderatorModeEnabled;
}
@ManagedAttribute(persistPolicy = "OnUpdate")
public void setModeratorModeEnabled(boolean moderatorModeEnabled) {
this.moderatorModeEnabled = moderatorModeEnabled;
}
}
My goal is to save state after a property change (save to file or metadata - not to db). After a JBoss restart, my MBean is initialized with standard values. It seems PersistPolicy is not working... I tried to implement PersistentMBean, but store() and load() were never invoked. I found that it may be a JBoss JMX implementation issue. Also some people used AOP and annotated methods in MBean to store them. All these posts were from 2008-2010, so maybe something has changed?
My JBoss config is default (jboss-service.xml)
persistPolicy
? – Unfeigned