title: MBean persistence
body: <p>I have a problem with persistence of my config MBean. My configuration:</p>
  
  <pre><code>&lt;bean id="adminMBean" class="pl.mobileexperts.catchme.mbeans.AdminSettingsMBean"&gt;&lt;/bean&gt;
  
  &lt;bean id="exporter" class="org.springframework.jmx.export.MBeanExporter"&gt;
      &lt;property name="assembler" ref="assembler" /&gt;
      &lt;property name="autodetect" value="true" /&gt;
      &lt;property name="namingStrategy" ref="namingStrategy"/&gt;
  &lt;/bean&gt;
  
  &lt;bean id="attributeSource" class="org.springframework.jmx.export.annotation.AnnotationJmxAttributeSource" /&gt;
  &lt;bean id="namingStrategy" class="org.springframework.jmx.export.naming.MetadataNamingStrategy"&gt;
      &lt;property name="attributeSource" ref="attributeSource" /&gt;
  &lt;/bean&gt;
  &lt;bean id="assembler" class="org.springframework.jmx.export.assembler.MetadataMBeanInfoAssembler"&gt;
      &lt;property name="attributeSource" ref="attributeSource" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <hr>
  
  <pre><code> @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;
        }
   }
  </code></pre>
  
  <p>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?</p>
  
  <p>My JBoss config is default (jboss-service.xml)</p>