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

//import java
import java.util.Properties;

import javax.management.MBeanException;
import javax.management.NotificationFilter;
import javax.management.NotificationListener;

import org.apache.commons.modeler.BaseModelMBean;

/**
 * This interface defines all the management methods provided by the JavaMailResource objects.
 * @author Florent Benoit
 * @author Ludovic Bert
 * @author Adriana Danes:
 *  - Refactor code: rename the management methods (use straightforward names, as they are to be used in a Management Console)
 *  - J2EEManagement conformance
 *  - Use jakarta-commons modeler
 */
public class JavaMailResourceMBean extends BaseModelMBean {
    /**
     * Default constructor
     * @throws MBeanException if super constructor fails
     */
    public JavaMailResourceMBean() throws MBeanException {
        super();
    }

    /**
     * Get the name of the factory.
     * @return name of the mail factory.
     */
    String getFactoryName() {
        return (String) ((JavaMailResource) this.resource).getFactoryName();
    }

    /**
     * Get the name of the factory.
     * @return name of the mail factory.
     */
    String getName() {
        return (String) ((JavaMailResource) this.resource).getName();
    }

    /**
     * Set the name of the factory.
     * @param name name of the mail factory.
     */
    void setName(String name) {
        ((JavaMailResource) this.resource).setName(name);
    }

    /**
     * Get the type of the factory.
     * @return type of the mail factory.
     */
    String getFactoryType() {
        return (String) ((JavaMailResource) this.resource).getFactoryType();
    }


    /**
     * Get the authentication properties.
     * @return properties of the authentication.
     */
    Properties getAuthenticationProperties() {
        return (Properties) ((JavaMailResource) this.resource).getAuthenticationProperties();
    }

    /**
     * Set the authentication properties.
     * @param props the authentication properties.
     */
    void setAuthenticationProperties(Properties props) {
        ((JavaMailResource) this.resource).setAuthenticationProperties(props);
    }

    /**
     * Get the session properties.
     * @return the properties of Session.
     */
    Properties getSessionProperties() {
        return (Properties) ((JavaMailResource) this.resource).getSessionProperties();
    }

    /**
     * Set the session properties.
     * @param props the Session properties.
     */
    void setSessionProperties(Properties props) {
        ((JavaMailResource) this.resource).setSessionProperties(props);
    }

    /**
     * Save updated configuration
     */
    void saveConfig() {
    	((JavaMailResource) this.resource).saveConfig();
    }

    /**
     * Add a new listener.
     * @param pListner Listener to notify
     * @param pFilter Notification filter
     * @param pHandback ??
     * @throws java.lang.IllegalArgumentException if notification is not done
     */
    public void addNotificationListener(NotificationListener pListner, NotificationFilter pFilter,
            java.lang.Object pHandback) throws java.lang.IllegalArgumentException {
        ((JavaMailResource) (this.resource)).addNotificationListener(pListner, pFilter, pHandback);
    }
}

