站内搜索: 请输入搜索关键词

当前页面: 开发资料首页Netbeans 专题Getting Started with JMX Monitoring in NetBeans IDE 5.0

Getting Started with JMX Monitoring in NetBeans IDE 5.0

摘要: The NetBeans JMX Module integrates JMX technology right into your workflow in the NetBeans IDE. This module allows you to quickly develop management applications, add management to exisiting applications, develop manager applications, and monitor the state of the Virtual Machine. The module is available for NetBeans IDE version 4.0 and higher. You can install the module by choosing Tools > Update Center and downloading the module from the NetBeans Update Center.

The NetBeans JMX Module integrates JMX technology right into your workflow in the NetBeans IDE. This module allows you to quickly develop management applications, add management to exisiting applications, develop manager applications, and monitor the state of the Virtual Machine. The module is available for NetBeans IDE version 4.0 and higher. You can install the module by choosing Tools > Update Center and downloading the module from the NetBeans Update Center.

This getting started guide presents the features of the module:

Accessing the Wizards


You can access the wizards by choosing File > New File (Ctrl-N) and selecting one of the following templates from the Management category:
List of Wizards

Updating MBeans and Adding MBeans to a JMX Agent

To update an MBean, select the MBean class in the Projects tree then access the Management contextual menu by right-clicking on the node or via the top level management menu.

To add an MBean to a previously generated JMX Agent, select the Agent class in the Projects tree then access the Management contextual menu  by right-clicking on node or via the top level management menu.

Management menu


Implementing and Executing Manageable Applications


Typically, the work flow of implementing and executing manageable applications is as follows:
  1. Generate your MBeans.
  2. Instrument your MBeans
  3. Instrument your unit test logic.
  4. Generate a JMX Agent (which is either runnable or not). Runnable agents are used to develop management agents. Non-runnable agents are embedded in a runnable application (see the sample application for an example of an embedded agent).
  5. Run and/or debug the project with JConsole using the new project utilities located in the toolbar.

Run/Debug with JConsole icons in the toolbar

For advanced users: If you want to test your application with remote management enabled, you can use the remote management utilities (located in Run > Remote Management menu). Use the Management Properties File wizard and the generated file when launching the action.

Launching JConsole from NetBeans


This is really easy. Just click this nice icon: Launch JConsole icon

Running the Sample Application


The JMX module includes a sample application with JMX monitoring built into it.  
  1. Choose File > New Project.
  2. In Samples, select the Management category.
  3. Select Anagram Game Managed with JMX project.
  4. Anagram Game Managed with JMX - click for fullsize

     

  5. Once your project is created, Run it with JConsole. The Anagram game is displayed, as well as the JConsole window.
  6. Run your project - click for fullsize

  7. In the JConsole window, go to the MBeans tab:
    1. Select the AnagramsStats MBean.
    2. Select the Notifications tab.
    3. Subscribe to notifications.
    4. Select the Attributes tab.
    5. Double click on the LastThinkingTime attribute value to plot it.
  8. In the Anagrams window, solve the first anagram. Notice that the attributes are updated and that the JConsole window received a notification.
  9. Anagram window

    JConsole - click for fullsize

What Next?

This document has provided a quick introduction to the JMX module for the NetBeans IDE.  You can get more information about the JMX module by completing the JMX Module Tutorial.

↑返回目录
前一篇: Generating Primary Key Values in CMP Beans
后一篇: Getting Started with NetBeans and Java