org.objectweb.jonas.webapp.jonasadmin
Class JonasAdminJmx

java.lang.Object
  extended by org.objectweb.jonas.webapp.jonasadmin.JonasAdminJmx

public class JonasAdminJmx
extends java.lang.Object

Helper class supporting manipulation of MBeans (accessing MBeans).

Author:
Michel-Ange ANTON

Contributors: Adriana Danes


Constructor Summary
protected JonasAdminJmx()
          Protected constructor to prevent instantiation.
 
Method Summary
static java.lang.String extractFilename(java.lang.String p_Path)
          Extract the filename of complete path.
static java.lang.String extractValueMbeanName(java.lang.String pName, java.lang.String pMBeanName)
          Extract the value of a key property from the MBean name.
static java.lang.String findSecurityFactorySubType(java.lang.String p_NameFactory, java.lang.String serverName)
          Return the SubType of a Security Factory in the current server.
static javax.management.ObjectName getArchiveConfigObjectName(java.lang.String serverName)
           
static java.util.ArrayList getConnectionFactoriesList(org.apache.struts.util.MessageResources p_Resources, java.lang.String serverName)
          Return the default Connection Factories.
static java.util.ArrayList getDatasourceDependences(java.lang.String pDatasourceName, java.lang.String domainName, java.lang.String serverName)
          Return the list of Datasource dependences for a given datasource name in the current server.
static java.util.ArrayList getDatasourceFilesDeployable(java.lang.String serverName)
          Return the list of Datasource properties files ready to deploy in the current server.
static java.util.ArrayList getDatasourceFilesDeployed(java.lang.String domainName, java.lang.String serverName)
          Return the list of deployed Datasources in the current server.
static java.util.ArrayList getEarFilesDeployable(java.lang.String serverName)
          Return the list of EAR filename ready to deploy in the current server.
static java.util.ArrayList getEarFilesDeployed(java.lang.String serverName)
          Return the list of deployed EAR filename in the current server.
static java.util.ArrayList[] getFamiliesMbeansLists(java.lang.String serverName)
          Create a list for each family of Mbean.
static javax.management.ObjectName getFirstMbean(javax.management.ObjectName p_On, java.lang.String serverName)
          Return the first ObjectName Mbean gotten by the query in the current MbeanServer.
static java.lang.String getFirstMBeanName(javax.management.ObjectName p_On, java.lang.String serverName)
          Return the first Mbean name gotten by the query in the current MbeanServer.
static java.util.ArrayList getGroups(java.lang.String p_Resource, java.lang.String serverName)
          Return the list of all groups in a resource.
static javax.management.ObjectName getJ2eeDomainObjectName(java.lang.String serverName)
          Return the ObjectName corresponding to the J2EEDomain managed object registered in the current MBeanServer.
static javax.management.ObjectName getJ2eeServerObjectName(java.lang.String serverName)
          Return the ObjectName corresponding to the J2EEServer managed object registered in the current MBeanServer.
static javax.management.ObjectName getJ2eeServerObjectName(java.lang.String p_DomainName, java.lang.String serverName)
          Return the ObjectName corresponding to the J2EEServer managed object registered in the current MBeanServer and belonging to a domain.
static java.util.ArrayList getJarFilesDeployable(java.lang.String serverName)
          Return the list of JAR filename ready to deploy in the current server.
static java.util.ArrayList getJarFilesDeployed(java.lang.String serverName)
          Return the list of deployed JAR filename in the current server.
static java.util.List getListMbean(javax.management.ObjectName p_On, java.lang.String serverName)
          Return the list of ObjectName Mbean gotten by the query in the current MbeanServer.
static java.util.List getListMBeanName(javax.management.ObjectName p_On, java.lang.String serverName)
          Return the list of Mbean name gotten by the query in the current MbeanServer.
static java.util.ArrayList getLoggers(org.apache.struts.util.MessageResources p_Resources, WhereAreYou p_WhereAreYou, boolean p_Action)
          Return the list of all used loggers in this JOnAS server.
