org.ow2.jonas.lib.management.extensions.base
Class JonasManagementRepr

java.lang.Object
  extended by org.ow2.jonas.lib.management.extensions.base.JonasManagementRepr

public class JonasManagementRepr
extends Object

Wrapper class allowing to apply a management operations (getAttribute, setAttribute, invoke, etc.) on the corresponding to managed server's connection. The managed server is identified by a name (serverName parameter). The corresponding connection is kept in the serverConnections table.

Author:
Adriana Danes, S. Ali Tokmen

Field Summary
protected static org.ow2.util.log.Log logger
          Logger for traces.
 
Method Summary
static Object getAttribute(ObjectName on, String attribute, String serverName)
          Gets the value of a specific attribute of a named MBean.
static Object getAttribute(ObjectName on, String attribute, String jmxUrl, String username, String password)
          Gets the value of a specific attribute of a named MBean.
static AttributeList getAttributes(ObjectName on, String[] attributes, String serverName)
          Gets the values of several attributes of a named MBean.
static Object getAttributes(ObjectName on, String[] attributes, String jmxUrl, String username, String password)
          Gets the values of several attributes of a named MBean.
static MBeanInfo getMBeanInfo(ObjectName on, String serverName)
           
static MBeanServerConnection getServerConnection(String serverName)
          Return the MBeanServer connection corresponding to a given server in the current domain.
static MBeanServerConnection getServerConnection(String jmxUrl, String username, String password)
          Return the MBeanServer connection corresponding to a given server in the current domain.
static Object invoke(ObjectName on, String operation, Object[] param, String[] signature, String serverName)
          Implementation of the invoke method to be applied to a server in the domain.
static Object invoke(ObjectName on, String operation, Object[] param, String[] signature, String jmxUrl, String username, String password)
          Implementation of the invoke method to be applied to a server in the domain.
static boolean isRegistered(ObjectName on, String serverName)
          Implementation of the isRegistered method to be applied to a server in the domain.
static boolean isRegistered(ObjectName on, String jmxUrl, String username, String password)
          Implementation of the isRegistered method to be applied to a server identified by a JMX Url.
static Set queryNames(ObjectName on, String serverName)
           
static void setAttribute(ObjectName on, String attribute, Object value, String serverName)
          Sets the value of a specific attribute of a named MBean.
static void setAttribute(ObjectName on, String attribute, Object value, String jmxUrl, String username, String password)
          Sets the value of a specific attribute of a named MBean.
static void setAttributes(ObjectName on, AttributeList attributes, String serverName)
           
static void setAttributes(ObjectName on, AttributeList attributes, String jmxUrl, String username, String password)
           
static void unregisterMBean(ObjectName on, String serverName)
          Unregisters an MBean from the managed server's MBean server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static org.ow2.util.log.Log logger
Logger for traces.

Method Detail

getServerConnection

public static MBeanServerConnection getServerConnection(String serverName)
                                                 throws ManagementException
Return the MBeanServer connection corresponding to a given server in the current domain. The connection for servers in the domain are provided by the DomainMonitor.

Parameters:
serverName - The managed server name
Returns:
The MBeanServerConnection corresponding to the managed server
Throws:
ManagementException - Couldn't get the connection

getServerConnection

public static MBeanServerConnection getServerConnection(String jmxUrl,
                                                        String username,
                                                        String password)
                                                 throws ManagementException
Return the MBeanServer connection corresponding to a given server in the current domain. The connection for servers in the domain are provided by the DomainManager.

Parameters:
jmxUrl - a server's jmx url.
username - the user name in case the jmx server is protected by user/password.
password - the password in case the jmx server is protected by user/password.
Returns:
The MBeanServerConnection corresponding to the managed server
Throws:
ManagementException - Couldn't get the connection

isRegistered

public static boolean isRegistered(ObjectName on,
                                   String jmxUrl,
                                   String username,
                                   String password)
                            throws ManagementException
Implementation of the isRegistered method to be applied to a server identified by a JMX Url.

Parameters:
on - ObjectName of the MBean we are looking for
jmxUrl - a server's jmx url.
username - the user name in case the jmx server is protected by user/password.
password - the password in case the jmx server is protected by user/password.
Returns:
True if the MBean is already registered in the server's MBean server, false otherwise or if an exception is catched.
Throws:
ManagementException - management operation failed

isRegistered

public static boolean isRegistered(ObjectName on,
                                   String serverName)
                            throws ManagementException
Implementation of the isRegistered method to be applied to a server in the domain.

Parameters:
on - ObjectName of the MBean we are looking for
serverName - The server name
Returns:
True if the MBean is already registered in the MBean server, false otherwise or if an exception is catched.
Throws:
ManagementException - management operation failed

getAttribute

public static Object getAttribute(ObjectName on,
                                  String attribute,
                                  String serverName)
                           throws ManagementException
Gets the value of a specific attribute of a named MBean.

Parameters:
on - The ObjectName of the MBean.
attribute - A String specifying the name of the attribute to be retrieved.
serverName - The server name
Returns:
The value of the attribute.
Throws:
ManagementException - management operation failed

getAttribute

public static Object getAttribute(ObjectName on,
                                  String attribute,
                                  String jmxUrl,
                                  String username,
                                  String password)
                           throws ManagementException
