/**
 * JOnAS: Java(TM) Open Application Server
 * Copyright (C) 1999-2005 Bull S.A.
 * Contact: jonas-team@objectweb.org
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 * USA
 *
 * --------------------------------------------------------------------------
 * $Id$
 * --------------------------------------------------------------------------
 */

package org.objectweb.jonas.jmx;

import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;

/**
 * A set of static classes used to build the names of proprietary MBeans used in JOnAS and in Joram.
 * @author Bruno Michel
 * @author Guillaume Riviere
 * @author Florent Benoit
 * @author Ludovic Bert
 * @author Miroslav Halas
 * @author Adriana Danes
 */
public class JonasObjectName {

    /**
     * domain name
     */
    private static String domain = null;


    /**
     * Set the domain used by JOnAS server
     * @param domainName the domain to use
     */
    public static void setDomain(String domainName) {
        if (domain != null) {
            throw new IllegalStateException("The setDomain method can be called only once.");
        }
        domain = domainName;
    }

    /**
     * @return the domain name of the JOnAS server.
     */
    public static String getDomain() {
        if (domain == null) {
            throw new IllegalStateException("The domain was not previously set, cannot return it.");
        }
        return domain;
    }

    /**
     * Create ObjectName for the JMX Connector Server which is an MBean inside the target MBeanServer
     * @param protocol used protocol
     * @param connectorName name used to distinguish connector servers using the same protocol
     * @return ObjectName for the JMX Connector Server MBean
     */
    public static ObjectName jmxConnectorServer(String protocol, String connectorName) {
        try {
            return ObjectName.getInstance("connectors:protocol=" + protocol + ",name=" + connectorName);
        } catch (MalformedObjectNameException e) {
            // this should never occur
            return null;
        }
    }

    /**
     * @return ObjectName for reconfiguration manager MBean
     */
    public static ObjectName serverConfig() {
        try {
            return ObjectName.getInstance(getDomain() + ":type=management,name=reconfigManager");
        } catch (MalformedObjectNameException e) {
            // this should never occur
            return null;
        }
    }

    public static ObjectName wwwService() {
        try {
            return ObjectName.getInstance(getDomain() + ":type=webContainer,name=Jetty");
        } catch (MalformedObjectNameException e) {
            // this should never occur
            return null;
        }
    }

    public static ObjectName wsService(){
        //TODO: Add a proper web service mbean instead.
        try {
            return ObjectName.getInstance(getDomain() + ":type=WebService,*");
        } catch (MalformedObjectNameException e) {
            // this should never occur
            return null;
        }
    }

    public static ObjectName ejbService() {
        try {
            return ObjectName.getInstance(getDomain() + ":type=service,name=ejbContainers");
        } catch (MalformedObjectNameException e) {
            // this should never occur
            return null;
        }
    }

    /**
     * Return the earService (Jmx).
     * @return the Ear service.
     */
    public static ObjectName earService() {
        try {
            return ObjectName.getInstance(getDomain() + ":type=service,name=ear");
        } catch (MalformedObjectNameException e) {
            // this should never occur
            return null;
        }
    }

    /**
     * Return the mailService (Jmx).
     * @return the Mail service.
     */
    public static ObjectName mailService() {
        try {
            return ObjectName.getInstance(getDomain() + ":type=service,name=mail");
        } catch (MalformedObjectNameException e) {
            // this should never occur
            return null;
        }
    }

    /**
     * Return the webContainerService (Jmx).
     * @return the web container service.
     */
    public static ObjectName webContainerService() {
        try {
            return ObjectName.getInstance(getDomain() + ":type=service,name=webContainers");
        } catch (MalformedObjectNameException e) {
            // this should never occur
            return null;
        }
    }

    public static ObjectName databaseService() {
        try {
            return ObjectName.getInstance(getDomain() + ":type=service,name=database");
        } catch (MalformedObjectNameException e) {
            // this should never occur
            return null;
        }
    }

    public static ObjectName resourceService() {
        try {
            return ObjectName.getInstance(getDomain() + ":type=service,name=resource");
        } catch (MalformedObjectNameException e) {
            // this should never occur
            return null;
        }
    }

