/**
 * 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;

// JMX
import javax.management.ObjectName;
import javax.management.MalformedObjectNameException;


// JOnAS JMX

/**
 * A J2EE MBean deployed on server.
 *
 * @author Michel-Ange Anton
 */
public class J2EEDeployedObject extends J2EEManagedObject {


// ------------------------------------------------------------- Privates Variables

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

    /**
     * J2EE Deployment descriptor.
     */
    private String deploymentDescriptor = null;

    /**
     * Specific JOnAS Deployment descriptor.
     */
    private String jonasDeploymentDescriptor = null;


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

    /**
     * MBean constructor.
     * @param p_ObjectName The object name of the deployed object
     */
    protected J2EEDeployedObject(String p_ObjectName) {
        super(p_ObjectName);
    }

    /**
     * MBean constructor.
     * @param p_ObjectName The object name of the managed object
     * @param p_StateManageable If true, this object implements J2EE State Management Model
     * @param p_StatisticsProvider If true, this object implements the J2EE StatisticProvide Model
     * @param p_EventProvider If true, this object implements the J2EE EventProvider Model
     */
    protected J2EEDeployedObject(String p_ObjectName, boolean p_StateManageable
        , boolean p_StatisticsProvider, boolean p_EventProvider) {
        super(p_ObjectName, p_StateManageable, p_StatisticsProvider, p_EventProvider);
    }

// ------------------------------------------------------------- Properties Methods

    public String getDeploymentDescriptor() {
        return deploymentDescriptor;
    }

    public void setDeploymentDescriptor(String deploymentDescriptor) {
        this.deploymentDescriptor = deploymentDescriptor;
    }

    public String getJonasDeploymentDescriptor() {
        return jonasDeploymentDescriptor;
    }

    public void setJonasDeploymentDescriptor(String jonasDeploymentDescriptor) {
        this.jonasDeploymentDescriptor = jonasDeploymentDescriptor;
    }

// ------------------------------------------------------------- Public Methods

    public String getServer() {
        String s = null;
        try {
            ObjectName on = new ObjectName(getObjectName());
            s = J2eeObjectName.J2EEServer(on.getDomain()
                , on.getKeyProperty(J2EE_TYPE_SERVER)).toString();
        }
        catch (MalformedObjectNameException e) {
            // none action
        }
        return s;
    }
}
