/**
 * JOnAS: Java(TM) Open Application Server
 * Copyright (C) 2006 Bull S.A.S.
 * 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 1any 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.cluster.daemon;

/**
 * Defines the MBean interface. Don't use Models MBeans as it will imply some
 * external libraries like commons-modeler (easier).
 * @author Benoit Pelletier
 */
public interface ClusterDaemonMBean {

    /**
     * @return Object Name
     */
    String getobjectName();

    /**
     * Sets the object name of this mbean
     * @param name the Object Name
     */
    void setobjectName(String name);

    /**
     * @return true if it is an event provider
     */
    boolean iseventProvider();

    /**
     * @return true if this managed object implements J2EE State Management Model
     */
    boolean isstateManageable();

    /**
     * @return true if this managed object implements the J2EE StatisticProvider Model
     */
    boolean isstatisticsProvider();

    /**
     * @return the list of JOnAS instances
     */
    String getServersList();

    /**
     * @return the JAVA_HOME for a specified server name
     * @param name JOnAS instance name
     */
    String getJavaHome4Server(String name);

    /**
     * @return the JONAS_ROOT for a specified server name
     * @param name JOnAS instance name
     */
    String getJonasRoot4Server(String name);

    /**
     * @return the JONAS_BASE for a specified server name
     * @param name JOnAS instance name
     */
    String getJonasBase4Server(String name);

    /**
     * @return the user command for a specified server name
     * @param name JOnAS instance name
     */
    String getJonasCmd4Server(String name);

    /**
     * @return xprm for a specified server name
     * @param name JOnAS instance name
     */
    String getXprm4Server(String name);

    /**
     * @return autoBoot value for a specified server name
     * @param name JOnAS instance name
     */
    String getAutoBoot4Server(String name);

    /**
     * Reload the configuration
     * @throws ClusterDaemonException if an error occurs
     */
    void reloadConfiguration() throws ClusterDaemonException;

    /**
     * Add a server configuration
     * @param name server name
     * @param description server description
     * @param javaHome JAVA_HOME dir
     * @param jonasBase JONAS_BASE dir
     * @param jonasRoot JONAS_ROOT dir
     * @param xprm extra JVM parameters
     * @param autoBoot automatic start
     * @param jonasCmd user command
     * @throws ClusterDaemonException if an error occurs
     */
    void addServer(String name, String description, String javaHome, String jonasRoot, String jonasBase, String xprm, String autoBoot, String jonasCmd) throws ClusterDaemonException;

    /**
     * Remove a server configuration
     * @param name server name
     * @throws ClusterDaemonException if an error occurs
     */
    void removeServer(String name) throws ClusterDaemonException;

    /**
     * Modify a server configuration
     * @param name server name
     * @param description server description
     * @param javaHome JAVA_HOME dir
     * @param jonasBase JONAS_BASE dir
     * @param jonasRoot JONAS_ROOT dir
     * @param xprm extra JVM parameters
     * @param autoBoot automatic start
     * @param jonasCmd user command
     * @throws ClusterDaemonException if an error occurs
     */
    void modifyServer(String name, String description, String javaHome, String jonasRoot, String jonasBase, String xprm, String autoBoot, String jonasCmd) throws ClusterDaemonException;

    /**
     * Start a JOnAS instance
     * @param name instance name
     * @param domainName domain name
     * @param prm extra parameters
     * @throws ClusterDaemonException if an error occurs
     */
    void startJOnAS(String name, String domainName, String prm) throws ClusterDaemonException;

    /**
     * Stop a JOnAS instance
     * @param name instance name
     * @throws ClusterDaemonException if an error occurs
    */
    void stopJOnAS(String name) throws ClusterDaemonException;

    /**
     * Ping a JOnAS instance (MBean interface)
     * @param name instance name
     * @return exit code of the ping (0 ok, 1 ko)
     * @throws ClusterDaemonException if an error occurs
    */
    int pingJOnAS(String name) throws ClusterDaemonException;

    /**
     * Start all the JOnAS instances configured with auto-reboot
     * @param domainName domain name
     * @param prm extra parameters
      * @return the nodes list with an indicator started/starting failed
     */
    String startAllJOnAS(String domainName, String prm);

    /**
     * Stop all the JOnAS instances
     * @return the nodes list with an indicator stopped/stopping failed
     */
    String stopAllJOnAS();

    /**
     * Stop the cluster daemon instance
     */
    void stopClusterDaemon();

}
