|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.adventnet.services.database.DatabaseAdaptor
public class 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) javax.management.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(javax.management.MBeanServer server)
Constructor that takes MBeanServer reference. |
|
| Method Summary | |
|---|---|
void |
addRow(java.lang.Object[] indexObjects,
javax.jmx.openmbean.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. |
javax.jmx.openmbean.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. |
javax.management.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. |
javax.jmx.openmbean.CompositeData |
getEntry(java.lang.Object[] indexObjects)
This method is used to get the entry from the database. |
javax.jmx.openmbean.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. |
javax.management.MBeanInfo |
getMBeanInfo()
This method discovers the attributes and operations this MBean exposes for management. |
javax.jmx.openmbean.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,
javax.jmx.openmbean.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. |
javax.management.ObjectName |
preRegister(javax.management.MBeanServer server,
javax.management.ObjectName name)
Allows the MBean to perform any operations it needs before being registered in the MBeanServer. |
void |
setAttribute(javax.management.Attribute attribute)
Sets the value of a specific attribute of this MBean. |
javax.management.AttributeList |
setAttributes(javax.management.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 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 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 javax.management.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(javax.management.MBeanServer server)
server - the MBeanServer where the Database Adaptor will be
registered.| Method Detail |
|---|
public java.lang.Integer getState()
public javax.management.MBeanInfo getMBeanInfo()
getMBeanInfo in interface javax.management.DynamicMBean
public java.lang.Object getAttribute(java.lang.String attribute)
throws javax.management.AttributeNotFoundException,
javax.management.MBeanException,
javax.management.ReflectionException
getAttribute in interface javax.management.DynamicMBeanattribute - A String specifying the name of the
attribute to be retrieved.
javax.management.AttributeNotFoundException
javax.management.MBeanException
javax.management.ReflectionExceptionpublic javax.management.AttributeList getAttributes(java.lang.String[] attributes)
getAttributes in interface javax.management.DynamicMBeanattributes - 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 javax.management.MBeanException,
javax.management.ReflectionException
invoke in interface javax.management.DynamicMBeanactionName - 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.
javax.management.MBeanException
javax.management.ReflectionException
public void setAttribute(javax.management.Attribute attribute)
throws javax.management.AttributeNotFoundException,
javax.management.InvalidAttributeValueException,
javax.management.MBeanException,
javax.management.ReflectionException
setAttribute in interface javax.management.DynamicMBeanattribute - The identification of the attribute to
be set and the value it is to be set to.
javax.management.AttributeNotFoundException
javax.management.InvalidAttributeValueException
javax.management.MBeanException
javax.management.ReflectionExceptionpublic javax.management.AttributeList setAttributes(javax.management.AttributeList attributes)
setAttributes in interface javax.management.DynamicMBeanattributes - 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 javax.management.ObjectName preRegister(javax.management.MBeanServer server,
javax.management.ObjectName name)
throws java.lang.Exception
preRegister in interface javax.management.MBeanRegistrationserver - The MBeanServer in which the MBean will be registered.name - The object name of the MBean.
java.lang.Exception - - This exception should be caught by the
MBeanServer and re-thrown as an MBeanRegistrationException.public void postRegister(java.lang.Boolean registrationDone)
postRegister in interface javax.management.MBeanRegistrationregistrationDone - 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
preDeregister in interface javax.management.MBeanRegistrationjava.langException - This exception should be caught by the MBeanServer and
re-thrown as an MBeanRegistrationException.
java.lang.Exceptionpublic void postDeregister()
postDeregister in interface javax.management.MBeanRegistrationpublic javax.jmx.openmbean.CompositeData getFirstEntry()
public javax.jmx.openmbean.CompositeData getNextEntry(java.lang.Object[] indexObjects)
indexObjects - the object array with index objects
which identifies the row
public javax.jmx.openmbean.CompositeData getEntry(java.lang.Object[] indexObjects)
The - indexes which identifies the row as an Object Array.
public javax.jmx.openmbean.TabularData executeQueryToDB(java.lang.String query)
throws java.lang.Exception
String - The query need to execute to the database
java.lang.Exceptionpublic int totalRows()
public java.util.ArrayList getEntries(int startIndex,
int endIndex)
public void addRow(java.lang.Object[] indexObjects,
javax.jmx.openmbean.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.
java.lang.Exception
public void modifyRow(java.lang.Object[] indexObjects,
javax.jmx.openmbean.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.
java.lang.Exception
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.
java.lang.Exceptionpublic 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
java.lang.Exception
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||