    public static ObjectName transactionService() {
        try {
            return ObjectName.getInstance(getDomain() + ":type=service,name=jtm");
        } catch (MalformedObjectNameException e) {
            // this should never occur
            return null;
        }
    }

    public static ObjectName logService(String filename) {
        try {
            return ObjectName.getInstance(getDomain() + ":type=service,name=log,fname="
                + fileNameForObjectName(filename));
        } catch (MalformedObjectNameException e) {
            // this should never occur
            return null;
        }
    }
    /**
     * Construct ObjectName for the discovery service MBean
     * @return ObjectName for the discovery service MBean
     */
    public static ObjectName discoveryService() {
        try {
            return ObjectName.getInstance(getDomain() + ":type=service,name=discovery");
        } catch (MalformedObjectNameException e) {
            // this should never occur
            return null;
        }
    }

    public static ObjectName allLogServices() {
        try {
            return ObjectName.getInstance(getDomain() + ":type=service,name=log,*");
        } catch (MalformedObjectNameException e) {
            // this should never occur
            return null;
        }
    }

    public static ObjectName allServices() {
        try {
            return ObjectName.getInstance(getDomain() + ":type=service,*");
        } catch (MalformedObjectNameException e) {
            // this should never occur
            return null;
        }
    }

    public static ObjectName jmsService() {
        try {
            return ObjectName.getInstance(getDomain() + ":type=service,name=jms");
        } catch (MalformedObjectNameException e) {
            // this should never occur
            return null;
        }
    }

    public static ObjectName jmsService1() {
        try {
            return ObjectName.getInstance(getDomain() + ":type=service,name=jms");
        } catch (MalformedObjectNameException e) {
            // this should never occur
            return null;
        }
    }

    public static ObjectName securityService() {
        try {
            return ObjectName.getInstance(getDomain() + ":type=service,name=security");
        } catch (MalformedObjectNameException e) {
            // this should never occur
            return null;
        }
    }

    public static ObjectName jmxService() {
        try {
            return ObjectName.getInstance("JMImplementation:type=MBeanServerDelegate");
        } catch (MalformedObjectNameException e) {
            // this should never occur
            return null;
        }
    }

    public static ObjectName haService() {
        try {
            return ObjectName.getInstance(getDomain() + ":type=service,name=ha");
        } catch (MalformedObjectNameException e) {
            // this should never occur
            return null;
        }
    }

    public static ObjectName www(String subtype)
        throws MalformedObjectNameException {
        return ObjectName.getInstance(getDomain() + ":type=www,subtype=" + subtype);
    }

    public static ObjectName rar(String filename)
        throws MalformedObjectNameException {
        return ObjectName.getInstance(getDomain() + ":type=resource,fname=" + fileNameForObjectName(filename));
    }

    public static ObjectName war(String filename)
        throws MalformedObjectNameException {
        return ObjectName.getInstance(getDomain() + ":type=war,fname=" + fileNameForObjectName(filename));
    }

    public static ObjectName datasource(String name)
        throws MalformedObjectNameException {
        return ObjectName.getInstance(getDomain() + ":type=datasource,name=" + name);
    }

    /**
     * Return an objectName for a Session type mail factory.
     * @param name the name of the mail factory
     * @return an objectName for the mail factory.
     * @throws MalformedObjectNameException if the objectname can't be build
     */
    public static ObjectName sessionMailFactory(String name)
        throws MalformedObjectNameException {
        return ObjectName.getInstance(getDomain() + ":type=sessionmailfactory,name=" + name);
    }

    /**
     * Return an objectName for the WorkManager
     * @return an objectName for the WorkManager
     */
    public static ObjectName workManager() {
        try {
            return ObjectName.getInstance(getDomain() + ":type=workmanager");
        } catch (MalformedObjectNameException e) {
            // this should never occur
            return null;
        }
    }

    /**
     * Return an objectName for a MimePartDataSource type mail factory.
     * @param name the name of the mail factory
     * @return an objectName for the mail factory.
     * @throws MalformedObjectNameException if the objectname can't be build
     */
    public static ObjectName mimeMailFactory(String name)
        throws MalformedObjectNameException {
        return ObjectName.getInstance(getDomain() + ":type=mimemailfactory,name=" + name);
    }