static java.util.ArrayList getMailFactoryDependences(java.lang.String p_MailFactoryName, WhereAreYou p_WhereAreYou)
          Return the list of Mail factory dependences in the current server for a given factory name.
static java.util.ArrayList getMailFilesDeployable(java.lang.String serverName)
          Return the list of Mail factory files ready to deploy in the current server.
static java.util.ArrayList getMailFilesDeployed(WhereAreYou p_WhereAreYou)
          Return the list of deployed Mail factories in the current server.
static java.util.ArrayList getMbeansLists(java.lang.String serverName)
          Create a list for each family of Mbean.
static java.util.ArrayList getMimeMailPartFactoriesDeployed(WhereAreYou p_WhereAreYou)
          Return the list of deployed MimePartDatasource Mail Factories in the current server.
static java.util.ArrayList getMimePartMailFilesDeployable(java.lang.String serverName)
          Return the list of MimePartDataSource Mail factory files ready to deploy in the current server.
static java.util.ArrayList getMimePartMailFilesDeployed(WhereAreYou p_WhereAreYou)
          Return the list of deployed MimePartDataSource Mail factories in the current server.
static java.util.ArrayList getQueuesList(java.lang.String serverName)
          Return the Queue destinations list.
static javax.management.ObjectName getRarConfigObjectName(java.lang.String serverName)
           
static java.util.ArrayList getRarFilesDeployable(java.lang.String serverName)
          Return the list of RAR filename ready to deploy in the current server.
static java.util.ArrayList getRarFilesDeployed(java.lang.String serverName)
          Return the list of deployed RAR filename in the current server.
static java.util.ArrayList getRegistryList(java.lang.String serverName)
          Return a list of names bounded in the registry.
static java.util.ArrayList getRoles(java.lang.String p_Resource, java.lang.String serverName)
          Return the list of all roles in a resource.
static java.util.ArrayList getSecurityDatasourceFactories(java.lang.String serverName)
          Return the list of Security Datasource Factories in the current server.
static java.util.ArrayList getSecurityLdapFactories(java.lang.String serverName)
          Return the list of Security Ldap Factories in the current server.
static java.util.ArrayList getSecurityMemoryFactories(java.lang.String serverName)
          Return the list of Security Memory Factories in the current server.
static java.util.ArrayList getSessionMailFactoriesDeployed(WhereAreYou p_WhereAreYou)
          Return the list of deployed Session Mail Factories in the current server.
static java.util.ArrayList getSessionMailFilesDeployable(java.lang.String serverName)
          Return the list of Session Mail factory files ready to deploy in the current server.
static java.util.ArrayList getSessionMailFilesDeployed(WhereAreYou p_WhereAreYou)
          Return the list of deployed Session Mail factories in the current server.
static java.util.ArrayList getTopicsList(java.lang.String serverName)
          Return the Topic destinations list.
static java.util.ArrayList getUsers(java.lang.String p_Resource, java.lang.String serverName)
          Return the list of all users in a resource.
static java.util.ArrayList getWarFilesDeployable(java.lang.String serverName)
          Return the list of WAR filename ready to deploy in the current server.
static java.util.ArrayList getWarFilesDeployed(java.lang.String serverName)
          Return the list of deployed WAR filename in the current server.
static boolean hasMBeanName(javax.management.ObjectName p_On, java.lang.String serverName)
          Verify if the Mbean gotten by the query in the current MbeanServer exists.
static java.util.ArrayList prepareContainersToDisplay(java.util.ArrayList p_Containers, java.lang.String p_ContainerDir, java.lang.String p_EarDir)
          Prepare a list of containers to diplay.
static java.lang.String replace(java.lang.String template, java.lang.String placeholder, java.lang.String value)
          Replace any occurrence of the specified placeholder in the specified template string with the specified replacement value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JonasAdminJmx

protected JonasAdminJmx()
Protected constructor to prevent instantiation.

Method Detail

replace

