KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > management > j2eemanagement > J2EEModule


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  * --------------------------------------------------------------------------
21  * $Id: J2EEModule.java,v 1.3 2005/04/01 15:25:14 danesa Exp $
22  * --------------------------------------------------------------------------
23  */

24
25 package org.objectweb.jonas.management.j2eemanagement;
26
27 // JMX
28
import javax.management.AttributeNotFoundException JavaDoc;
29 import javax.management.InstanceNotFoundException JavaDoc;
30 import javax.management.MBeanException JavaDoc;
31 import javax.management.MBeanServer JavaDoc;
32 import javax.management.MBeanServerConnection JavaDoc;
33 import javax.management.MalformedObjectNameException JavaDoc;
34 import javax.management.ObjectName JavaDoc;
35 import javax.management.ReflectionException JavaDoc;
36
37 import org.objectweb.jonas.jmx.J2eeObjectName;
38 import org.objectweb.jonas.jmx.ManagementReprFactory;
39
40 /**
41  * A J2EE MBean module used on server (EJB container).
42  *
43  * @author Michel-Ange Anton
44  */

45 public class J2EEModule extends J2EEDeployedObject {
46
47 // ------------------------------------------------------------- Private Constants
48

49 // ------------------------------------------------------------- Privates Variables
50
private MBeanServerConnection JavaDoc localManagementRepr = ManagementReprFactory.getLocalManagementRepr();
51 // ------------------------------------------------------------- Properties
52

53 // ------------------------------------------------------------- Contructors
54

55     /**
56      * MBean constructor.
57      * @param p_ObjectName The object name of the deployed object
58      */

59     protected J2EEModule(String JavaDoc p_ObjectName) {
60         super(p_ObjectName);
61     }
62
63     /**
64      * MBean constructor.
65      * @param p_ObjectName The object name of the module object
66      * @param p_StateManageable If true, this object implements J2EE State Management Model
67      * @param p_StatisticsProvider If true, this object implements the J2EE StatisticProvide Model
68      * @param p_EventProvider If true, this object implements the J2EE EventProvider Model
69      */

70     protected J2EEModule(String JavaDoc p_ObjectName, boolean p_StateManageable
71         , boolean p_StatisticsProvider, boolean p_EventProvider) {
72         super(p_ObjectName, p_StateManageable, p_StatisticsProvider, p_EventProvider);
73     }
74
75 // ------------------------------------------------------------- Public Methods
76

77     /**
78      * Return the JVM used by this J2EEModule.
79      * @return A array of strings of the object name of the JVMs.
80      */

81     public String JavaDoc[] getJavaVMs() {
82         String JavaDoc[] as = new String JavaDoc[0];
83         try {
84             ObjectName JavaDoc on = new ObjectName JavaDoc(getObjectName());
85             ObjectName JavaDoc onServer = J2eeObjectName.J2EEServer(on.getDomain()
86                 , on.getKeyProperty(J2EE_TYPE_SERVER));
87             as = (String JavaDoc[]) ((MBeanServer JavaDoc) localManagementRepr).getAttribute(onServer, "javaVMs");
88         }
89         catch (MalformedObjectNameException JavaDoc e) {
90             // none action
91
} catch (AttributeNotFoundException JavaDoc e) {
92             // TODO Auto-generated catch block
93
e.printStackTrace();
94         } catch (InstanceNotFoundException JavaDoc e) {
95             // TODO Auto-generated catch block
96
e.printStackTrace();
97         } catch (MBeanException JavaDoc e) {
98             // TODO Auto-generated catch block
99
e.printStackTrace();
100         } catch (ReflectionException JavaDoc e) {
101             // TODO Auto-generated catch block
102
e.printStackTrace();
103         }
104         return as;
105     }
106
107 }
108
Popular Tags