org.objectweb.cjdbc.console.jmx
Class RmiJmxClient

java.lang.Object
  extended byorg.objectweb.cjdbc.console.jmx.RmiJmxClient

public class RmiJmxClient
extends java.lang.Object

This class defines a RmiJmxClient that uses Jmx 2.0 specifications to connect to the RmiSever

Version:
1.0
Author:
Nicolas Modrzyk

Field Summary
private  DatabaseBackendMBean backendMBean
           
private  javax.management.remote.JMXConnector connector
           
private  ControllerMBean controllerMBean
           
private  java.lang.Object credentials
           
private  DataCollectorMBean dataMBean
           
private  javax.management.NotificationListener notificationListener
           
private  java.lang.String remoteHostAddress
           
private  java.lang.String remoteHostPort
           
(package private)  javax.security.auth.Subject subject
           
private  VirtualDatabaseMBean virtualDbMBean
           
 
Constructor Summary
RmiJmxClient(java.lang.String url, java.lang.Object credentials)
          Creates a new RmiJmxClient object
RmiJmxClient(java.lang.String port, java.lang.String host, java.lang.Object credentials)
          Creates a new RmiJmxClient.java object
RmiJmxClient(java.lang.String port, java.lang.String host, java.lang.String jmxUser, java.lang.String jmxPassword)
          Creates a new RmiJmxClient.java object
 
Method Summary
 void connect(java.lang.String port, java.lang.String host, java.lang.Object credentials)
          Connect to the MBean server
 java.lang.Object getAttributeValue(javax.management.ObjectName mbean, java.lang.String attribute)
          Get the value of an attribute on the given mbean
 ControllerMBean getControllerProxy()
          Get a proxy to the ControllerMBean
 java.lang.Object getCredentials()
          Returns the credentials value.
 DatabaseBackendMBean getDatabaseBackendProxy(java.lang.String vdb, java.lang.String backend, java.lang.String user, java.lang.String password)
          Get a proxy to the DatabaseBackendMBean
 DataCollectorMBean getDataCollectorProxy()
          Get a proxy to the DataCollectorMBean
 javax.management.MBeanInfo getMBeanInfo(javax.management.ObjectName mbean)
          Get the mbean information
 javax.management.NotificationListener getNotificationListener()
          Returns the notificationListener value.
 java.lang.String getRemoteHostAddress()
          Returns the remoteHostAddress value.
 java.lang.String getRemoteHostPort()
          Returns the remoteHostPort value.
 java.lang.String getRemoteName()
          Get the controller name used for jmx connection This is [hostname]:[jmxServerPort]
private  java.lang.String[] getSignature(javax.management.MBeanOperationInfo operation)
           
 VirtualDatabaseMBean getVirtualDatabaseProxy(java.lang.String database, java.lang.String user, java.lang.String password)
          Get a reference to the virtualdatabaseMbean with the given authentication
private  void invalidateMBeans()
          Invalidate all MBeans.
 java.lang.Object invokeOperation(javax.management.ObjectName name, javax.management.MBeanOperationInfo operation, java.lang.Object[] args)
          Invoke an operation on the given object.
 boolean isSubjectSet()
          Has the subject been set?
 boolean isValidConnection()
          Test if the connection with the mbean server is still valid
 java.util.Set listCJDBCMBeans()
          List of all the mbean on the current server
 void reconnect()
          Reconnect to the same mbean server
 void setAttributeValue(javax.management.ObjectName mbean, java.lang.String attribute, java.lang.Object value)
          Change an attribute value
 void setCurrentSubject(java.lang.String user, java.lang.String password)
          Set the current subject for authentication
 void setNotificationListener(javax.management.NotificationListener notificationListener)
          Sets the notificationListener value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

connector

private javax.management.remote.JMXConnector connector

credentials

private java.lang.Object credentials

remoteHostAddress

private java.lang.String remoteHostAddress

remoteHostPort

private java.lang.String remoteHostPort

notificationListener

private javax.management.NotificationListener notificationListener

controllerMBean

private ControllerMBean controllerMBean

virtualDbMBean

private VirtualDatabaseMBean virtualDbMBean

backendMBean

private DatabaseBackendMBean backendMBean

dataMBean

private DataCollectorMBean dataMBean

subject

javax.security.auth.Subject subject
Constructor Detail

RmiJmxClient

public RmiJmxClient(java.lang.String port,
                    java.lang.String host,
                    java.lang.String jmxUser,
                    java.lang.String jmxPassword)
             throws java.io.IOException
Creates a new RmiJmxClient.java object

Parameters:
port - the port of the host to connect to
host - the host name to connect to
jmxUser - the jmxUser if one, to be authenticated with
jmxPassword - the jmxPassword if one, to be authenticated with
Throws:
java.io.IOException - if cannot connect

RmiJmxClient

public RmiJmxClient(java.lang.String url,
                    java.lang.Object credentials)
             throws java.io.IOException
Creates a new RmiJmxClient object

Parameters:
url - the jmx connector url
credentials - to use for the connection
Throws:
java.io.IOException - if connect fails

RmiJmxClient

public RmiJmxClient(java.lang.String port,
                    java.lang.String host,
                    java.lang.Object credentials)
             throws java.io.IOException
Creates a new RmiJmxClient.java object

Parameters:
port - the port of the host to connect to
host - the host name to connect to
credentials - to use for the connection
Throws:
java.io.IOException - if connect fails
Method Detail

getNotificationListener

public javax.management.NotificationListener getNotificationListener()
Returns the notificationListener value.