public static java.lang.String replace(java.lang.String template,
                                       java.lang.String placeholder,
                                       java.lang.String value)
Replace any occurrence of the specified placeholder in the specified template string with the specified replacement value.

Parameters:
template - Pattern string possibly containing the placeholder
placeholder - Placeholder expression to be replaced
value - Replacement value for the placeholder
Returns:
A complete string

getJ2eeDomainObjectName

public static javax.management.ObjectName getJ2eeDomainObjectName(java.lang.String serverName)
Return the ObjectName corresponding to the J2EEDomain managed object registered in the current MBeanServer. Normally, we should have only one which has not the property 'clusterName'

Returns:
an ObjectName which corresponds to the first J2EEDomain ObjectName pattern

getArchiveConfigObjectName

public static javax.management.ObjectName getArchiveConfigObjectName(java.lang.String serverName)

getRarConfigObjectName

public static javax.management.ObjectName getRarConfigObjectName(java.lang.String serverName)

getJ2eeServerObjectName

public static javax.management.ObjectName getJ2eeServerObjectName(java.lang.String p_DomainName,
                                                                  java.lang.String serverName)
                                                           throws ManagementException
Return the ObjectName corresponding to the J2EEServer managed object registered in the current MBeanServer and belonging to a domain. We should have one ObjectName corresponding to the current JOnAS server instance.

Parameters:
p_DomainName - The name of the management domain.
Returns:
an ObjectName which corresponds to a J2EEServer ObjectName pattern or null if no J2EEServer found for the given management domain (having j2eeType key property equal to J2EEServer)
Throws:
ManagementException - if could not connect to the MBean server

getJ2eeServerObjectName

public static javax.management.ObjectName getJ2eeServerObjectName(java.lang.String serverName)
Return the ObjectName corresponding to the J2EEServer managed object registered in the current MBeanServer. This method is used by EditTopAction to determine the list of JOnAS servers registered in the current registry (this code is particular to the current domain concept implementation). We should have one ObjectName corresponding to the current JOnAS server instance.

Returns:
an ObjectName which corresponds to a J2EEServer ObjectName pattern (having j2eeType key property equal to J2EEServer)

hasMBeanName

public static boolean hasMBeanName(javax.management.ObjectName p_On,
                                   java.lang.String serverName)
                            throws ManagementException
Verify if the Mbean gotten by the query in the current MbeanServer exists.

Parameters:
p_On - Query Mbean name to search
Returns:
true if MBean exists
Throws:
ManagementException

getFirstMBeanName

public static java.lang.String getFirstMBeanName(javax.management.ObjectName p_On,
                                                 java.lang.String serverName)
                                          throws ManagementException
Return the first Mbean name gotten by the query in the current MbeanServer.

Parameters:
p_On - Query Mbean name to search
Returns:
The first MBean name or null if not found
Throws:
ManagementException

getListMBeanName

public static java.util.List getListMBeanName(javax.management.ObjectName p_On,
                                              java.lang.String serverName)
                                       throws ManagementException
Return the list of Mbean name gotten by the query in the current MbeanServer.

Parameters:
p_On - Query Mbean name to search
Returns:
A list of string Mbean name
Throws:
ManagementException

getFirstMbean

public static javax.management.ObjectName getFirstMbean(javax.management.ObjectName p_On,
                                                        java.lang.String serverName)
                                                 throws ManagementException
Return the first ObjectName Mbean gotten by the query in the current MbeanServer.

Parameters:
p_On - Query Mbean name to search
Returns:
The first ObjectName or null if not found
Throws:
ManagementException

getListMbean

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

Parameters:
p_On - Query Mbeans to search
Returns:
The list of ObjectName
Throws:
ManagementException

extractValueMbeanName

public static java.lang.String extractValueMbeanName(java.lang.String pName,
                                                     java.lang.String pMBeanName)
Extract the value of a key property from the MBean name. This method is usefull when we have the String form and not the ObjectName (avoid creating an ObjectName instance).