    /**
     * Return an objectName for a Security memory factory.
     * @param name the name of the security memory factory
     * @return an objectName for the security memory factory.
     * @throws MalformedObjectNameException if the objectname can't be build
     */
    public static ObjectName securityMemoryFactory(String name)
        throws MalformedObjectNameException {
        return ObjectName.getInstance(getDomain() + ":type=securityfactory,subtype=memory,name=" + name);
    }

    /**
     * Return an objectName for a Security datasource factory.
     * @param name the name of the security datasource factory
     * @return an objectName for the security datasource factory.
     * @throws MalformedObjectNameException if the objectname can't be build
     */
    public static ObjectName securityDatasourceFactory(String name)
        throws MalformedObjectNameException {
        return ObjectName.getInstance(getDomain() + ":type=securityfactory,subtype=datasource,name=" + name);
    }

    /**
     * Return an objectName for a Security ldap factory.
     * @param name the name of the security ldap factory
     * @return an objectName for the security ldap factory.
     * @throws MalformedObjectNameException if the objectname can't be build
     */
    public static ObjectName securityLdapFactory(String name)
        throws MalformedObjectNameException {
        return ObjectName.getInstance(getDomain() + ":type=securityfactory,subtype=ldap,name=" + name);
    }

    /**
     * Return an objectName for a user
     * @param resource the name of the resource on which the user depends
     * @param username the name of the user
     * @return an objectName for the user MBean
     * @throws MalformedObjectNameException if the objectname can't be build
     */
    public static ObjectName user(String resource, String username)
        throws MalformedObjectNameException {
        return ObjectName.getInstance(getDomain() + ":type=security,subtype=users,resource=" + resource
            + ",name=" + username);
    }

    /**
     * Return an objectName for all the users
     * @return an objectName for all the users
     * @throws MalformedObjectNameException if the objectname can't be build
     */
    public static ObjectName allUsers() {
        try {
            return ObjectName.getInstance(getDomain() + ":type=security,subtype=users,*");
        }
        catch (MalformedObjectNameException e) {
            // this should never occur
            return null;
        }
    }

    /**
     * Return an objectName for a group
     * @param resource the name of the resource on which the group depends
     * @param groupname the name of the group
     * @return an objectName for the group MBean
     * @throws MalformedObjectNameException if the objectname can't be build
     */
    public static ObjectName group(String resource, String groupname)
        throws MalformedObjectNameException {
        return ObjectName.getInstance(getDomain() + ":type=security,subtype=groups,resource=" + resource
            + ",name=" + groupname);
    }

    /**
     * Return an objectName for all the groups
     * @return an objectName for all the groups
     * @throws MalformedObjectNameException if the objectname can't be build
     */
    public static ObjectName allGroups() {
        try {
            return ObjectName.getInstance(getDomain() + ":type=security,subtype=groups,*");
        }
        catch (MalformedObjectNameException e) {
            // this should never occur
            return null;
        }
    }

    /**
     * Return an objectName for a role
     * @param resource the name of the resource on which the role depends
     * @param rolename the name of the role
     * @return an objectName for the user MBean
     * @throws MalformedObjectNameException if the objectname can't be build
     */
    public static ObjectName role(String resource, String rolename)
        throws MalformedObjectNameException {
        return ObjectName.getInstance(getDomain() + ":type=security,subtype=roles,resource=" + resource
            + ",name=" + rolename);
    }

    /**
     * Return an objectName for all the roles
     * @return an objectName for all the roles
     * @throws MalformedObjectNameException if the objectname can't be build
     */
    public static ObjectName allRoles() {
        try {
            return ObjectName.getInstance(getDomain() + ":type=security,subtype=roles,*");
        }
        catch (MalformedObjectNameException e) {
            // this should never occur
            return null;
        }
    }

    public static ObjectName resourceAdapters()
        throws MalformedObjectNameException {
        return ObjectName.getInstance(getDomain() + ":type=resourceadapter,*");
    }

    public static ObjectName resourceAdapter(String name)
        throws MalformedObjectNameException {
        return ObjectName.getInstance(getDomain() + ":type=resourceadapter,name=" + name);
    }

    public static ObjectName rmiConnector() {
        try {
            return ObjectName.getInstance(getDomain() + ":type=connector,name=rmiconnector");
        }
        catch (MalformedObjectNameException e) {
            // this should never occur
            return null;
        }
    }

