001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: * --------------------------------------------------------------------------
021: * $Id: J2EEModule.java 6505 2005-04-01 15:25:14Z danesa $
022: * --------------------------------------------------------------------------
023: */package org.objectweb.jonas.management.j2eemanagement;
024:
025: // JMX
026: import javax.management.AttributeNotFoundException;
027: import javax.management.InstanceNotFoundException;
028: import javax.management.MBeanException;
029: import javax.management.MBeanServer;
030: import javax.management.MBeanServerConnection;
031: import javax.management.MalformedObjectNameException;
032: import javax.management.ObjectName;
033: import javax.management.ReflectionException;
034:
035: import org.objectweb.jonas.jmx.J2eeObjectName;
036: import org.objectweb.jonas.jmx.ManagementReprFactory;
037:
038: /**
039: * A J2EE MBean module used on server (EJB container).
040: *
041: * @author Michel-Ange Anton
042: */
043: public class J2EEModule extends J2EEDeployedObject {
044:
045: // ------------------------------------------------------------- Private Constants
046:
047: // ------------------------------------------------------------- Privates Variables
048: private MBeanServerConnection localManagementRepr = ManagementReprFactory
049: .getLocalManagementRepr();
050:
051: // ------------------------------------------------------------- Properties
052:
053: // ------------------------------------------------------------- Contructors
054:
055: /**
056: * MBean constructor.
057: * @param p_ObjectName The object name of the deployed object
058: */
059: protected J2EEModule(String p_ObjectName) {
060: super (p_ObjectName);
061: }
062:
063: /**
064: * MBean constructor.
065: * @param p_ObjectName The object name of the module object
066: * @param p_StateManageable If true, this object implements J2EE State Management Model
067: * @param p_StatisticsProvider If true, this object implements the J2EE StatisticProvide Model
068: * @param p_EventProvider If true, this object implements the J2EE EventProvider Model
069: */
070: protected J2EEModule(String p_ObjectName,
071: boolean p_StateManageable, boolean p_StatisticsProvider,
072: boolean p_EventProvider) {
073: super (p_ObjectName, p_StateManageable, p_StatisticsProvider,
074: p_EventProvider);
075: }
076:
077: // ------------------------------------------------------------- Public Methods
078:
079: /**
080: * Return the JVM used by this J2EEModule.
081: * @return A array of strings of the object name of the JVMs.
082: */
083: public String[] getJavaVMs() {
084: String[] as = new String[0];
085: try {
086: ObjectName on = new ObjectName(getObjectName());
087: ObjectName onServer = J2eeObjectName.J2EEServer(on
088: .getDomain(), on.getKeyProperty(J2EE_TYPE_SERVER));
089: as = (String[]) ((MBeanServer) localManagementRepr)
090: .getAttribute(onServer, "javaVMs");
091: } catch (MalformedObjectNameException e) {
092: // none action
093: } catch (AttributeNotFoundException e) {
094: // TODO Auto-generated catch block
095: e.printStackTrace();
096: } catch (InstanceNotFoundException e) {
097: // TODO Auto-generated catch block
098: e.printStackTrace();
099: } catch (MBeanException e) {
100: // TODO Auto-generated catch block
101: e.printStackTrace();
102: } catch (ReflectionException e) {
103: // TODO Auto-generated catch block
104: e.printStackTrace();
105: }
106: return as;
107: }
108:
109: }
|