Control Plugin
Control Plugins
Available in HQ Open Source unless marked by * for HQ Enterprise only
The ControlPlugin defines control actions and implements the doAction() method used to control resources. Like the Measurement Plugin, the method of control is left entirely to the plugin. Support classes are provided to assist with certain types of control: JDBC, JMX, Script Execution and Windows Service Manager. Following are some examples of collection methods used by various plugins:
| Collection Method | Plugins that Use It |
|---|---|
| JMX | JBoss, WebLogic, WebSphere |
| JDBC | Mysql, PostgreSQL |
| Script Execution | Apache, Tomcat |
| Windows Service Manager | IIS, Apache, Tomcat |
If you have any comments or suggestions for this help page, please submit them at the bottom of the page by clicking Add Comment.
ControlPlugin.doAction Method
Control actions are defined in the Plugin XML Descriptor. Server and Service resources can include an <actions> tag that will define the control actions that resource supports. Multiple control actions can be defined by separating the actions with a comma. For example:
<actions include="start,stop,restart"/>
These actions are passed into doAction as a String argument. The plugin can then act accordingly. Each resource that supports control will have its own ControlPlugin instance. Configuration parameters defined within the Plugin XML Descriptor <config> tags can be retrieved using the ControlPlugin.getConfig method.
An example using a JBoss JMS Destination, which uses JMX for its control actions:
<!-- ObjectName properties used in the control plugins --> <property name="JMSQueue" value="jboss.mq.destination:service=Queue,name=%jms.destination%"/> ... <service name="JMS Destination"> <config> <option name="jms.destination" description="JMS Destination" default=""/> </config> <actions include="removeAllMessages"/> ... </service> ...
public class JBossJMSControlPlugin extends ControlPlugin { public void doAction(String action) throws PluginException { // ObjectName to invoke the method on String oName = getProperty("JMSQueue"); //From hq-plugin.xml try { ... // Get a reference to the MBeanServer mBeanServer.invoke(oName, action, new Object[0], new String[0]); ... } catch (Exception e) { throw new PluginException("Unable to invoke method '" + action + "'", e); } } }