Connector
From jManage[edit] OverviewA connector is a collection of external MBeans that monitor or manage a particular application or device. jManage provides a framework which allows easy integration of external MBeans into the jManage platform. By leveraging the Apache commons modeler, custom MBeans can be easily developed to expand jManage to support non-JMX applications. For demonstration purpose, out of box jManage comes with a simple connector for monitoring Oracle 9i database. The connector is deployed in <jManage-install-dir>/build/connector/jmanage-oracle.jar It contains the following MBeans: ConnectorManager - a global configuration manager which provides the database settings Database - an MBean which provides monitoring metric at database level Session - an MBean which provides monitoring metric at session level SQLQuery - an MBean which provides monitoring data related to SQL statements, such as top 10 most used SQL statements. Performance - an MBean which provides performance related metrics. Note: The out-of-box connector requires a proper JDBC driver which is not included in the distribution. You need to copy your version of the JDBC driver to the <jmanage-install-dir>/build/lib folder.
[edit] Connector DevelopmentCreate connector.xml The connector.xml file defines the global configuration parameters which are displayed in the jManage "Add Connector" user interface (Application --> Add Connector). The jManage oracle connector has the following settings: <connector-config-setting name="jManage Oracle Connector">
<fields>
<field name="Username" defaultValue="sys" />
<field name="Password" />
<field name="URL" defaultValue="jdbc:oracle:thin:@localhost:1521:sid" />
<field name="Driver" defaultValue="oracle.jdbc.driver.OracleDriver" />
<field name="DBA" defaultValue="Yes" />
</fields>
</connector-config-setting>
connector-config-setting/name - the connector name to be shown in the connector dropdown list connector-config-setting/fields/field - each field element corresponds to a configuration parameter to be shown in the user interface. connector-config-setting/fields/field/name - the name of the parameter. connector-config-setting/fields/field/name - the default value of the parameter.
jManage uses Apache commons modeler to help construct MBeans. For details description refer to the commons modeler website [1]. In commons modeler an xml file, named MBeans-descriptors.xml, is used to configure the metadata for MBeans, such as implementation class, attribues and opertions. The following shows an example from the jManage oracle ConnectorManager
<mbean name="ConnectionManager"
domain="oracle-connector"
description="Oracle Connector MBean - ConnectionManager"
type="org.jmanage.connector.plugin.oracle.ConnectionManager">
<attribute name="logonUser"
description="Current Logon User Name"
type="java.lang.String"
writeable="false"/>
<attribute name="DBA"
description="Logon as sysdba user"
type="boolean"
is="true"
writeable="false"/>
<attribute name="url"
description="Connection URL"
type="java.lang.String"
writeable="false"/>
..............
..............
<operation name="openConnection"
description="Connect to the database"
impact="ACTION"
returnType="java.lang.String">
</operation>
..............
</mbean>
mbean/domain - specifies the domain of the mbeans for the connector. mbean/type - specifies the java implementation class. mbean/attribute/name - specifies the name of the attribute. The java class should have a corresponding property (getter and/or setter) for this attribute. mbean/attribute/type - specifies the java type of the attribute. mbean/attribute/writeable - specifies whether the attribute is mutable. mbean/attribute/is - specifies whether the attribute is boolean type. mbean/operation/name - specifies the name of the operation. mbean/operation/returnType - specifies the java return type of the operation. For more details see [2]
The following excerpt shows the key implementation of ConnectorManager
public class ConnectionManager extends ConnectorSupport {
private String driver;
private String logonUser;
private String password;
private String url;
private boolean dba = false;
public String openConnection() {
...........
}
public boolean isDBA() {
return dba;
}
public String getDriver() {
return driver;
}
public String getLogonUser() {
return logonUser;
}
public String getPassword() {
return password;
}
public String getUrl() {
return url;
}
public boolean isConnected() {
return conn == null ? false : true;
}
// this overrides the super class method
public void initialize(Map configParams) {
driver = (String) configParams.get("Driver");
logonUser = (String) configParams.get("Username");
password = (String) configParams.get("Password");
url = (String) configParams.get("URL");
String dba = (String) configParams.get("DBA");
if (dba.equalsIgnoreCase("yes") || dba.equalsIgnoreCase("y")) {
this.dba = true;
}
}
Notes: - The implementation should extend the org.jmanage.connector.framework.ConnectorSupport class - Overrides the initialize method to get the configuration parameter settings - Typically there should be a global configuration MBean like the ConnectorManager to provide the global settings to other MBeans - Frequent refereneced MBean can be implemented using the singleton design pattern to avoid constantly object lookup. The class need to provide the getInstance method and the framework would recoginize this method and use it to create the MBean.
The connector.xml should be placed in the top level of the connector jar file, where the mbeans-descriptors.xml should be placed in the META-INF folder. META-INF/mbeans-descriptors.xml connector.xml class-package
Once the connector is packaged, it should be placed in the following folder: <jmanage-install-dir>/build/connector/<your-connector-jar> Re-start jManage and the newly-deployed connector should show up in the connector dropdown list.
Any dependent jars, such as the jdbc driver for the oracle connector, should be placed in the lib folder <jmanage-install-dir>/build/lib
The line below shows the ConnectionManager MBean object name connectorType=jmanage-oracle.jar,name=ConnectionManager - connectorType - the jar file name of the connector - name - the MBean name specified in the mbeans-descriptors.xml file |
