/**
 * 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.web;

import java.rmi.RemoteException;
import java.util.List;
import java.util.Set;

/**
 * This interface provides a description for the web container management.
 * @author Ludovic Bert
 * @author Florent Benoit
 * @author Michel-Ange Anton (Contributor)
 */
public interface AbsJWebContainerServiceImplMBean {

    /**
     * Register a WAR, this method is used for the JMX Management.
     * @param fileName the name of the war to deploy.
     * @throws RemoteException if rmi call failed.
     * @throws JWebContainerServiceException if the registration of the WAR
     *         failed.
     */
    void registerWarMBean(String fileName) throws RemoteException, JWebContainerServiceException;

    /**
     * Unregister a WAR, this method is used for the JMX Management.
     * @param fileName the name of the war to undeploy.
     * @throws RemoteException if rmi call failed.
     * @throws JWebContainerServiceException if the unregistration of the WAR
     *         failed.
     */
    void unRegisterWarMBean(String fileName) throws RemoteException, JWebContainerServiceException;

    /**
     * Return the list of installed web applications. The WAR files or the
     * directories with expanded web application are searched in
     * JONAS_BASE/webapps and all webapps directories 'autoload'.
     * @return The list of WAR files or the directories with expanded web
     *         application found
     * @throws Exception if the list can't be retrieved
     */
    List getInstalledWars() throws Exception;

    /**
     * @return current number of wars deployed in the JOnAS server
     */
    Integer getCurrentNumberOfWars();

    /**
     * This method is added temporarily. It will disapear when Wars will have
     * their associated MBeans (when Wars will become manageable)
     * @return the names of the wars currently deployed in the JOnAS server
     */
    Set getWarNames();

    /**
     * Test if the specified filename is already deployed or not
     * @param fileName the name of the war file.
     * @return true if the war is deployed, else false.
     */
    boolean isWarLoaded(String fileName);

    /**
     * Gets the name of the server which is the web container
     * @return the name of the server which is the web container
     */
    String getServerName();

    /**
     * Gets the version of the server which is the web container
     * @return the version of the server which is the web container
     */
    String getServerVersion();

    /**
     * Return the list of all loaded web applications.
     * @return The list of deployed web applications
     */
    List getDeployedWars();

    /**
     * Return the list of installed web applications ready to deploy.
     * @return The list of deployable web applications
     * @throws Exception if the deployable wars can't be returned
     */
    List getDeployableWars() throws Exception;

    /**
     * Return the list of "autoload" directories for web applications.
     * @return The list of all "autoload" directories
     */
    List getAutoloadDirectories();

    /**
     * Return the WebApps directory.
     * @return The WebApps directory
     */
    String getWebappsDirectory();

}
