Wednesday January 30, 2008
JTop on the NetBeans Platform
Charlie Hunt, one of Sun's performance gurus, is in town (where "town" equals "Prague, Czech Republic") and we've been studying the JDK's JTop plugin for JConsole, with a view to porting it to a NetBeans module. Let me tell you, it was not easy to figure out, at least initially. JTop consists of a class that extends JConsolePlugin, which integrates with JConsole, as well as a JPanel, which provided the actual user interface. We ended up dumping the JConsolePlugin class completely. There was nothing we needed from it.
Then we moved most of the content from the sample's other class, i.e, the JPanel, into a TopComponent, which integrates with the NetBeans Platform. We initially simply wanted to call the JPanel from the TopComponent and then add it to the TopComponent. I think that probably failed because the JPanel might have been getting instantiated (at least) twice. So we moved everything into the TopComponent, ran the NetBeans Platform, and there it was:
We also installed it into the Visual VM:
...and into NetBeans IDE:
In the latter case, we encountered a lot of problems because, as we eventually discovered, the Visual Web Pack has a security manager that conflicts with the security manager set in the tools.jar, which is where the JConsole API is located. We tried in vain to set security policies in various places before we discovered the culprit and then simply excluded the Visual Web Pack from the IDE. Then the JTop plugin worked without a problem.
And, because the original JTop plugin uses the cool new JDK6 SwingWorker class, the TopComponent is updated automatically in the background and the thread information is continuously current. Hurray!
Jan 30 2008, 02:01:39 PM PST Permalink


