/**
 * JOnAS: Java(TM) Open Application Server
 * Copyright (C) 2008 Bull S.A.
 * Contact: jonas-team@ow2.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.ow2.jonas.lib.management.extensions.manager;


import org.ow2.jonas.lib.management.extensions.domain.DomainManagement;
import org.ow2.jonas.management.extensions.domain.api.IDomain;

/**
 * Implements singleton for all management operations in JOnAS.
 * @author danesa
 * @author Oualaa Hani
 */
public class ManagementEntryPoint implements IDomain {

    /**
     * The ManagementEntryPoint singleton for management tools.
     */
    private static ManagementEntryPoint unique = null;

    /**
     * The IDomain Interface for DomainManagement implementation.
     */
    private static IDomain domainManagement = null;

    /**
     * @return ManagementEntryPoint singleton.
     */
    public static synchronized ManagementEntryPoint getInstance() {
        if(unique == null) {
            unique = new ManagementEntryPoint();
        }
        return unique;
    }

    private ManagementEntryPoint() {
        domainManagement = new DomainManagement();
    }

    // --------------------------------------------------
    // Domain management operations.
    // --------------------------------------------------

    public String getClusterState(final String clusterName) {
        return domainManagement.getClusterState(clusterName);
    }

    public String getClusterType(final String clusterName) {
        return domainManagement.getClusterType(clusterName);
    }

    public String[] getClusterdaemonNames() {
        return domainManagement.getClusterdaemonNames();
    }

    public String getClusterdaemonState(final String clusterdaemonName) {
        return domainManagement.getClusterdaemonState(clusterdaemonName);
    }

    public String[] getClusters() {
        return domainManagement.getClusters();
    }

    public String[] getClustersNames() {
        return domainManagement.getClustersNames();
    }

    public String getServerClusterdaemon(final String serverName) {
        return domainManagement.getServerClusterdaemon(serverName);
    }

    public String[] getServerNames() {
        return domainManagement.getServerNames();
    }

    public String[] getServerNames(final String clusterName) {
        return domainManagement.getServerNames(clusterName);
    }

    public String getServerState(final String serverName) {
        return domainManagement.getServerState(serverName);
    }

    public String[] getclusterDaemons() {
        return domainManagement.getclusterDaemons();
    }

    public boolean isMaster(final String serverName) {
        return domainManagement.isMaster(serverName);
    }

    public boolean isMaster() {
        return domainManagement.isMaster();
    }

    public String getDomainName() {
        return domainManagement.getDomainName();
    }

    public String getServerName() {
        return domainManagement.getServerName();
    }
}