Returns:
Returns the notificationListener.

setNotificationListener

public void setNotificationListener(javax.management.NotificationListener notificationListener)
Sets the notificationListener value.

Parameters:
notificationListener - The notificationListener to set.

getCredentials

public java.lang.Object getCredentials()
Returns the credentials value.

Returns:
Returns the credentials.

connect

public void connect(java.lang.String port,
                    java.lang.String host,
                    java.lang.Object credentials)
             throws java.io.IOException
Connect to the MBean server

Parameters:
port - the port of the host to connect to
host - the host name to connect to
credentials - to use for the connection
Throws:
java.io.IOException - if connect fails

invalidateMBeans

private void invalidateMBeans()
Invalidate all MBeans. When connecting to a new Controller, all the local MBean instances must be invalidated (since they refered to the previous Controller and its associated MBean server).


listCJDBCMBeans

public java.util.Set listCJDBCMBeans()
                              throws java.lang.Exception
List of all the mbean on the current server

Returns:
a set of ObjectInstance
Throws:
java.lang.Exception - if fails

getMBeanInfo

public javax.management.MBeanInfo getMBeanInfo(javax.management.ObjectName mbean)
                                        throws java.lang.Exception
Get the mbean information

Parameters:
mbean - the ObjectName of the mbean to access
Returns:
MBeanInfo object
Throws:
java.lang.Exception - if fails

getAttributeValue

public java.lang.Object getAttributeValue(javax.management.ObjectName mbean,
                                          java.lang.String attribute)
                                   throws java.lang.Exception
Get the value of an attribute on the given mbean

Parameters:
mbean - the ObjectName of the mbean to access
attribute - the attribute name
Returns:
Object being the value returned by the get method
Throws:
java.lang.Exception - if fails

setAttributeValue

public void setAttributeValue(javax.management.ObjectName mbean,
                              java.lang.String attribute,
                              java.lang.Object value)
                       throws java.lang.Exception
Change an attribute value

Parameters:
mbean - the ObjectName of the mbean to access
attribute - the attribute name
value - the attribute new value
Throws:
java.lang.Exception - if fails

setCurrentSubject

public void setCurrentSubject(java.lang.String user,
                              java.lang.String password)
Set the current subject for authentication

Parameters:
user - the user login
password - the user password

isSubjectSet

public boolean isSubjectSet()
Has the subject been set?

Returns:
true if the subject is not null

invokeOperation

public java.lang.Object invokeOperation(javax.management.ObjectName name,
                                        javax.management.MBeanOperationInfo operation,
                                        java.lang.Object[] args)
                                 throws java.lang.Exception
Invoke an operation on the given object.

Parameters:
name - object name
operation - operation to invoke
args - method arguments
Returns:
result of operation invocation
Throws:
java.lang.Exception - if an error occurs

getSignature

private java.lang.String[] getSignature(javax.management.MBeanOperationInfo operation)

getVirtualDatabaseProxy

public VirtualDatabaseMBean getVirtualDatabaseProxy(java.lang.String database,
                                                    java.lang.String user,
                                                    java.lang.String password)
                                             throws javax.management.InstanceNotFoundException,
                                                    java.io.IOException,
                                                    VirtualDatabaseException
Get a reference to the virtualdatabaseMbean with the given authentication

Parameters:
database - the virtual database name
user - the user recognized as the VirtualDatabaseUser
password - the password for the VirtualDatabaseUser
Returns:
VirtualDatabaseMBean instance
Throws:
java.io.IOException - if cannot connect to MBean
javax.management.InstanceNotFoundException - if cannot locate MBean
VirtualDatabaseException - if virtual database fails

getControllerProxy

public ControllerMBean getControllerProxy()
                                   throws java.io.IOException
Get a proxy to the ControllerMBean

Returns:
ControllerMBean instance
Throws:
java.io.IOException - if cannot connect to MBean

getDataCollectorProxy

public DataCollectorMBean getDataCollectorProxy()
                                         throws java.io.IOException
Get a proxy to the DataCollectorMBean

Returns:
DataCollectorMBean instance
Throws:
java.io.IOException - if fails

getDatabaseBackendProxy

public DatabaseBackendMBean getDatabaseBackendProxy(java.lang.String vdb,
                                                    java.lang.String backend,
                                                    java.lang.String user,
                                                    java.lang.String password)
                                             throws javax.management.InstanceNotFoundException,
                                                    java.io.IOException
Get a proxy to the DatabaseBackendMBean

Parameters:
vdb - virtual database name
backend - backend name
user - user name
password - password name
Returns:
DatabaseBackendMBean instance
Throws:
java.io.IOException - if cannot connect to MBean
javax.management.InstanceNotFoundException - if cannot locate MBean

getRemoteName

public java.lang.String getRemoteName()
Get the controller name used for jmx connection This is [hostname]:[jmxServerPort]

Returns:
remoteHostName+":"+remoteHostPort

getRemoteHostAddress

public java.lang.String getRemoteHostAddress()
Returns the remoteHostAddress value.

Returns:
Returns the remoteHostAddress.

getRemoteHostPort

public java.lang.String getRemoteHostPort()
Returns the remoteHostPort value.

Returns:
Returns the remoteHostPort.

reconnect

public void reconnect()
               throws java.io.IOException
Reconnect to the same mbean server

Throws:
java.io.IOException - if reconnection failed

isValidConnection

public boolean isValidConnection()
Test if the connection with the mbean server is still valid

Returns:
true if it is


Copyright © 2002, 2005 - ObjectWeb Consortium - All Rights Reserved.