Over a million developers have joined DZone.

Examining the Pluggability of VisualVM Beta

DZone 's Guide to

Examining the Pluggability of VisualVM Beta

· Java Zone ·
Free Resource

The first beta release of VisualVM was announced on Friday. In an article last month, we celebrated the Milestone 3 release by introducing the Java troubleshooting, monitoring, and management features offered by VisualVM. This time, to celebrate the Beta release, we will explore VisualVM from a different angle—that of vendors wanting to integrate their own Java troubleshooting, monitoring, and management tools into VisualVM.

Integrating tools into VisualVM is done by means of the VisualVM APIs. Why would you want to integrate tools into VisualVM in the first place? Well, by bundling all of the JDK's small monitoring tools (from JConsole to JHat and about 10 others) into one comprehensive modern-looking tool with enhanced profiling features, VisualVM is positioned to be the tool of choice when it comes to covering the Java community's monitoring, management, and troubleshooting needs. On top of that, it is free and open source. Who would not want to be part of that action?

Secondly, maybe you have some special kind of application that has special monitoring, management, and troubleshooting needs. A good example is the GlassFish application server. With the beta release of VisualVM, a special VisualVM plugin for GlassFish is available. The plugin provides functionality that lets the user expand the GlassFish node in the VisualVM explorer window, exposing all the applications deployed to the GlassFish instance. Then you can see graphs and other info specific to the deployed apps. You can even drill down further and see data specific to servlets that make up the apps in question:

In other words, if your application has specific needs, such as specific artifacts that are not common to other applications, you can create a plugin specifically for that app, to provide specific features to aid the user in monitoring, managing, or troubleshooting that particular app, all in the same VisualVM where they're already doing the same kind of work with their other running applications.

But... how would you make a plugin that works with VisualVM? What are the APIs and how do they work? Here is a useful diagram, showing you the main entry points into VisualVM Beta (click to enlarge):

In short, you can create new tabs, subtabs, and menu items in VisualVM Beta. And, those entry points are themselves, at least potentially, also extendable. So, I could add a new tab that shows something or other, and then YOU could come along and add a new subtab to MY tab. I think that is pretty cool and a key element of the power of VisualVM.

Note: It is very important to realize, however, that the VisualVM APIs are still evolving. Changes will definitely happen, even incompatible ones, in the coming months. However, this is an ideal time to try out the APIs and give feedback to the API designers behind VisualVM.

Here are some very useful resources that should get you up and running very quickly:

  1. VisualVM API Quick Start. The document Getting Started Extending VisualVM should see to all your needs, in terms of setting up your development environment, understanding the API entry points, and building a simple Hello World scenario.
  2. VisualVM Javadoc. Get these from the "Beta API Docs" link on the https://visualvm.dev.java.net/ page.
  3. VisualVM Developer FAQ. A complete list of typical questions that can be asked in relation to the VisualVM APIs, together with many code samples that answer them.
  4. VisualVM Sources. If you read the VisualVM sources, you will be able to answer several of your API implementation questions. For example, you can find several pluggable views in the sources that you can learn from when creating your own pluggable views.
  5. VisualVM Plugins. When you download the VisualVM sources, you will find that you have also downloaded the sources of a set of plugins. You can inspect these plugins and learn from them. Treat them as samples. At the time of writing, the plugins bundled with the sources are as follows:

    • GlassFish. This plugin provides a new application type for the GlassFish server. A new application type node is created for each running GlassFish instance. All deployed applications are represented by subnodes, with further subnodes for each servlet in the application. Furthermore, tabs specific to each server instance, application, and servlet are also provided.
    • MBeans. This plugin provides a new tab for all applications that have JMX enabled. The information provided in the tab is exactly the same as the information provided by the MBeans tab in the JDK's JConsole application.
    • JConsole. This plugin makes VisualVM receptive to JConsole plugins, so that investment in JConsole plugins is not lost when you transfer from JConsole to VisualVM.
  6. Blog entries. As the technical writer responsible for documenting the VisualVM APIs, I've written a series of blog entries about the VisualVM APIs. Note that the Beta release of the VisualVM APIs may not compile against the sources in my blog entries, because there have been some changes. I will update the blog entries whenever I find API incompatibilities of this kind. The relevant blog entries are as follows:

Any feedback on these resources, or on the APIs themselves, can be left here or on the VisualVM mailing list.


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}