VisualVM View Template - plugin detail

Template for VisualVM Extensions

NetBeans Plugin - VisualVM View Template
Plugin owner: geertjan
Added: 2008-03-13
License: CDDL
Category: NetBeans Rich Client Platform
Downloaded: 1,694 times
 0, by 0 users

Plugin Log Show log

Versions available

Download plugin   Download size: 0.01 MB   Last Update: 2008-05-30

What's new in this version

1.1: Added a drop-down JComboBox for the data sources. 1.2: Updated the generated code to VisualVM Beta 2. 1.3: Added a help topic invoked from the wizard's Help button. 1.4: Fixed package declarations so that they are generated for all data sources even though only one is used. 1.5: The code now provides for a pluggable view, so that's what the support class is for, no installer is created anymore (caused conflicts with other VisualVM templates) and the icon is changed.

Verifications for NetBeans versions

Plugin is not subject to any verification


Creates a new template in the New File wizard's "Module Development" category, for VisualVM extensions. After installing the plugin, do the following:

Register VisualVM in Tools > NetBeans Platforms. Create a new module and make sure to set VisualVM as your platform. In the New File wizard, select the VisualVM View template: Click Next. Type anything for the "Prefix", it determines the prefix of generated classes and the display name in the tab, when installed in VisualVM. Since you are creating a view for a data source, select one of the data sources from the drop-down list or type the name of your own data source. If you choose "DataSource" the view will be available for ALL data sources. Click Finish. The wizard generates three classes: A PluggableDataSourceViewProvider. A DataSourceView. A support class for plugging into the pluggable view.


The names of the three classes are prefixed with the name that you specified as the "Prefix". In addition, the necessary project dependencies are set in the module's project.xml file.

Right-click the project node, choose New | Other, and then Module Development | Module Installer. Click Finish and then you have an Installer class, registered in the Manifest file, with the correct dependencies set in the project.xml file. Open the ViewProvider class and notice that an "initialize" method and an "unregister" method are defined there; you will now call these from the Installer class: public class Installer extends ModuleInstall { @Override public void restored() { DemoViewProvider.initialize(); } @Override public void uninstalled() { DemoViewProvider.unregister(); } } Run the module and VisualVM will start up. The specified data source will have a new tab with the name that you specified as the "Prefix", in this case it is "Demo": Now look in the ViewProvider class. It should look as follows, if you selected "Application" in the wizard: public class DemoViewProvider extends PluggableDataSourceViewProvider<Application> { private static DataSourceViewProvider<Application> instance = new DemoViewProvider(); @Override public boolean supportsViewFor(Application MyApplication) { //Always shown: return true; } @Override public synchronized DataSourceView createView(final Application MyApplication) { return new DemoView(MyApplication); } static void initialize() { DataSourceViewsManager.sharedInstance().addViewProvider(instance, Application.class); } static void unregister() { DataSourceViewsManager.sharedInstance().removeViewProvider(instance); } @Override public Set getPluggableLocations(DataSourceView arg0) { return ALL_LOCATIONS; } } The code above enables the view to be extended by external modules. If you want to disable that, change the signature so that DataSourceViewProvider is extended instead (and then remove the "getPluggableLocations" method as well as the support class). From the signature, you can see that we are dealing with an Application data source. if you'd like to deal with a different data source, replace the references to "Application" with references to the data source of your choosing, such as "Host". That determines the data source for which you're creating the view. You can narrow it down further by using the "supportsViewFor" method to specify the characteristics of the instance of the data source on which you'd like to concentrate. For example, instead of ALL applications, you can provide the view for a specific main class, so that the view would be provided for one specific application only. How would the support class be used to plug into this view? See the Pluggable View sample in the VisualVM Sample Collection.

[ You have to be logged in to be able to comment. ]

User Comments

There are no comments yet.

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo