[jboss-user] [Management, JMX/JBoss] - Re: Parameter names in Mbeans
dasmith836
do-not-reply at jboss.com
Fri Jan 9 12:37:47 EST 2009
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>
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4200665#4200665
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4200665
More information about the jboss-user
mailing list