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

java.lang.Object
  extended by org.ow2.jonas.lib.management.extensions.base.BaseManagement
All Implemented Interfaces:
IBaseManagement
Direct Known Subclasses:
ClusterdaemonManagement, ClusterManagement, DomainManagement, ServerManagement, ServerMonitoring

public class BaseManagement
extends Object
implements IBaseManagement

Base class for JOnAS management. This class is extended by classes specialized for specific management aspects.

Author:
Adriana.Danes@bull.net, Oualaa Hani

Field Summary
protected static org.ow2.util.log.Log logger
          create logger
protected static Object s_Synchro
          Object used for synchronization.
 
Constructor Summary
BaseManagement()
          Base constructor.
 
Method Summary
protected  void addRealmItem(ArrayList p_Realms, String p_Type, String p_SecurityRealmUsed, String domainName, String serverName)
          Add RealmItem in the list.
 Object getAttribute(ObjectName on, String attribute, String serverName)
          Gets the value of a specific attribute of a named MBean.
 J2EEMBeanAttributeInfo[] getAttributes(ObjectName objectName, String serverName)
          Get management attributes.
 String getDomainName()
           
static IBaseManagement getInstance()
          Get singleton instance of base management.
 int getIntegerAttribute(ObjectName objectName, String attrName)
          Get the integer attribute value of an MBean in the current MBean Server.
 String getKeyValue(String objectName, String keyName)
          Return the value of a key property in an OBJECT_NAME.
 String[] getKeyValues(String[] objectNames, String keyName)
          Return the values of a key property in String OBJECT_NAMEs.
 List getListMbean(ObjectName p_On, String serverName)
          Return the list of ObjectName Mbean gotten by the query in the current MbeanServer.
 List<RealmItem> getRealmItems(String realmType, String sSecurityRealmUsed)
          Get realm items of the given type within the current server of the current domain.
 List<RealmItem> getRealmItems(String realmType, String sSecurityRealmUsed, String domainName, String serverName)
          Get realm items of the given type.
 MBeanServerConnection getServerConnection()
          Return the MBeanServer connection corresponding to a current server in the current domain.
 MBeanServerConnection getServerConnection(String serverName)
          Return the MBeanServer connection corresponding to a given server in the current domain.
 String getServerName()
           
 String getStringAttribute(ObjectName objectName, String attrName)
          Get the String attribute value of an MBean in the current MBean Server.
 ObjectName getTomcatRealm(String domainName, String serverName)
          Get the ObjectName of the Tomcat Realm MBean.
 List<RealmItem> getTomcatRealmItems(String usedSecurityRealm, String domainName, String serverName)
           
 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.
 boolean isRegistered(ObjectName on, String serverName)
          Implementation of the isRegistered method to be applied to a server in the domain.
 void setAttribute(ObjectName on, String attribute, Object value)
          Sets the value of a specific attribute of a named MBean within the current server.
 void setAttribute(ObjectName on, String attribute, Object value, String serverName)
          Sets the value of a specific attribute of a named MBean.
 
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
create logger


s_Synchro

protected static Object s_Synchro
Object used for synchronization.

Constructor Detail

BaseManagement

public BaseManagement()
Base constructor.

Method Detail

getInstance

public static IBaseManagement getInstance()
Get singleton instance of base management.

Returns:

getServerName

public String getServerName()
Specified by:
getServerName in interface IBaseManagement
Returns:
The current server name.

getDomainName

public String getDomainName()
Specified by:
getDomainName in interface IBaseManagement
Returns:
The current domain name.

getStringAttribute

public String getStringAttribute(ObjectName objectName,
                                 String attrName)
                          throws ManagementException
Get the String attribute value of an MBean in the current MBean Server.

Specified by:
getStringAttribute in interface IBaseManagement
Parameters:
objectName - The MBean's ObjectName
attrName - The attribute name
Returns:
The value of the attribute
Throws:
ManagementException

getIntegerAttribute

public int getIntegerAttribute(ObjectName objectName,
                               String attrName)
                        throws ManagementException
Get the integer attribute value of an MBean in the current MBean Server.

Specified by:
getIntegerAttribute in interface IBaseManagement
Parameters:
objectName - The MBean's ObjectName
attrName - The attribute name
Returns:
The value of the attribute
Throws:
ManagementException

getKeyValue

public String getKeyValue(String objectName,
                          String keyName)
                   throws ManagementException
