/**
 * JOnAS: Java(TM) Open Application Server
 * Copyright (C) 1999 Bull S.A.
 * Contact: jonas-team@ow2.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.ow2.jonas.lib.management.javaee;

import org.ow2.jonas.lib.reconfig.ReconfigEmitter;

/**
 * This class implements the J2EEManagedObject type specified in JSR77
 * @author Adriana Danes
 */
public class J2EEManagedObject extends ReconfigEmitter {

    // ------------------------------------------------------------- Private
    // Constants
    // the following strings represent key properties within
    // a J2EEManagedObject's objectName cf. JSR 77
    /**
     * Name constant
     */
    public static final String NAME = "name";

    /**
     * Constant for j2ee server
     */
    public static final String J2EE_TYPE_SERVER = "J2EEServer";

    /**
     * Constant for a j2ee application
     */
    public static final String J2EE_TYPE_APPLICATION = "J2EEApplication";

    // ------------------------------------------------------------- Properties

    /**
     * The managed object name
     */
    private String objectName;

    /**
     * State management support for this managed object (start, stop, ...)
     */
    private boolean stateManageable;

    /**
     * Performance statistics support for this managed object.
     */
    private boolean statisticsProvider;

    /**
     * Event provider support for this managed object.
     */
    private boolean eventProvider;

    // ------------------------------------------------------------- Contructors

    /**
     * MBean constructor
     * @param objectName The complete name of the managed object
     */
    protected J2EEManagedObject(String objectName) {
        this.objectName = objectName;
        this.stateManageable = false;
        this.statisticsProvider = false;
        this.eventProvider = false;
    }

    /**
     * MBean constructor
     * @param objectName object name of the managed object
     * @param stateManageable if true, this managed object implements J2EE State
     *        Management Model
     * @param statisticsProvider if true, this managed object implements the
     *        J2EE StatisticProvide Model
     * @param eventProvider if true, this managed object implements the J2EE
     *        EventProvider Model
     */
    protected J2EEManagedObject(String objectName, boolean stateManageable, boolean statisticsProvider,
            boolean eventProvider) {
        this.objectName = objectName;
        this.stateManageable = stateManageable;
        this.statisticsProvider = statisticsProvider;
        this.eventProvider = eventProvider;
    }

    // ------------------------------------------------------------- Properties
    // accessors

    /**
     * Return this MBean's name
     * @return The name of the MBean (see OBJECT_NAME in the JSR77)
     */
    public String getObjectName() {
        return objectName;
    }

    /**
     * @return true if it is an event provider
     */
    public boolean isEventProvider() {
        return eventProvider;
    }

    /**
     * @return true if this managed object implements J2EE State Management
     *         Model
     */
    public boolean isStateManageable() {
        return stateManageable;
    }

    /**
     * @return true if this managed object implements the J2EE StatisticProvider
     *         Model
     */
    public boolean isStatisticsProvider() {
        return statisticsProvider;
    }

}
