/*
 * 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
 *
 * --------------------------------------------------------------------------
 * $Id$
 * --------------------------------------------------------------------------
 */

package org.objectweb.jonas.jmx;

import java.util.Properties;
import java.util.Set;

import javax.management.AttributeList;
import javax.management.MBeanInfo;
import javax.management.ObjectName;
import javax.naming.Context;
import javax.naming.NamingException;

/**
 *  Defines all the management operations invoked by management applications through the 
 *  <code>JonasManagementRepr</code> class.
 * @author Adriana Danes
 */
public interface ManagementRepr { 

    /**
     * @return True if the MBean is already registered in the MBean server, false otherwise or if an exception is catched.
     */
    public boolean isRegistered(ObjectName on) ;

    /**
     * @param on The ObjectName of the MBean of which the attribute is to be retrieved.
     * @param attribute A String specifying the name of the attribute to be retrieved.
     * @return The value of the attribute.
     */
    public Object getAttribute(ObjectName on, String attribute) 
        throws ManagementException ;

    /**
     * @param on The ObjectName of the MBean of which attribute are to be retrieved.
     * @param attributes A list of the attributes to be retrieved.
     * @return Thelist of retrieved attributes.
     */
    public AttributeList getAttributes(ObjectName on, String[] attributes) 
        throws ManagementException ;

    /**
     * @param on The ObjectName of the MBean of which the attribute is to be set
     * @param attribute A String specifying the name of the attribute to be retrieve.
     * @param value The value to set to the attribute.
     */
    public void setAttribute(ObjectName on, String attribute, Object value) 
        throws ManagementException;

    /**
     * @param on The ObjectName of the MBean of which the attribute is to be set.
     * @param attributes A list of attributes: The identification of the attribute to be set and the value it is to be set to
     * @return The list of attributes that were set, with their new values.
     */
    public AttributeList setAttributes(ObjectName on, AttributeList attributes) 
        throws ManagementException;

    /**
     * @param on
     */
    public Object invoke(ObjectName on, String operation, Object[] param, String[] signature) 
        throws ManagementException;    

    /**
     * @return A set containing the ObjectNames for the MBeans selected.
     */
    public java.util.Set queryNames(ObjectName on) 
        throws ManagementException;

    /**
     * @return An instance of MBeanInfo allowing the retrieval of all 
     * attributes and operations of this MBean.
     */    
    public MBeanInfo getMBeanInfo(ObjectName name) throws ManagementException;

    /**
     * @return Context the current application context.
     */
    public  Context getContext() throws NamingException;

    /**
     * @return String the name of the current RMI connector.   
     */
    public String getCurrentRMIConnectorName();

    /**
     * Set the currentRMIConnectorName to the specified value
     */
    public void setCurrentRMIConnectorName(String name) throws Exception;

    /**
     * Set the currentRMIConnectorName to null
     */
    public void resetCurrentRMIConnectorName();

    /**
     * @return Set a set containning all RMI connector names available in the current context.
     */
    public Set getRMIConnectorsNames() throws NamingException;

    /**
     * @return String the value of the PROVIDER_URL property in the current context.
     */
    public String getJonasNamingServiceURL();

    /**
     * Sets  the PROVIDER_URL property to the specified value. 
     */
    public void setJonasNamingServiceURL(String url) throws NamingException;   

    /**
     * Create a new naming context based on the given env. properties
     */
    public void setNamingEnvCtx(Properties env) throws javax.naming.NamingException;
}
