|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--com.adventnet.services.database.DatabaseAdaptor
The DatabaseAdaptor Service helps to make sql queries to retrieve tables in JMX. This can be used in combination with User Storage Model. Example: DatabaseAdaptor dbservice = new DatabaseAdaptor(); dbservice.setDatabaseURL("jdbc:oracle:thin:@murali:1521:murali"); dbservice.setUserName("scott"); dbservice.setPassword("tiger"); dbservice.setTableName("Empl"); dbservice.setDriverName("oracle.jdbc.driver.OracleDriver"); dbservice.setColumnNames(new String[]{"name","dept","employeeId","age","designation", "salary","contactEmail","addr"}); dbservice.setIndexNames(new String[]{"dept","employeeId"}); dbservice.setColumnTypes(new String[]{DatabaseAdaptor.STRING,DatabaseAdaptor.STRING, DatabaseAdaptor.STRING,DatabaseAdaptor.INTEGER, DatabaseAdaptor.STRING,DatabaseAdaptor.INTEGER, DatabaseAdaptor.STRING,DatabaseAdaptor.STRING}); dbservice.setDebugLevel(agentName.debugLevel); server = agentName.getServer(); String name = server.getDefaultDomain()+":type=com.adventnet.services.database,tableName=emplTable"; try{ server.registerMBean(dbservice,new ObjectName(name)); } catch(Exception e) { e.printStackTrace(); } dbservice.startService();
| Field Summary | |
(package private) boolean |
cacheFlag
|
(package private) int |
cacheNumber
|
(package private) int |
cachingTime
|
(package private) int[] |
columnAccess
|
(package private) java.util.Hashtable |
columnMap
|
(package private) java.lang.String[] |
columnNames
|
(package private) java.lang.String[] |
columnTypes
|
(package private) java.lang.String |
databaseURL
|
(package private) int |
debugLevel
|
(package private) java.lang.String |
driverName
|
static java.lang.String |
FLOAT
Denotes Float data type for the column in the database. |
(package private) java.lang.String[] |
indexNames
|
static java.lang.String |
INTEGER
Denotes Integer data type for the column in the database. |
static java.lang.String |
LONG
Denotes Long data type for the column in the database. |
(package private) java.lang.String |
passwd
|
static int |
READ_ONLY
Specifies the access of the column as READ_ONLY |
static int |
READ_WRITE
Specifies the access of the column as READ_WRITE |
(package private) MBeanServer |
server
the MBeanServer |
static java.lang.String |
STRING
Denotes String data type for the column in the database. |
(package private) java.lang.String |
tableName
|
(package private) java.lang.String |
userName
|
| Constructor Summary | |
DatabaseAdaptor()
The NoArg constructor used to initialize the DatabaseAdaptor in forming the MBeanInfo and getting the reference of the MBeanServer using the MBeanServer.findJMXAgent(...) method. |
|
DatabaseAdaptor(MBeanServer server)
Constructor that takes MBeanServer reference. |
|
| Method Summary | |
void |
addRow(java.lang.Object[] indexObjects,
CompositeData entry)
When the manager is trying to add a row in the database table, this method can be called. |
void |
deleteRow(java.lang.Object[] indexObjects)
When the manager is trying to delete a row in the table, this method can be called. |
TabularData |
executeQueryToDB(java.lang.String query)
This method is used to get the TabularData from the database |
java.lang.Object |
getAttribute(java.lang.String attribute)
Gets the value of a specific attribute of this MBean. |
AttributeList |
getAttributes(java.lang.String[] attributes)
Enables the values of several attributes of this MBean. |
int |
getCachingNumber()
Getter for the number of rows which will be cached. |
int |
getCachingTime()
Getter for caching Time. |
int[] |
getColumnAccess()
Getter for the column access. |
java.util.Hashtable |
getColumnMap()
Getter for the column mapping. |
java.lang.String[] |
getColumnNames()
Getter for the column names of the table present in the mib. |
java.lang.String[] |
getColumnTypes()
Getter for the column types of the table present in the mib. |
java.sql.Connection |
getConnection()
This method gives the Connection instance with the Database |
java.lang.String |
getDatabaseURL()
Getter for the database URL. |
int |
getDebugLevel()
Getter for the debug level. |
java.lang.String |
getDriverName()
Getter for the JDBC driver name. |
java.util.ArrayList |
getEntries(int startIndex,
int endIndex)
This method gives an ArrayList of the CompositeData instances in this table starting from the startIndex through till the EndIndex. |
CompositeData |
getEntry(java.lang.Object[] indexObjects)
This method is used to get the entry from the database. |
CompositeData |
getFirstEntry()
To get the first entry in the table from the database. |
java.lang.String[] |
getIndexNames()
Getter for the index names of the table present in the mib. |
MBeanInfo |
getMBeanInfo()
This method discovers the attributes and operations this MBean exposes for management. |
CompositeData |
getNextEntry(java.lang.Object[] indexObjects)
To get the next entry for the given row (identified by the instance) |
java.lang.String |
getPassword()
Getter for the Password. |
java.lang.Integer |
getState()
Returns the state, whether ON_STATE (1) / OFF_STATE (0), of this service. |
java.lang.String |
getTableName()
Getter for the table name. |
java.lang.String |
getUserName()
Getter for the user name. |
java.lang.Object |
invoke(java.lang.String actionName,
java.lang.Object[] params,
java.lang.String[] signature)
Invokes an action on the original MBean associated with this MBean. |
boolean |
isCachingEnabled()
Used to see whether the table is cached or not. |
void |
modifyRow(java.lang.Object[] indexObjects,
CompositeData entry)
When the manager is trying to modify a row in the database table, this method can be called. |
void |
postDeregister()
Allows this MBean to perform any operations needed after having been de-registered in the MBeanServer. |
void |
postRegister(java.lang.Boolean registrationDone)
Allows this MBean to perform any operations needed after having been registered in the MBeanServer or after the registration has failed. |
void |
preDeregister()
Allows this MBean to perform any operations it needs before being de-registered by the MBeanServer. |
ObjectName |
preRegister(MBeanServer server,
ObjectName name)
Allows the MBean to perform any operations it needs before being registered in the MBeanServer. |
void |
setAttribute(Attribute attribute)
Sets the value of a specific attribute of this MBean. |
AttributeList |
setAttributes(AttributeList attributes)
Sets the values of several attributes of this MBean. |
void |
setCachingEnabled(boolean cacheFlag)
Used to set whether the table needs to be cached or not. |
void |
setCachingNumber(int noOfRows)
Setter for the number of rows that will be cached. |
void |
setCachingTime(int cachingTime)
Setter for Caching Time for Time in seconds to cache the Table Entries By default 60 seconds |
void |
setColumnAccess(int[] access)
Setter for the column access. |
void |
setColumnMap(java.util.Hashtable columnMap)
Setter for the column mapping. |
void |
setColumnNames(java.lang.String[] columnNames)
Setter for the column names of the table present in the mib. |
void |
setColumnTypes(java.lang.String[] columnTypes)
Setter for the column types of the table present in the mib. |
void |
setDatabaseURL(java.lang.String url)
Setter for the database URL. |
void |
setDebugLevel(int debugLevel)
Setter for the debug level. |
void |
setDriverName(java.lang.String driverName)
Setter for the driver name. |
void |
setIndexNames(java.lang.String[] indexNames)
Setter for the index names of the table present in the mib. |
void |
setPassword(java.lang.String password)
Setter for the password. |
void |
setTableName(java.lang.String tableName)
Setter for the table name. |
void |
setUserName(java.lang.String name)
Setter for the User name. |
void |
startService()
Allows the service to get started. |
void |
stopService()
Allows the service to get stopped. |
int |
totalRows()
This method gives the total number of rows in the table present in the database. |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
public static final java.lang.String INTEGER
public static final java.lang.String LONG
public static final java.lang.String STRING
public static final java.lang.String FLOAT
public static final int READ_ONLY
public static final int READ_WRITE
transient MBeanServer server
java.lang.String databaseURL
java.lang.String userName
java.lang.String passwd
java.lang.String tableName
java.lang.String driverName
java.lang.String[] columnNames
java.lang.String[] indexNames
java.lang.String[] columnTypes
int[] columnAccess
java.util.Hashtable columnMap
int debugLevel
boolean cacheFlag
int cachingTime
int cacheNumber
| Constructor Detail |
public DatabaseAdaptor()
public DatabaseAdaptor(MBeanServer server)
server - the MBeanServer where the Database Adaptor will be
registered.| Method Detail |
public java.lang.Integer getState()
public MBeanInfo getMBeanInfo()
public java.lang.Object getAttribute(java.lang.String attribute)
throws AttributeNotFoundException,
MBeanException,
ReflectionException
attribute - A String specifying the name of the
attribute to be retrieved.public AttributeList getAttributes(java.lang.String[] attributes)
attributes - A list of attributes to be retrieved.
public java.lang.Object invoke(java.lang.String actionName,
java.lang.Object[] params,
java.lang.String[] signature)
throws MBeanException,
ReflectionException
actionName - The name of the action to be invoked.params - An array containing the parameters to be
set when the action is invokedsignature - An array containing the signature of
the action. The class objects will be loaded using the
same class loader as the one used for loading the MBean
on which the action was invoked.
public void setAttribute(Attribute attribute)
throws AttributeNotFoundException,
InvalidAttributeValueException,
MBeanException,
ReflectionException
attribute - The identification of the attribute to
be set and the value it is to be set to.public AttributeList setAttributes(AttributeList attributes)
attributes - A list of attributes: The identification
of the attributes to be set and the values they are to be set to.public void startService()
public void stopService()
public ObjectName preRegister(MBeanServer server,
ObjectName name)
throws java.lang.Exception
server - The MBeanServer in which the MBean will be registered.name - The object name of the MBean.public void postRegister(java.lang.Boolean registrationDone)
registrationDone - Indicates whether or not the MBean has been successfully
registered in the MBeanServer. The value false means that either the registration phase
has failed.registrationDone - indicates whether the mbean is registered properly
with the server.
public void preDeregister()
throws java.lang.Exception
public void postDeregister()
public CompositeData getFirstEntry()
public CompositeData getNextEntry(java.lang.Object[] indexObjects)
indexObjects - the object array with index objects
which identifies the rowpublic CompositeData getEntry(java.lang.Object[] indexObjects)
The - indexes which identifies the row as an Object Array.
public TabularData executeQueryToDB(java.lang.String query)
throws java.lang.Exception
String - The query need to execute to the databasepublic int totalRows()
public java.util.ArrayList getEntries(int startIndex,
int endIndex)
public void addRow(java.lang.Object[] indexObjects,
CompositeData entry)
throws java.lang.Exception
indexObjects - the object array with index objects
which identifies the row to be added.entry - the entry value as javax.jmx.openmbean.CompositeData instance.
public void modifyRow(java.lang.Object[] indexObjects,
CompositeData entry)
throws java.lang.Exception
indexObjects - the object array with index objects
which identifies the row to be modified.entry - the entry value as javax.jmx.openmbean.CompositeData instance.
public void deleteRow(java.lang.Object[] indexObjects)
throws java.lang.Exception
indexObjects - the object array with index objects
which identifies the row to be deleted.entry - the entry value as javax.jmx.openmbean.CompositeData instance.public java.lang.String getDatabaseURL()
public void setDatabaseURL(java.lang.String url)
The - Database URL of the connection.public java.lang.String getUserName()
public void setUserName(java.lang.String name)
The - User name of the connection.public java.lang.String getPassword()
public void setPassword(java.lang.String password)
The - Password of the connection.public java.lang.String getTableName()
public void setTableName(java.lang.String tableName)
The - Table Name in the database which should be queried.public java.lang.String getDriverName()
public void setDriverName(java.lang.String driverName)
The - Driver name of the connection.public java.lang.String[] getColumnNames()
public void setColumnNames(java.lang.String[] columnNames)
The - column names as a String array.public java.lang.String[] getIndexNames()
public void setIndexNames(java.lang.String[] indexNames)
The - index names as a String array.public java.lang.String[] getColumnTypes()
public void setColumnTypes(java.lang.String[] columnTypes)
The - column types as a String array.public int[] getColumnAccess()
public void setColumnAccess(int[] access)
The - access for the columns as an int[].public java.util.Hashtable getColumnMap()
public void setColumnMap(java.util.Hashtable columnMap)
The - column mapping as a Hashtable.public int getDebugLevel()
public void setDebugLevel(int debugLevel)
The - debug level as an int.
1 - FATAL , 2 - CRITICAL , 3 - NON-CRITICALpublic boolean isCachingEnabled()
public void setCachingEnabled(boolean cacheFlag)
cacheFlag - true to specify caching
false to specify no caching.public int getCachingTime()
public void setCachingTime(int cachingTime)
cachingTime - The caching Time in seconds.public int getCachingNumber()
public void setCachingNumber(int noOfRows)
noOfRows - The number of rows that will be cached.
public java.sql.Connection getConnection()
throws java.lang.Exception
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||