KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > management > j2ee > JVM


1 /*
2  * JBoss, Home of Professional Open Source
3  * Copyright 2005, JBoss Inc., and individual contributors as indicated
4  * by the @authors tag. See the copyright.txt in the distribution for a
5  * full listing of individual contributors.
6  *
7  * This is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation; either version 2.1 of
10  * the License, or (at your option) any later version.
11  *
12  * This software is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this software; if not, write to the Free
19  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21  */

22 package org.jboss.management.j2ee;
23
24 import org.jboss.management.j2ee.statistics.JVMStatsImpl;
25
26 import javax.management.MalformedObjectNameException JavaDoc;
27 import javax.management.ObjectName JavaDoc;
28 import javax.management.j2ee.statistics.Stats JavaDoc;
29 import java.util.Hashtable JavaDoc;
30
31 /**
32  * The JBoss JSR-77.3.4 JVM model implementation
33  *
34  * @author <a HREF="mailto:andreas@jboss.org">Andreas Schaefer</a>
35  * @author <a HREF="mailto:scott.stark@jboss.org">Scott Stark</a>
36  * @author <a HREF="mailto:thomas.diesler@jboss.org">Thomas Diesler</a>
37  * @version $Revision: 40550 $
38  */

39 public class JVM extends J2EEManagedObject
40    implements JVMMBean
41 {
42    // Constants -----------------------------------------------------
43

44    // Attributes ----------------------------------------------------
45

46    private String JavaDoc javaVendor;
47    private String JavaDoc javaVersion;
48    private String JavaDoc node;
49    private JVMStatsImpl stats;
50
51    // Static --------------------------------------------------------
52

53    // Constructors --------------------------------------------------
54

55    /**
56     */

57    public JVM(String JavaDoc name, ObjectName JavaDoc j2eeServer, String JavaDoc javaVersion,
58               String JavaDoc javaVendor, String JavaDoc node)
59            throws MalformedObjectNameException JavaDoc,
60            InvalidParentException
61    {
62       super(J2EETypeConstants.JVM, name, j2eeServer);
63       this.javaVendor = javaVendor;
64       this.javaVersion = javaVersion;
65       this.node = node;
66       this.stats = new JVMStatsImpl();
67    }
68
69    // Public --------------------------------------------------------
70

71    /**
72     * @jmx:managed-attribute
73     */

74    public String JavaDoc getjavaVendor()
75    {
76       return javaVendor;
77    }
78
79    /**
80     * @jmx:managed-attribute
81     */

82    public String JavaDoc getjavaVersion()
83    {
84       return javaVersion;
85    }
86
87    /**
88     * @jmx:managed-attribute
89     */

90    public String JavaDoc getnode()
91    {
92       return node;
93    }
94
95    // Begin StatisticsProvider interface methods
96
/**
97     * Obtain the Stats from the StatisticsProvider
98     *
99     * @return
100     * @jmx:managed-attribute
101     */

102    public Stats JavaDoc getstats()
103    {
104       // Refresh the stats
105
stats.getUpTime();
106       stats.getHeapSize();
107       return stats;
108    }
109
110    /**
111     * Reset all statistics in the StatisticsProvider
112     *
113     * @jmx:managed-operation
114     */

115    public void resetStats()
116    {
117       stats.reset();
118    }
119    // End StatisticsProvider interface methods
120

121    // java.lang.Object overrides ------------------------------------
122

123    public String JavaDoc toString()
124    {
125       StringBuffer JavaDoc tmp = new StringBuffer JavaDoc("JVM");
126       tmp.append('[');
127       tmp.append("JavaVendor: ");
128       tmp.append(javaVendor);
129       tmp.append(", JavaVersion: ");
130       tmp.append(javaVersion);
131       tmp.append(", JavaVersion: ");
132       tmp.append(javaVendor);
133       tmp.append(", Stats: ");
134       tmp.append(stats);
135       tmp.append(']');
136       return tmp.toString();
137    }
138
139    // Protected -----------------------------------------------------
140

141    /**
142     * @return A hashtable with the J2EE Server as parent
143     */

144    protected Hashtable JavaDoc getParentKeys(ObjectName JavaDoc pParent)
145    {
146       Hashtable JavaDoc lReturn = new Hashtable JavaDoc();
147       Hashtable JavaDoc lProperties = pParent.getKeyPropertyList();
148       lReturn.put(J2EETypeConstants.J2EEServer, lProperties.get("name"));
149
150       return lReturn;
151    }
152
153 }
154
Popular Tags