Gets the value of a specific attribute of a named MBean.

Parameters:
on - The ObjectName of the MBean.
attribute - A String specifying the name of the attribute to be retrieved.
jmxUrl - a server's jmx url.
username - the user name in case the jmx server is protected by user/password.
password - the password in case the jmx server is protected by user/password.
Returns:
The value of the attribute.
Throws:
ManagementException - management operation failed

getAttributes

public static AttributeList getAttributes(ObjectName on,
                                          String[] attributes,
                                          String serverName)
                                   throws ManagementException
Gets the values of several attributes of a named MBean.

Parameters:
on - The ObjectName of the MBean.
attributes - Array of attribute names to be retrieved.
serverName - The server name
Returns:
The value of the attribute.
Throws:
ManagementException - management operation failed

getAttributes

public static Object getAttributes(ObjectName on,
                                   String[] attributes,
                                   String jmxUrl,
                                   String username,
                                   String password)
                            throws ManagementException
Gets the values of several attributes of a named MBean.

Parameters:
on - The ObjectName of the MBean.
attributes - Array of attribute names to be retrieved.
jmxUrl - a server's jmx url.
username - the user name in case the jmx server is protected by user/password.
password - the password in case the jmx server is protected by user/password.
Returns:
The value of the attribute.
Throws:
ManagementException - management operation failed

setAttribute

public static void setAttribute(ObjectName on,
                                String attribute,
                                Object value,
                                String serverName)
                         throws ManagementException
Sets the value of a specific attribute of a named MBean.

Parameters:
on - The ObjectName of the MBean.
serverName - The server name
attribute - A String specifying the name of the attribute to be set.
value - The value to set to the attribute.
Throws:
ManagementException - management operation failed

setAttribute

public static void setAttribute(ObjectName on,
                                String attribute,
                                Object value,
                                String jmxUrl,
                                String username,
                                String password)
                         throws ManagementException
Sets the value of a specific attribute of a named MBean.

Parameters:
on - The ObjectName of the MBean.
attribute - A String specifying the name of the attribute to be set.
value - The value to set to the attribute.
jmxUrl - a server's jmx url.
username - the user name in case the jmx server is protected by user/password.
password - the password in case the jmx server is protected by user/password.
Throws:
ManagementException - management operation failed

setAttributes

public static void setAttributes(ObjectName on,
                                 AttributeList attributes,
                                 String serverName)
                          throws ManagementException
Parameters:
on - The ObjectName of the MBean within which the attribute is to be set.
serverName - The server name
attributes - A list of attributes: The identification of the attribute to be set and the value it is to be set to
Throws:
ManagementException - management operation failed

setAttributes

public static void setAttributes(ObjectName on,
                                 AttributeList attributes,
                                 String jmxUrl,
                                 String username,
                                 String password)
                          throws ManagementException
Parameters:
on - The ObjectName of the MBean within which the attribute is to be set.
attributes - A list of attributes: The identification of the attribute to be set and the value it is to be set to
jmxUrl - a server's jmx url.
username - the user name in case the jmx server is protected by user/password.
password - the password in case the jmx server is protected by user/password.
Throws:
ManagementException - management operation failed

invoke

public static Object invoke(ObjectName on,
                            String operation,
                            Object[] param,
                            String[] signature,
                            String serverName)
                     throws ManagementException
Implementation of the invoke method to be applied to a server in the domain.

Parameters:
on - the ObjectName of the MBean that is the target of the invoke.
operation - operation to invoke
param - invoke parameters
signature - invoke parameters signature
serverName - The server's name
Returns:
The object returned by the operation
Throws:
ManagementException - management operation failed

invoke

public static Object invoke(ObjectName on,
                            String operation,
                            Object[] param,
                            String[] signature,
                            String jmxUrl,
                            String username,
                            String password)
                     throws ManagementException
Implementation of the invoke method to be applied to a server in the domain.

Parameters:
on - the ObjectName of the MBean that is the target of the invoke.
operation - operation to invoke
param - invoke parameters
signature - invoke parameters signature
jmxUrl - a server's jmx url.
username - the user name in case the jmx server is protected by user/password.
password - the password in case the jmx server is protected by user/password.
Returns:
The object returned by the operation
Throws:
ManagementException - management operation failed

queryNames

public static Set queryNames(ObjectName on,
                             String serverName)
                      throws ManagementException
Parameters:
on - MBean name
serverName - The server name
Returns:
A set containing the ObjectNames for the MBeans selected.
Throws:
ManagementException - management operation failed

getMBeanInfo

public static MBeanInfo getMBeanInfo(ObjectName on,
                                     String serverName)
                              throws ManagementException
Parameters:
name - MBean's ObjectName
serverName - The server name
Returns:
An instance of MBeanInfo allowing the retrieval of all attributes and operations of this MBean.
Throws:
ManagementException - management operation failed

unregisterMBean

public static void unregisterMBean(ObjectName on,
                                   String serverName)
                            throws ManagementException
Unregisters an MBean from the managed server's MBean server.

Parameters:
on - The object name of the MBean.
serverName - The server name
Throws:
ManagementException - wraps exception thrown by the called management operation


Copyright © 2010 OW2 Consortium. All Rights Reserved.