Return the value of a key property in an OBJECT_NAME.

Specified by:
getKeyValue in interface IBaseManagement
Parameters:
objectName - the OBJECT_NAME (String form)
keyName - key property name
Returns:
key value
Throws:
ManagementException

getKeyValues

public String[] getKeyValues(String[] objectNames,
                             String keyName)
                      throws ManagementException
Return the values of a key property in String OBJECT_NAMEs.

Specified by:
getKeyValues in interface IBaseManagement
Parameters:
objectNames - the OBJECT_NAMEs
keyName - key name
Returns:
array of key values
Throws:
ManagementException

getAttributes

public J2EEMBeanAttributeInfo[] getAttributes(ObjectName objectName,
                                              String serverName)
                                       throws ManagementException
Get management attributes.

Specified by:
getAttributes in interface IBaseManagement
Parameters:
objectName - the ObjectName
serverName - server name.
Returns:
attributes for the given objectName.
Throws:
ManagementException - management operation failed

getAttribute

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

Specified by:
getAttribute in interface IBaseManagement
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

isRegistered

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

Specified by:
isRegistered in interface IBaseManagement
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

invoke

public 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.

Specified by:
invoke in interface IBaseManagement
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

getListMbean

public List getListMbean(ObjectName p_On,
                         String serverName)
                  throws ManagementException
Return the list of ObjectName Mbean gotten by the query in the current MbeanServer.

Specified by:
getListMbean in interface IBaseManagement
Parameters:
p_On - Query Mbeans to search
Returns:
The list of ObjectName
Throws:
ManagementException

getServerConnection

public 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.

Specified by:
getServerConnection in interface IBaseManagement
Parameters:
serverName - The managed server name
Returns:
The MBeanServerConnection corresponding to the managed server
Throws:
ManagementException - Couldn't get the connection

getServerConnection

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

Specified by:
getServerConnection in interface IBaseManagement
Returns:
The MBeanServerConnection corresponding to the managed server
Throws:
ManagementException - Couldn't get the connection

setAttribute

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

Specified by:
setAttribute in interface IBaseManagement
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 void setAttribute(ObjectName on,
                         String attribute,
                         Object value)
                  throws ManagementException
Sets the value of a specific attribute of a named MBean within the current server.

Specified by:
setAttribute in interface IBaseManagement
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.
Throws:
ManagementException - management operation failed

getRealmItems

public List<RealmItem> getRealmItems(String realmType,
                                     String sSecurityRealmUsed,
                                     String domainName,
                                     String serverName)
                              throws ManagementException
Get realm items of the given type.

Specified by:
getRealmItems in interface IBaseManagement
Parameters:
realmType - realm type.
sSecurityRealmUsed - the used security realm.
domainName -
serverName - server's name
Returns:
real items of the given type
Throws:
ManagementException - any.

getRealmItems

public List<RealmItem> getRealmItems(String realmType,
                                     String sSecurityRealmUsed)
                              throws ManagementException
Get realm items of the given type within the current server of the current domain.

Specified by:
getRealmItems in interface IBaseManagement
Parameters:
realmType - realm type.
sSecurityRealmUsed - the used security realm.
Returns:
realm items of the given type
Throws:
ManagementException - any.

getTomcatRealmItems

public List<RealmItem> getTomcatRealmItems(String usedSecurityRealm,
                                           String domainName,
                                           String serverName)
                                    throws ManagementException
Specified by:
getTomcatRealmItems in interface IBaseManagement
Throws:
ManagementException

getTomcatRealm

public ObjectName getTomcatRealm(String domainName,
                                 String serverName)
                          throws ManagementException
Description copied from interface: IBaseManagement
Get the ObjectName of the Tomcat Realm MBean.

Specified by:
getTomcatRealm in interface IBaseManagement
Parameters:
domainName - the domain's name
serverName - the server's name
Returns:
ObjectName of the Tomcat Realm MBean.
Throws:
ManagementException

addRealmItem

protected void addRealmItem(ArrayList p_Realms,
                            String p_Type,
                            String p_SecurityRealmUsed,
                            String domainName,
                            String serverName)
                     throws Exception
Add RealmItem in the list.

Parameters:
p_Realms - List to add found items
p_Type - Type item to add (memory or datasource or ldap)
p_SecurityRealmUsed - Name of realm used by the security service or null if nothing used
Throws:
Exception


Copyright © 2010 OW2 Consortium. All Rights Reserved.