- java.lang.Object
-
- com.sun.tools.jconsole.JConsolePlugin
-
public abstract class JConsolePlugin extends Object
A JConsole plugin class. JConsole uses theservice providermechanism to search the JConsole plugins. Users can provide their JConsole plugins in a jar file containing a file namedMETA-INF/services/com.sun.tools.jconsole.JConsolePlugin
This file contains one line for each plugin, for example,
com.sun.example.JTop
which is the fully qualified class name of the class implementing
JConsolePlugin.To load the JConsole plugins in JConsole, run:
jconsole -pluginpath <plugin-path>
where
<plugin-path>specifies the paths of JConsole plugins to look up which can be a directory or a jar file. Multiple paths are separated by the path separator character of the platform.When a new JConsole window is created for a connection, an instance of each
JConsolePluginwill be created. TheJConsoleContextobject is not available at its construction time. JConsole will set theJConsoleContextobject for a plugin after the plugin object is created. It will then call itsgetTabsmethod and add the returned tabs to the JConsole window.- Since:
- 1.6
- See Also:
ServiceLoader
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedJConsolePlugin()Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddContextPropertyChangeListener(PropertyChangeListener listener)Adds aPropertyChangeListenerto theJConsoleContextobject for this plugin.voiddispose()Dispose this plugin.JConsoleContextgetContext()Returns theJConsoleContextobject representing the connection to an application.abstract Map<String,JPanel>getTabs()Returns the tabs to be added in JConsole window.abstract SwingWorker<?,?>newSwingWorker()Returns aSwingWorkerto perform the GUI update for this plugin at the same interval as JConsole updates the GUI.voidremoveContextPropertyChangeListener(PropertyChangeListener listener)Removes aPropertyChangeListenerfrom the listener list of theJConsoleContextobject for this plugin.voidsetContext(JConsoleContext context)Sets theJConsoleContextobject representing the connection to an application.
-
-
-
Method Detail
-
setContext
public final void setContext(JConsoleContext context)
Sets theJConsoleContextobject representing the connection to an application. This method will be called only once after the plugin is created and before thegetTabs()is called. The givencontextcan be in anyconnection statewhen this method is called.- Parameters:
context- aJConsoleContextobject
-
getContext
public final JConsoleContext getContext()
Returns theJConsoleContextobject representing the connection to an application. This method may returnnullif it is called before thecontextis initialized.- Returns:
- the
JConsoleContextobject representing the connection to an application.
-
getTabs
public abstract Map<String,JPanel> getTabs()
Returns the tabs to be added in JConsole window.The returned map contains one entry for each tab to be added in the tabbed pane in a JConsole window with the tab name as the key and the
JPanelobject as the value. This method returns an empty map if no tab is added by this plugin. This method will be called from the Event Dispatch Thread once at the new connection time.- Returns:
- a map of a tab name and a
JPanelobject representing the tabs to be added in the JConsole window; or an empty map.
-
newSwingWorker
public abstract SwingWorker<?,?> newSwingWorker()
Returns aSwingWorkerto perform the GUI update for this plugin at the same interval as JConsole updates the GUI.JConsole schedules the GUI update at an interval specified for a connection. This method will be called at every update to obtain a
SwingWorkerfor each plugin.JConsole will invoke the
execute()method to schedule the returnedSwingWorkerfor execution if:- the
SwingWorkerobject has not been executed (i.e. theSwingWorker.getState()method returnsPENDINGstate); and - the
SwingWorkerobject returned in the previous update has completed the task if it was notnull(i.e. theSwingWorker.isDonemethod returnstrue).
Otherwise,SwingWorkerobject will not be scheduled to work.A plugin can schedule its own GUI update and this method will return
null.- Returns:
- a
SwingWorkerto perform the GUI update; ornull.
- the
-
dispose
public void dispose()
Dispose this plugin. This method is called by JConsole to inform that this plugin will be discarded and that it should free any resources that it has allocated. TheJConsoleContextcan be in anyconnection statewhen this method is called.
-
addContextPropertyChangeListener
public final void addContextPropertyChangeListener(PropertyChangeListener listener)
Adds aPropertyChangeListenerto theJConsoleContextobject for this plugin. This method is a convenient method for this plugin to register a listener when theJConsoleContextobject may or may not be available.For example, a plugin constructor can call this method to register a listener to listen to the
connectionStateproperty changes and the listener will be added to theJConsoleContextobject when it is available.- Parameters:
listener- ThePropertyChangeListenerto be added- Throws:
NullPointerException- iflistenerisnull.
-
removeContextPropertyChangeListener
public final void removeContextPropertyChangeListener(PropertyChangeListener listener)
Removes aPropertyChangeListenerfrom the listener list of theJConsoleContextobject for this plugin. Iflistenerwas never added, no exception is thrown and no action is taken.- Parameters:
listener- thePropertyChangeListenerto be removed- Throws:
NullPointerException- iflistenerisnull.
-
-