0 Replies Latest reply on Aug 18, 2016 6:44 AM by mikeburger

    WildFly 10 MBean Attribute Persistence

    mikeburger

      hi,

      i'm trying to get a service MBean, which is working under JBoss 5, to work under WildFly 10.0.0.Final.

      the deployment works (using the jboss-service.xml at the end of this post),

      changing attributes via JConsole and hawtio jmx-console works,

      but the MBean's attributes are not getting persisted - when redeploying or restarting WildFly the values are getting reset.

       

      under JBoss 5 the attributes get stored in an xml file - how to get this functionality under WildFly?

       

      since i'm very new to this a "how to port for dummies" would be great.

       

      thanks,

      mike

       

      public interface UpdaterMBean
      {
          public String getUpdateURL();
          public void setUpdateURL( String url );
      }
      

       

      public class Updater implements UpdaterMBean
      {
          protected String updateURL;
      
          /**
           * @jmx:managed-attribute
           */    
          @Override
          public String getUpdateURL()
          {
              return updateURL;
          }
      
          /**
           * @jmx:managed-attribute
           */    
          @Override
          public void setUpdateURL( String url )
          {
              this.updateURL = url;
          }
      }
      

       

      jboss-service.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE jboss-web PUBLIC "-//JBOSS//DTD Web Application 2.5//EN" "jboss-service_5_0.dtd">
      <server>
          <mbean code="com.foo.Updater" name="com.foo:service=Updater" xmbean-dd="Updater-xmbean.xml">    
               <depends>jboss:service=AttributePersistenceService</depends>    
          </mbean>
      </server>
      

       

      Updater-xmbean.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE mbean PUBLIC "-//JBoss//DTD JBOSS XMBEAN 1.1//EN" "jboss_xmbean_1_1.dtd">
      <mbean>
          <description>Update service</description>
      
          <descriptors>
              <persistence persistPolicy="OnUpdate" />
              <persistence-manager value="org.jboss.mx.persistence.DelegatingPersistenceManager" />
          </descriptors>
      
          <class>com.foo.Updater</class> 
      
          <constructor>
              <description>The default constructor</description>
              <name>Updater</name>
          </constructor>
      
          <attribute access="read-write" getMethod="getUpdateURL" setMethod="setUpdateURL">  
              <description>Server URL to check for updates</description>  
              <name>UpdateURL</name>  
              <type>java.lang.String</type>
              <descriptors>
                  <value value="https://foo.org/builds/release/" />
              </descriptors>
          </attribute>  
      </mbean>
      

       

      jboss-service.xml (WildFly)

      <?xml version="1.0" encoding="UTF-8"?>
      <server xmlns="urn:jboss:service:7.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:jboss:service:7.0 jboss-service_7_0.xsd">        
          <mbean code="com.foo.Updater" name="com.foo:service=Updater">
               <attribute name="updateURL">https://foo.org/builds/release/</attribute>
          </mbean>
      </server>