1 Reply Latest reply on Jan 21, 2005 11:44 AM by Scott Stark

    non-String attribute setting in <mbean> <attribute>

    mazz Master

      When configuring your MBeans, you can set attributes like this:

      <mbean code="com.abc.MyBean" name="domain:type=foo">
       <attribute name="FileName">/tmp/log.txt</attribute>
      </mbean>
      


      But that assumes all my attribute values are java.lang.String. What if my JMX attribute has a type other than String? In the above example, what if my "FileName" attribute is actually a java.io.File:

      com.abc.MyBeanMBean.java:

       public File getFileName() { ... };
       public void setFileName(File f) { ... };
      


      Will I need to do anything special to get JBoss to convert that XML string found in the configuration file to a File value?

        • 1. Re: non-String attribute setting in <mbean> <attribute>
          Scott Stark Master

          The majority of the jboss mbeans use non-string attributes. The conversion is based on the standard JavaBean property editor plugin mechanism. We bundle a number of property editors for commonly used types, java.io.File being one of them.

          [starksm@banshee9100 Releases]$ jar -tf jboss-4.0.1/lib/jboss-common.jar | grep propertyeditor
          org/jboss/util/propertyeditor/
          org/jboss/util/propertyeditor/BigDecimalEditor.class
          org/jboss/util/propertyeditor/BlockingModeEditor.class
          org/jboss/util/propertyeditor/BooleanEditor.class
          org/jboss/util/propertyeditor/ClassArrayEditor.class
          org/jboss/util/propertyeditor/ClassEditor.class
          org/jboss/util/propertyeditor/DateEditor.class
          org/jboss/util/propertyeditor/DocumentEditor.class
          org/jboss/util/propertyeditor/DoubleEditor.class
          org/jboss/util/propertyeditor/ElementEditor.class
          org/jboss/util/propertyeditor/FileEditor.class
          org/jboss/util/propertyeditor/FloatEditor.class
          org/jboss/util/propertyeditor/InetAddressEditor.class
          org/jboss/util/propertyeditor/IntArrayEditor.class
          org/jboss/util/propertyeditor/IntegerEditor.class
          org/jboss/util/propertyeditor/LongEditor.class
          org/jboss/util/propertyeditor/PropertiesEditor.class
          org/jboss/util/propertyeditor/PropertyEditors.class
          org/jboss/util/propertyeditor/ShortEditor.class
          org/jboss/util/propertyeditor/StringArrayEditor.class
          org/jboss/util/propertyeditor/TextPropertyEditorSupport.class
          org/jboss/util/propertyeditor/URLEditor.class
          


          We will soon be adding support for using the jbossxb framework in combination with xml namespaces such that you can write more sophisticated xml -> object parsing and ultimately a jaxb 2.0 mechanism.