Geertjan is a DZone Zone Leader and has posted 457 posts at DZone. You can read more from them at their website. View Full User Profile

VisualVM Sample Collection 1.0

05.29.2008
| 25249 views |
  • submit to reddit

Those interested in plugging into VisualVM now have a collection of NetBeans module samples at their disposal:

http://plugins.netbeans.org/PluginPortal/faces/PluginDetailPage.jsp?pluginid=10000

Install that plugin in NetBeans IDE 6.1 and then you should find the samples below in the New Project wizard:

The samples make use of the 1.0 APIs. What do these samples provide? Soon each of them will have a full tutorial describing what you need to do to create them from scratch. But, just to show you that these are not completely trivial samples and that they, in fact, cater to some pretty complex scenarios, let's go through a few of them here.

If you choose "JVM Comparison" in the list of samples above, you'll be able to see the system properties of all the applications running on the local JVM. The system properties are shown in a new tab, specifically for "Host" data sources. Below, I double-clicked "Local" in the explorer view and then saw my new tab. There are some nice touches, such as the fact that the icon of each application, i.e., the icon shown in the explorer view below, is also shown in the new tab:

If you choose "Explorer Subnodes" from the list of samples, you will have the sources of a module that will create a new node for the Anagram Game, which is one of the samples that is bundled with NetBeans IDE. However, you need a special version of this sample, because it needs to be JMX enabled. So you need to install the JMX plugin too (available in the Plugin Portal) and then you need to run the Anagram Game sample that that plugin provides. When you do so, assuming the "Explorer Subnodes" sample is installed, you will have a special node (i.e., the icon is different, for example) for the Anagram Game, together with subnodes for the attributes retrieved from the Anagram Game's JMX bean:

If you choose the "Data Source" example, you will get a top-level node in the explorer view, as you can see below. The top-level node has "System Monitors" as its display name, together with a unique icon. When you double-click on that node, or if you right-click it and choose Open, you will get a new view, divided such that each area contains a different memory monitor. The memory monitors come from the "MemoryMonitor" sample, which is one of the samples in the JDK, and which was ported to VisualVM to make this sample possible:

Those are three of the seven samples. The others are also pretty interesting, but the three above really show the power of VisualVM and the extent to which you can enhance it with your own plugins. As stated at the start, tutorials for each of these scenarios will be provided soon. However, the VisualVM API Quick Start should give you a thorough entry point if you need some reading material to back you up while you play with these samples. Be aware that the quick start is undergoing change, though the code describing the Hello World sample should now be stable.

AttachmentSize
vvm-samples-0.png64.94 KB
vvm-samples-1.png104.08 KB
vvm-samples-2.png98.08 KB
vvm-samples-3.png59.38 KB
0
Published at DZone with permission of its author, Geertjan Wielenga.