Parameters:
pName - Name of the key property
pMBeanName - Stringified ObjectName
Returns:
The value or null if not found

extractFilename

public static java.lang.String extractFilename(java.lang.String p_Path)
Extract the filename of complete path.

Parameters:
p_Path - Complete path (directory and filename)
Returns:
The filename or null

getJarFilesDeployable

public static java.util.ArrayList getJarFilesDeployable(java.lang.String serverName)
                                                 throws ManagementException
Return the list of JAR filename ready to deploy in the current server.

Returns:
The list of JAR filename.
Throws:
ManagementException

getRarFilesDeployable

public static java.util.ArrayList getRarFilesDeployable(java.lang.String serverName)
                                                 throws ManagementException
Return the list of RAR filename ready to deploy in the current server.

Returns:
The list of RAR filename.
Throws:
ManagementException

getEarFilesDeployable

public static java.util.ArrayList getEarFilesDeployable(java.lang.String serverName)
                                                 throws ManagementException
Return the list of EAR filename ready to deploy in the current server.

Returns:
The list of EAR filename.
Throws:
ManagementException

getWarFilesDeployable

public static java.util.ArrayList getWarFilesDeployable(java.lang.String serverName)
                                                 throws ManagementException
Return the list of WAR filename ready to deploy in the current server.

Returns:
The list of WAR filename.
Throws:
ManagementException

getJarFilesDeployed

public static java.util.ArrayList getJarFilesDeployed(java.lang.String serverName)
                                               throws ManagementException
Return the list of deployed JAR filename in the current server.

Returns:
The list of JAR filename.
Throws:
ManagementException

getEarFilesDeployed

public static java.util.ArrayList getEarFilesDeployed(java.lang.String serverName)
                                               throws ManagementException
Return the list of deployed EAR filename in the current server.

Returns:
The list of EAR filename.
Throws:
ManagementException

getRarFilesDeployed

public static java.util.ArrayList getRarFilesDeployed(java.lang.String serverName)
                                               throws ManagementException
Return the list of deployed RAR filename in the current server.

Returns:
The list of RAR filename.
Throws:
ManagementException

getWarFilesDeployed

public static java.util.ArrayList getWarFilesDeployed(java.lang.String serverName)
                                               throws ManagementException
Return the list of deployed WAR filename in the current server.

Returns:
The list of WAR filename.
Throws:
ManagementException

prepareContainersToDisplay

public static java.util.ArrayList prepareContainersToDisplay(java.util.ArrayList p_Containers,
                                                             java.lang.String p_ContainerDir,
                                                             java.lang.String p_EarDir)
Prepare a list of containers to diplay. Deleting prefix root container directory, sorting the list.

Parameters:
p_Containers - The list of containers
p_ContainerDir - The root container directory
p_EarDir - The root ear directory or null
Returns:
The list of containers ready to display

getMailFilesDeployable

public static java.util.ArrayList getMailFilesDeployable(java.lang.String serverName)
                                                  throws ManagementException
Return the list of Mail factory files ready to deploy in the current server.

Returns:
The list of Mail factory properties filenames.
Throws:
ManagementException

getMimePartMailFilesDeployable

public static java.util.ArrayList getMimePartMailFilesDeployable(java.lang.String serverName)
                                                          throws ManagementException
Return the list of MimePartDataSource Mail factory files ready to deploy in the current server.

Returns:
The list of MimePartDataSource Mail factory properties filenames.
Throws:
ManagementException

getSessionMailFilesDeployable

public static java.util.ArrayList getSessionMailFilesDeployable(java.lang.String serverName)
                                                         throws ManagementException
Return the list of Session Mail factory files ready to deploy in the current server.

Returns:
The list of Session Mail factory properties filenames.
Throws:
ManagementException

getMimePartMailFilesDeployed

public static java.util.ArrayList getMimePartMailFilesDeployed(WhereAreYou p_WhereAreYou)
                                                        throws ManagementException
Return the list of deployed MimePartDataSource Mail factories in the current server.

