/**
 * JOnAS: Java(TM) Open Application Server
 * Copyright (C) 1999-2008 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 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): ____________________________________.
 * Contributor(s): - Michel Bruno and Guillaume Riviere
 *                 - S. Ali Tokmen, Malek Chahine: EJB statistics
 *
 * --------------------------------------------------------------------------
 * $Id$
 * --------------------------------------------------------------------------
 */

package org.objectweb.jonas.container;

import java.util.List;
import java.util.Set;

/**
 * MBean Interface for EJB Service Management
 * MBean type: Standard
 * MBean model: Inheritance (EJBServiceImpl)
 */
public interface EJBServiceImplMBean {

    /**
     * @return Integer Total Number of Container actually in JOnAS
     */
    public Integer getCurrentNumberOfContainer();

    /**
     * @return Integer Total Number of Bean Type actually in JOnAS
     */
    public Integer getTotalCurrentNumberOfBeanType();

    /**
     * @return Integer Total Number of Bmp Type actually in JOnAS
     */
    public Integer getTotalCurrentNumberOfBMPType();

    /**
     * @return Integer Total Number of Cmp Type actually in JOnAS
     */
    public Integer getTotalCurrentNumberOfCMPType();

    /**
     * @return Integer Total Number of Sbf Type actually in JOnAS
     */
    public Integer getTotalCurrentNumberOfSBFType();

    /**
     * @return Integer Total Number of Sbl Type actually in JOnAS
     */
    public Integer getTotalCurrentNumberOfSBLType();

    /**
     * @return Integer Total Number of Mdb Type actually in JOnAS
     */
    public Integer getTotalCurrentNumberOfMDBType();

    /**
     * MBean method
     * @return the ObjectName of all the ejbs using this datasource
     */
    public Set getDataSourceDependence(String dsName);

    /**
     * MBean method
     * @return the ObjectName of all the ejb using this destination.
     */
    public Set getJmsDestinationDependence(String dsName);

    /**
     * MBean method
     * @return the ObjectName of all the ejb using this Connection Factory.
     */
    public Set getJmsConnectionFactoryDependence(String cfName);

    /**
     * MBean method
     * @return the ObjectName of all the ejb using a given Mail Factory.
     */
    public Set getMailFactoryDependence(String mfName);

    /**
     * remove a container application
     * @param String ContainerName, the Name of this container
     */
    public void removeContainerMBean(String fileName) throws Exception;

    /**
     * Create an ejb container for the EJBs contained in a .jar (or .xml) file
     * @param file Name of the file to be deployed
     * @return The ObjectName of the MBean associated to the container (to the deployed module)
     */
    public String createContainerMBean(String file) throws Exception;

    /**
     * Return the list of installed EJB containers.
     * The JAR files or the directories with expanded EJB container are searched
     * in JONAS_BASE/ejbjars and all ejbjar directories 'autoload'.
     * @return The list of JAR files or the directories with expanded EJB container found
     * @throws Exception if the list can't be retrieved
     */
    public List getInstalledJars() throws Exception;

    /**
     * Synchronized all entity bean containers
     * @param passivate passivate instances after synchronization.
     */
    public void syncAllEntities(boolean passivate);

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

    /**
     * Return the list of all loaded EJB container.
     *
     * @return The list of deployed EJB container
     */
    public List getDeployedJars();

    /**
     * Return the list of installed EJB container ready to deploy.
     *
     * @return The list of deployable EJB container
     * @throws Exception
     */
    public List getDeployableJars() throws Exception;

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

    /**
     * Return the Ejbjars directory.
     * @return The Ejbjars directory
     */
    public String getEjbjarsDirectory();


    /**
     * @return Will EJB monitoring enabled for EJBs deployed in the future?
     */
    public boolean getMonitoringEnabled();

    /**
     * @param monitoringEnabled Whether EJB monitoring will enabled for EJBs
     *                      deployed in the future.
     */
    public void setMonitoringEnabled(final boolean monitoringEnabled);

    /**
     * @return Number of milliseconds after which methods of EJBs deployed in
     *         the future will start warning.
     */
    public int getWarningThreshold();

    /**
     * @param warningThreshold Number of milliseconds after which methods of
     *                            EJBs deployed in the future will start
     *                            warning.
     */
    public void setWarningThreshold(final int warningThreshold);

    /**
     * get the total number of calls on all beans of this ejb container
     * @return the total number of calls on all beans of this ejb container
     */
    public int getNumberOfCalls();

    /**
     * get the total time spent in container + business execution for all beans
     * of this ejb container
     * @return the total time spent in container + business execution for all
     *         beans of this ejb container
     */
    public long getTotalProcessingTime();

    /**
     * get the total time spent in business execution for all beans of this
     * ejb container
     * @return the total time spent in business execution for all beans of this
     *         ejb container
     */
    public long getTotalBusinessProcessingTime();
    
    /**
     * get the average time spent in container + business execution for all beans
     * of this ejb container per request
     * @return the average time spent in container + business execution for all
     *         beans of this ejb container per request
     */
    public long getAverageProcessingTime();

    /**
     * get the average time spent in business execution for all beans of this
     * ejb container per request
     * @return the average time spent in business execution for all beans of this
     *         ejb container per request
     */
    public long getAverageBusinessProcessingTime();
     
    /**
     * Applies the current monitoring settings to deployed EJBs.
     */
    public void applyMonitorSettings(String scope);


}