    public static ObjectName allWWW() {
        try {
            return ObjectName.getInstance(getDomain() + ":type=service,name=www,*");
        }
        catch (MalformedObjectNameException e) {
            // this should never occur
            return null;
        }
    }

    public static ObjectName allEars() {
        try {
            return ObjectName.getInstance(getDomain() + ":type=ear,*");
        }
        catch (MalformedObjectNameException e) {
            // this should never occur
            return null;
        }
    }

    public static ObjectName allRars() {
        try {
            return ObjectName.getInstance(getDomain() + ":type=resource,*");
        } catch (MalformedObjectNameException e) {
            // this should never occur
            return null;
        }
    }

    public static ObjectName allWars() {
        try {
            return ObjectName.getInstance(getDomain() + ":type=war,*");
        } catch (MalformedObjectNameException e) {
            // this should never occur
            return null;
        }
    }

    public static ObjectName allDatasources() {
        try {
            return ObjectName.getInstance(getDomain() + ":type=datasource,*");
        } catch (MalformedObjectNameException e) {
            // this should never occur
            return null;
        }
    }

    /**
     * Return an objectName specifying all the session mail factories.
     * @return an objectName referencing all session mail factories.
     */
    public static ObjectName allSessionMailFactories() {
        try {
            return ObjectName.getInstance(getDomain() + ":type=sessionmailfactory,*");
        } catch (MalformedObjectNameException e) {
            // this should never occur
            return null;
        }
    }

    /**
     * Return an objectName specifying all the mime mail factories.
     * @return an objectName referencing all mime mail factories.
     */
    public static ObjectName allMimeMailFactories() {
        try {
            return ObjectName.getInstance(getDomain() + ":type=mimemailfactory,*");
        } catch (MalformedObjectNameException e) {
            // this should never occur
            return null;
        }
    }

    public static ObjectName allResourceAdaptors() {
        try {
            return ObjectName.getInstance(getDomain() + ":type=resourceadapter,*");
        } catch (MalformedObjectNameException e) {
            // this should never occur
            return null;
        }
    }

    public static String getType(ObjectName obj) {
        return obj.getKeyProperty("type");
    }

    public static String fileNameForObjectName(String fileName) {
        return fileName.replace(':', '|');
    }

    /**
     * Return an objectName for the Security factory name.
     *
     * @param pName The name of the wanted security factory
     * @return an objectName for the security factory name.
     * @throws MalformedObjectNameException if the objectname can't be build
     */
    public static ObjectName securityFactories(String pName)
        throws MalformedObjectNameException {
        return ObjectName.getInstance(JonasObjectName.getDomain() + ":type=securityfactory,name=" + pName);
    }

    /**
     * Return an objectName for the Security factory name.
     *
     * @return an objectName for the security factory name.
     * @throws MalformedObjectNameException if the objectname can't be build
     */
    public static ObjectName allSecurityFactories()
        throws MalformedObjectNameException {
        return ObjectName.getInstance(JonasObjectName.getDomain() + ":type=securityfactory,*");
    }

    /**
     * Return an objectName for all the Security memory factories.
     *
     * @return an objectName for all the security memory factories
     * @throws MalformedObjectNameException if the objectname can't be build
     */
    public static ObjectName allSecurityMemoryFactories()
        throws MalformedObjectNameException {
        return ObjectName.getInstance(JonasObjectName.getDomain() + ":type=securityfactory,subtype=memory,*");
    }

    /**
     * Return an objectName for all the Security datasource factories.
     *
     * @return an objectName for all the security datasource factories
     * @throws MalformedObjectNameException if the objectname can't be build
     */
    public static ObjectName allSecurityDatasourceFactories()
        throws MalformedObjectNameException {
        return ObjectName.getInstance(JonasObjectName.getDomain() + ":type=securityfactory,subtype=datasource,*");
    }

    /**
     * Return an objectName for all the Security ldap factories.
     *
     * @return an objectName for all the security ldap factories
     * @throws MalformedObjectNameException if the objectname can't be build
     */
    public static ObjectName allSecurityLdapFactories()
        throws MalformedObjectNameException {
        return ObjectName.getInstance(JonasObjectName.getDomain() + ":type=securityfactory,subtype=ldap,*");
    }

