This content has been marked as final.
Show 3 replies
-
1. Re: Parameter names in Mbeans
flios Apr 9, 2007 3:10 PM (in response to clizarralde)+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
carstenrudat Jan 8, 2009 5:19 AM (in response to clizarralde)+ 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
dasmith836 Jan 9, 2009 12:37 PM (in response to clizarralde)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>