/**
 * JOnAS: Java(TM) Open Application Server
 * Copyright (C) 2003-2004 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 Catalina MBeans used in JOnAS.
 * This class was initially located in package org.objectweb.jonas.webapp.jonasadmin.
 *
 * @author Michel-Ange ANTON
 */
public class CatalinaObjectName {

    public static ObjectName catalinaServer() throws MalformedObjectNameException {
        return ObjectName.getInstance("Catalina:type=Server");
    }

    public static ObjectName catalinaFactory() throws MalformedObjectNameException {
        return ObjectName.getInstance("Catalina:type=MBeanFactory");
    }

    public static ObjectName catalinaService(String p_Domain, String p_ServiceName) throws MalformedObjectNameException {
        return ObjectName.getInstance(p_Domain + ":type=Service,name=" + p_ServiceName);
    }

    public static ObjectName catalinaEngine(String p_Domain) throws MalformedObjectNameException {
        return ObjectName.getInstance(p_Domain + ":type=Engine");
    }


    public static ObjectName catalinaClusters(String p_Domain) throws MalformedObjectNameException {
        return ObjectName.getInstance(p_Domain + ":type=Cluster,*");
    }

    public static ObjectName catalinaClusterMembership(String domainName, String hostName) throws MalformedObjectNameException {
        return ObjectName.getInstance(domainName + ":type=ClusterMembership,host=" + hostName);
    }

    public static ObjectName catalinaClusterReceiver(String domainName, String hostName) throws MalformedObjectNameException {
        return ObjectName.getInstance(domainName + ":type=ClusterReceiver,host=" + hostName);
    }

    public static ObjectName catalinaClusterSender(String domainName, String hostName) throws MalformedObjectNameException {
        return ObjectName.getInstance(domainName + ":type=ClusterSender,host=" + hostName);
    }

    public static ObjectName catalinaConnectors(String p_Domain) throws MalformedObjectNameException {
        return ObjectName.getInstance(p_Domain + ":type=Connector,*");
    }

    public static ObjectName catalinaConnector(String p_Domain, String p_Port) throws MalformedObjectNameException {
        return ObjectName.getInstance(p_Domain + ":type=Connector,port=" + p_Port);
    }

    public static ObjectName catalinaHosts(String p_Domain) throws MalformedObjectNameException {
        return ObjectName.getInstance(p_Domain + ":type=Host,*");
    }

    public static ObjectName catalinaHost(String p_Domain, String p_HostName) throws MalformedObjectNameException {
        return ObjectName.getInstance(p_Domain + ":type=Host,host=" + p_HostName);
    }

    public static ObjectName catalinaRealms() throws MalformedObjectNameException {
        return ObjectName.getInstance("*:type=Realm,*");
    }

    public static ObjectName catalinaRealm(String p_Domain) throws MalformedObjectNameException {
        return ObjectName.getInstance(p_Domain + ":type=Realm");
    }

    public static ObjectName catalinaValves(String p_Domain) throws MalformedObjectNameException {
        return ObjectName.getInstance(p_Domain + ":type=Valve,*");
    }

    public static ObjectName catalinaAccessLogValves(String p_Domain) throws MalformedObjectNameException {
        return ObjectName.getInstance(p_Domain + ":type=Valve,name=AccessLogValve,*");
    }

    public static ObjectName catalinaValves(String p_Domain, String p_Host) throws MalformedObjectNameException {
        return ObjectName.getInstance(p_Domain + ":type=Valve,host=" + p_Host + ",*");
    }

    public static ObjectName catalinaValve(String p_Domain, String p_Name) throws MalformedObjectNameException {
        return ObjectName.getInstance(p_Domain + ":type=Valve,name=" + p_Name);
    }

    public static ObjectName catalinaValve(String p_Domain, String p_Name, String p_Host) throws MalformedObjectNameException {
        return ObjectName.getInstance(p_Domain + ":type=Valve,name=" + p_Name + ",host=" + p_Host);
    }

    public static ObjectName catalinaThreadPools(String p_Domain) throws MalformedObjectNameException {
        return ObjectName.getInstance(p_Domain + ":type=ThreadPool,*");
    }

    public static ObjectName catalinaGlobalRequestProcessors(String p_Domain) throws MalformedObjectNameException {
        return ObjectName.getInstance(p_Domain + ":type=GlobalRequestProcessor,*");
    }
}