    /**
     * Return an objectName for all users in a resource.
     *
     * @param pResource the name of the resource on which the user depends
     * @return an objectName for the user MBean
     * @throws MalformedObjectNameException if the objectname can't be build
     */
    public static ObjectName allUsers(String pResource)
        throws MalformedObjectNameException {
        return ObjectName.getInstance(JonasObjectName.getDomain() + ":type=security,subtype=users,resource="
            + pResource + ",*");
    }

    /**
     * Return an objectName for all roles in a resource.
     *
     * @param pResource the name of the resource on which the role depends
     * @return an objectName for the user MBean
     * @throws MalformedObjectNameException if the objectname can't be build
     */
    public static ObjectName allRoles(String pResource)
        throws MalformedObjectNameException {
        return ObjectName.getInstance(JonasObjectName.getDomain() + ":type=security,subtype=roles,resource="
            + pResource + ",*");
    }

    /**
     * Return an objectName for all groups in a resource.
     *
     * @param pResource the name of the resource on which the group depends
     * @return an objectName for the user MBean
     * @throws MalformedObjectNameException if the objectname can't be build
     */
    public static ObjectName allGroups(String pResource)
        throws MalformedObjectNameException {
        return ObjectName.getInstance(JonasObjectName.getDomain() + ":type=security,subtype=groups,resource="
            + pResource + ",*");
    }

    /**
     * A different implementation should allow returning a logical name.
     * This String is used within the Exception messages when throwing a ManagementException.
         * This is done currently in the invoke method of ManagementReprImpl/Mx4jManagementReprImpl classes.
     * @return String representation of the ObjectName
     */
    public String toString() {
        return super.toString();
    }

    // Joram integration
    // ------------------
    /**
     * @return ObjectName for the local Joram server
     * @exception MalformedObjectNameException Could not create ObjectName with the given String
     */
    public static ObjectName joramLocalServer() throws MalformedObjectNameException {
        return ObjectName.getInstance("joram:type=JMSlocalServer");
    }

    /**
     * Create ObjectName for a remote Joram server
     * @param id remote server identifier
     * @return ObjectName for a remote Joram server
     * @exception MalformedObjectNameException Could not create ObjectName with the given String
     */
    public static ObjectName joramRemoteServer(String id) throws MalformedObjectNameException {
        return ObjectName.getInstance("joram:type=JMSremoteServer,id=" + id);
    }

    /**
     * Create ObjectName for a Joram managed queue
     * @param name queue name
     * @return ObjectName for a Joram managed queue
     * @exception MalformedObjectNameException Could not create ObjectName with the given String
     */
    public static ObjectName joramQueue(String name) throws MalformedObjectNameException {
        return ObjectName.getInstance("joram:type=JMSqueue,name=" + name);
    }

    /**
     * Create ObjectName for a Joram managed topic
     * @param name topic name
     * @return ObjectName for a Joram managed topic
     * @exception MalformedObjectNameException Could not create ObjectName with the given String
     */
    public static ObjectName joramTopic(String name) throws MalformedObjectNameException {
        return ObjectName.getInstance("joram:type=JMStopic,name=" + name);
    }

    /**
     * @return ObjectName for discovery manager MBean
     * @exception MalformedObjectNameException Could not create ObjectName with the given String
     */
    public static ObjectName discoveryManager() throws MalformedObjectNameException {
        return ObjectName.getInstance(getDomain() + ":type=management,name=discoveryManager,server=JOnAS");
    }

    /**
     * @return ObjectName for discovery client MBean
     * @exception MalformedObjectNameException Could not create ObjectName with the given String
     */
    public static ObjectName discoveryClient() throws MalformedObjectNameException {
        return ObjectName.getInstance(getDomain() + ":type=management,name=discoveryClient,server=JOnAS");
    }
    /**
     * @return ObjectName for discovery enroller MBean
     * @exception MalformedObjectNameException Could not create ObjectName with the given String
     */
    public static ObjectName discoveryEnroller() throws MalformedObjectNameException {
        return ObjectName.getInstance(getDomain() + ":type=management,name=discoveryEnroller,server=JOnAS");
    }

