3 Replies Latest reply on Jan 9, 2009 12:37 PM by Dale Smith

    Parameter names in Mbeans

    Carlos Lizarralde Newbie

      Hi, i'm using Jboss 4.0.4 and i'm writing an Mbean with several methods.
      Those methods receive some parameters.
      When i look at these parameters in JMX Console, they appear as p0, p1, etc.
      Is there any possiblity to rename them? If so, where?

      Thank you very much in advance!!!

        • 1. Re: Parameter names in Mbeans
          Nicolas PAGES Newbie

          +1 !

          I'd also like to change those names...

          (and a second little question about the same subject : how could we control the method's order in the MBean HTML page ? It's not the order of the interface, not the order of the implementation... )

          • 2. Re: Parameter names in Mbeans
            Carsten Rudat Novice

            + 1 :-)

            Hi all,

            I've read the FAQ and did not find anything about it...

            Is there a way to give "human readable" names to method-parameters for MBean in JBoss jmx-console?

            Thanks for advice.
            Carsten

            • 3. Re: Parameter names in Mbeans
              Dale Smith Newbie

              Yes there is - Spring to the rescue! Here is an example:

              In you MBean, decorate your method with annotations like this:

               @ManagedOperation(description = "Create a job")
               @ManagedOperationParameters({
               @ManagedOperationParameter(name = "accountName", description = "The name of the account to create the Job in."),
               @ManagedOperationParameter(name = "applicationName", description = "The name of the application to create the Job in."),
               @ManagedOperationParameter(name = "jobName", description = "The name of the Job to create."),
               @ManagedOperationParameter(name = "lineItems", description = "input line items for the job. Fields are comma-separated. Lines are linefeed separated")
               })
               public String createJob(String accountName, String applicationName, String jobName, String lineItems) throws Exception
              {
               // MBean code here
              }
              


              then declare MBean support in Spring like this:


               <!-- ################################################### -->
               <!-- #### #### -->
               <!-- #### MBEAN EXPORT CONTROL #### -->
               <!-- #### #### -->
               <!-- ################################################### -->
              
               <!-- the adapter to expose various Beans as MBeans. MBeans are auto-detected in the declared beans through annotations -->
               <bean id="mbeanExporter" class="org.springframework.jmx.export.MBeanExporter">
               <property name="assembler" ref="assembler"/>
               <property name="autodetectModeName" value="AUTODETECT_ASSEMBLER"/>
               <property name="namingStrategy" ref="namingStrategy"/>
               </bean>
              
               <!-- declare that Java 5 annotations will be used to derive MBean meta-data -->
               <bean id="assembler" class="org.springframework.jmx.export.assembler.MetadataMBeanInfoAssembler">
               <property name="attributeSource" ref="attributeSource"/>
               </bean>
              
               <!-- declare that Java 5 annotations will be used for MDB naming -->
               <bean id="namingStrategy" class="org.springframework.jmx.export.naming.MetadataNamingStrategy">
               <property name="attributeSource" ref="attributeSource"/>
               </bean>
              
               <!-- declare that Java 5 annotations will be used to derive MBean attributes -->
               <bean id="attributeSource" class="org.springframework.jmx.export.annotation.AnnotationJmxAttributeSource"/>
              
              


              Then declare your MBean as a managed resource:

              @ManagedResource(description = "Job Creation operations", objectName = "blah.operations:name=jobCreation")
              public class JobCreationMBean
              


              and create one in Spring:

               <!-- an MBean to expose the job creation/upload functionality -->
               <bean id="jobCreation" class="com.blah.misc.servlet.JobCreationMBean">
               <!-- bean configuration here -->
               </bean>