Persistence not quite working
bossy Jan 30, 2007 12:31 PMHello,
I have two XMBeans which attributes I'd like to persist. My problem is that while the first MBean persists its attributes, the second doesn't. After couple of hours I found out that the difference between the two XMBeans is that the attributes for the first one( which is a configuration bean) are ?read-write? and when I press ?Apply Changes? button from the JMX console, the values are saved as per the ?xmbean.xml file. The attributes of the second one are ?read-only?, as I update them using a different mechanism. This results in the attribute values not being saved. I added a setter to one of the attributes( just to prove that this is indeed the reason) and once I updated this attribute by clicking on the ?Apply changes? button, the value was saved and the next time I re-started the server I was able to see the correct value.
My question is ? is this a bug and is there a way to work around this problem?
To illustrate the problem I added extracts from my code
stats-xmbean.xml
<!DOCTYPE mbean PUBLIC
 "-//JBoss//DTD JBOSS XMBEAN 1.0//EN"
 "http://www.jboss.org/j2ee/dtd/jboss_xmbean_1_0.dtd">
<mbean>
 <description></description>
 <descriptors>
 <persistence persistPolicy="OnUpdate"
 persistPeriod="10"
 persistLocation="${jboss.server.data.dir}"
 persistName="StatsJNDIMap.ser"/>
 <currencyTimeLimit value="10"/>
 <state-action-on-update value="keep-running"/>
 <persistence-manager value="org.jboss.mx.persistence.ObjectStreamPersistenceManager" />
 </descriptors>
 <class>org.jboss.test.jmx.xmbean.JNDIMap</class>
 <constructor>
 <description>The default constructor</description>
 <name>JNDIMap</name>
 </constructor>
 <!-- Attributes -->
 <attribute access="read-write" getMethod="getStartDate" setMethod="setStartDate">
 <description>Start Date</description>
 <name>Start Date</name>
 <type>java.lang.String</type>
 </attribute>
 <attribute access="read-only" getMethod="getInBoxReqCount" >
 <description>Number of requests</description>
 <name>Get Message Requests</name>
 <type>java.lang.String</type>
 </attribute>
 ... more
StatsXMBean.java
public class StatsXMBean extends ServiceMBeanSupport
{
... more
} 
    