    /**
     * @return ObjectName for domain monitor MBean
     * @exception MalformedObjectNameException Could not create ObjectName with the given String
     */
    public static ObjectName domainMonitor() throws MalformedObjectNameException {
        return ObjectName.getInstance(getDomain() + ":type=management,name=domainMonitor,server=JOnAS");
    }

    /**
     * @return ObjectName for ServerProxy MBean
     * @exception MalformedObjectNameException Could not create ObjectName with the given String
     */
    public static ObjectName serverProxy(String serverName) throws MalformedObjectNameException {
        return ObjectName.getInstance(getDomain() + ":type=ServerProxy,name=" + serverName);
    }

    /**
     * @return ObjectName for ServerProxy MBean
     * @exception MalformedObjectNameException Could not create ObjectName with the given String
     */
    public static ObjectName serverProxys() throws MalformedObjectNameException {
        return ObjectName.getInstance(getDomain() + ":type=ServerProxy,*");
    }

    /**
     * Build an ObjectName for a Cluster defined by its type and its name.
     * @param name Name of the Cluster
     * @param type Type: JkCluster, TomcatCluster, JoramCluster, EjbHaCluster, CmiCluster, ...
     * @return ObjectName for a Cluster
     * @throws MalformedObjectNameException
     */
    public static ObjectName cluster(String name, String type) throws MalformedObjectNameException {
        return ObjectName.getInstance(getDomain() + ":type=" + type + ",name=" + name);
    }

    /**
     * Build an ObjectName for a Cluster defined by its type only.
     * @param type Type: JkCluster, TomcatCluster, JoramCluster, EjbHaCluster, CmiCluster, ...
     * @return ObjectName for a Cluster
     * @throws MalformedObjectNameException
     */
    public static ObjectName clusters(String type) throws MalformedObjectNameException {
        return ObjectName.getInstance(getDomain() + ":type=" + type + ",name=*");
    }

    /**
     * Build an ObjectName for a ClusterMember.
     * All ClusterMember have the same type, regardless the cluster type.
     * @param name Name of the ClusterMember
     * @param type type of the cluster (ex: JkCluster or TomcatCluster)
     * @param cluster Name of the Cluster
     * @return ObjectName for a ClusterMember
     * @throws MalformedObjectNameException
     */
    public static ObjectName clusterMember(String name, String type, String cluster) throws MalformedObjectNameException {
        return ObjectName.getInstance(getDomain() + ":type="+type+"Member,name=" + name + ","+type+"=" + cluster);
    }

    public static ObjectName clusterDaemon() throws Exception {
        return ObjectName.getInstance(getDomain() + ":type=ClusterDaemon");
    }

    /**
     * @param name name of the ClusterDaemon
     * @return
     * @exception MalformedObjectNameException Could not create ObjectName with the given String
     */
    public static ObjectName clusterDaemonProxy(String name) throws MalformedObjectNameException {
        return ObjectName.getInstance(getDomain() + ":type=ClusterDaemonProxy,name=" + name);
    }

    /**
     * @return ObjectName for Catalina Connectors Factory
     * @exception MalformedObjectNameException Could not create ObjectName with the given String
     * @param pDomain domain name
     */
    public static ObjectName catalinaConnectorFactory(String pDomain) throws MalformedObjectNameException {
        return new ObjectName(pDomain + ":type=ConnectorFactory");
    }

    /**
     * @return ObjectName for WebModule Proxy
     * @exception MalformedObjectNameException Could not create ObjectName with the given String
     * @param pDomain domain name
     */
    public static ObjectName webModuleProxy(String pDomain) throws MalformedObjectNameException {
        return new ObjectName(pDomain + ":type=WebModuleProxy");
    }

    /**
     * @return ObjectName for the generic archive configurationMBean
     */
    public static ObjectName ArchiveConfig() {
        try {
            return new ObjectName(":type=archiveConfig,name=ArchiveConfigMBean");
        } catch (javax.management.MalformedObjectNameException e) {
            // this should never occur
            return null;
        }
    }

    /**
     * @return ObjectName for RAR specific archive configuration MBean
     */
    public static ObjectName RarConfig() {
        try {
            return new ObjectName(":type=archiveConfig,name=RarConfigMBean");
        } catch (javax.management.MalformedObjectNameException e) {
            // this should never occur
            return null;
        }
    }
}