Parameters:
p_WhereAreYou - The container WhereAreYou
Returns:
The list of MimePartDataSource Mail factory filename.
Throws:
ManagementException

getSessionMailFilesDeployed

public static java.util.ArrayList getSessionMailFilesDeployed(WhereAreYou p_WhereAreYou)
                                                       throws ManagementException
Return the list of deployed Session Mail factories in the current server.

Parameters:
p_WhereAreYou - The container WhereAreYou
Returns:
The list of Session Mail factory filename.
Throws:
ManagementException

getMailFilesDeployed

public static java.util.ArrayList getMailFilesDeployed(WhereAreYou p_WhereAreYou)
                                                throws ManagementException
Return the list of deployed Mail factories in the current server.

Parameters:
p_WhereAreYou - The container WhereAreYou
Returns:
The list of Mail factory filename.
Throws:
ManagementException

getDatasourceFilesDeployable

public static java.util.ArrayList getDatasourceFilesDeployable(java.lang.String serverName)
                                                        throws ManagementException
Return the list of Datasource properties files ready to deploy in the current server.

Returns:
The list of Datasource properties filenames.
Throws:
ManagementException - Could not get managzement info from the MBeanServer

getDatasourceFilesDeployed

public static java.util.ArrayList getDatasourceFilesDeployed(java.lang.String domainName,
                                                             java.lang.String serverName)
                                                      throws ManagementException
Return the list of deployed Datasources in the current server.

Parameters:
domainName - Current domain name
serverName - Current server name
Returns:
The list of Datasource filename.
Throws:
ManagementException - Could not get managzement info from the MBeanServer

getDatasourceDependences

public static java.util.ArrayList getDatasourceDependences(java.lang.String pDatasourceName,
                                                           java.lang.String domainName,
                                                           java.lang.String serverName)
                                                    throws ManagementException
Return the list of Datasource dependences for a given datasource name in the current server.

Parameters:
pDatasourceName - The name of the datasource
domainName - Current domain name
serverName - Current server name
Returns:
The list of Datasource dependence (a list of names corresponding to EJBs using this datasource).
Throws:
ManagementException - Could not get managzement info from the MBeanServer
javax.management.MalformedObjectNameException

getMailFactoryDependences

public static java.util.ArrayList getMailFactoryDependences(java.lang.String p_MailFactoryName,
                                                            WhereAreYou p_WhereAreYou)
                                                     throws ManagementException
Return the list of Mail factory dependences in the current server for a given factory name.

Parameters:
p_MailFactoryName - The name of the mail factory
p_WhereAreYou - The container WhereAreYou
Returns:
The list of Mail factory dependences (a list of names corresponding to EJBs using this mail factory).
Throws:
ManagementException

getSessionMailFactoriesDeployed

public static java.util.ArrayList getSessionMailFactoriesDeployed(WhereAreYou p_WhereAreYou)
                                                           throws ManagementException
Return the list of deployed Session Mail Factories in the current server.

Parameters:
p_WhereAreYou - The container WhereAreYou
Returns:
The list
Throws:
ManagementException

getMimeMailPartFactoriesDeployed

public static java.util.ArrayList getMimeMailPartFactoriesDeployed(WhereAreYou p_WhereAreYou)
                                                            throws ManagementException
Return the list of deployed MimePartDatasource Mail Factories in the current server.

Parameters:
p_WhereAreYou - The container WhereAreYou
Returns:
The list
Throws:
ManagementException

getSecurityMemoryFactories

public static java.util.ArrayList getSecurityMemoryFactories(java.lang.String serverName)
                                                      throws ManagementException,
                                                             javax.management.MalformedObjectNameException
Return the list of Security Memory Factories in the current server.

Returns:
The list of Security Memory Factories
Throws:
ManagementException
javax.management.MalformedObjectNameException

getSecurityDatasourceFactories

public static java.util.ArrayList getSecurityDatasourceFactories(java.lang.String serverName)
                                                          throws ManagementException,
                                                                 javax.management.MalformedObjectNameException
