/**
 * JOnAS: Java(TM) Open Application Server
 * Copyright (C) 1999 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
 *
 * Initial developer(s): Florent BENOIT & Ludovic BERT
 * --------------------------------------------------------------------------
 * $Id$
 * --------------------------------------------------------------------------
 */

package org.objectweb.jonas.ear;

import javax.naming.Context;

import org.objectweb.jonas.service.Service;

/**
 * JOnAS EAR Service interface. This interface provides a description of an EAR
 * service.
 * @author Ludovic Bert
 * @author Florent Benoit
 */
public interface EarService extends Service {

    /**
     * Deploy an EAR file with sending JAR file to the EJB container and WAR
     * file to the WEB container.
     * @param ctx the context which contains the configuration in order to
     *        deploy an EAR.
     * @return The ObjectName of the J2EE Application MBean associated to the
     *         deployed EAR
     * @throws EarServiceException if the deployment of the EAR failed.
     */
    String deployEar(Context ctx) throws EarServiceException;

    /**
     * Undeploy an EAR by sending the request to the EJB container and to the
     * WEB container.
     * @param ctx the context which contains the configuration in order to
     *        undeploy an EAR.
     * @throws EarServiceException if the undeployment of the EAR failed.
     */
    void unDeployEar(Context ctx) throws EarServiceException;

    /**
     * Deploy an EAR, used by management applications via J2EEServer managed
     * object
     * @param fileName the fileName of the ear which must be be deployed.
     * @return The ObjectName of the MBean associated to the deployed J2EE
     *         Application
     * @throws Exception if the deployment of the EAR failed.
     */
    String deployEar(String fileName) throws Exception;

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

    /**
     * Test if the specified unpack name is already deployed or not. This
     * method is defined in the EarService interface.
     * @param unpackName the name of the ear file.
     * @return true if the ear is deployed, else false.
     */
    boolean isEarDeployedByUnpackName(String unpackName);

    /**
     * Undeploy an EAR, used by management applications via J2EEServer managed
     * object
     * @param fileName the fileName of the ear which must be be undeployed.
     * @throws Exception if the undeployment of the EAR failed.
     */
    void unDeployEar(String fileName) throws Exception;

    /**
     * Return the Apps directory.
     * @return The Apps directory
     */
    String getAppsDirectory();

}