Return the list of Security Datasource Factories in the current server.

Returns:
The list of Security Datasource Factories
Throws:
ManagementException
javax.management.MalformedObjectNameException

getSecurityLdapFactories

public static java.util.ArrayList getSecurityLdapFactories(java.lang.String serverName)
                                                    throws ManagementException,
                                                           javax.management.MalformedObjectNameException
Return the list of Security Ldap Factories in the current server.

Returns:
The list of Security Ldap Factories
Throws:
ManagementException
javax.management.MalformedObjectNameException

findSecurityFactorySubType

public static java.lang.String findSecurityFactorySubType(java.lang.String p_NameFactory,
                                                          java.lang.String serverName)
                                                   throws ManagementException,
                                                          javax.management.MalformedObjectNameException
Return the SubType of a Security Factory in the current server.

Parameters:
p_NameFactory - The factory name to find
Returns:
The SubType or null if not found
Throws:
ManagementException
javax.management.MalformedObjectNameException

getUsers

public static java.util.ArrayList getUsers(java.lang.String p_Resource,
                                           java.lang.String serverName)
                                    throws ManagementException,
                                           javax.management.MalformedObjectNameException
Return the list of all users in a resource.

Parameters:
p_Resource - The resource
Returns:
The list of users
Throws:
ManagementException
javax.management.MalformedObjectNameException

getRoles

public static java.util.ArrayList getRoles(java.lang.String p_Resource,
                                           java.lang.String serverName)
                                    throws ManagementException,
                                           javax.management.MalformedObjectNameException
Return the list of all roles in a resource.

Parameters:
p_Resource - The resource
Returns:
The list of roles
Throws:
ManagementException
javax.management.MalformedObjectNameException

getGroups

public static java.util.ArrayList getGroups(java.lang.String p_Resource,
                                            java.lang.String serverName)
                                     throws ManagementException,
                                            javax.management.MalformedObjectNameException
Return the list of all groups in a resource.

Parameters:
p_Resource - The resource
Returns:
The list of groups
Throws:
ManagementException
javax.management.MalformedObjectNameException

getRegistryList

public static java.util.ArrayList getRegistryList(java.lang.String serverName)
                                           throws javax.naming.NamingException
Return a list of names bounded in the registry.

Returns:
The list
Throws:
javax.naming.NamingException

getQueuesList

public static java.util.ArrayList getQueuesList(java.lang.String serverName)
Return the Queue destinations list.

Returns:
The list

getTopicsList

public static java.util.ArrayList getTopicsList(java.lang.String serverName)
Return the Topic destinations list.

Returns:
The list

getConnectionFactoriesList

public static java.util.ArrayList getConnectionFactoriesList(org.apache.struts.util.MessageResources p_Resources,
                                                             java.lang.String serverName)
Return the default Connection Factories.

Parameters:
p_Resources - The messages
Returns:
The list

getLoggers

public static java.util.ArrayList getLoggers(org.apache.struts.util.MessageResources p_Resources,
                                             WhereAreYou p_WhereAreYou,
                                             boolean p_Action)
                                      throws ManagementException,
                                             javax.management.MalformedObjectNameException
Return the list of all used loggers in this JOnAS server.

Parameters:
p_Resources - The used message resource
p_WhereAreYou - The used WhereAreYou instance
p_Action - True to get the action (to use directly in jsp) or False to get the same action but in forward (write in the file struts-config.xml)
Returns:
The list of loggers
Throws:
ManagementException
javax.management.MalformedObjectNameException

getMbeansLists

public static java.util.ArrayList getMbeansLists(java.lang.String serverName)
                                          throws ManagementException
Create a list for each family of Mbean.

Returns:
An array of lists
Throws:
ManagementException

getFamiliesMbeansLists

public static java.util.ArrayList[] getFamiliesMbeansLists(java.lang.String serverName)
                                                    throws ManagementException
Create a list for each family of Mbean.

Returns:
An array of lists
Throws:
ManagementException