Source Code Cross Referenced for VMManagementImpl.java in  » 6.0-JDK-Modules-sun » management » sun » management » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules sun » management » sun.management 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2003-2006 Sun Microsystems, Inc.  All Rights Reserved.
003:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004:         *
005:         * This code is free software; you can redistribute it and/or modify it
006:         * under the terms of the GNU General Public License version 2 only, as
007:         * published by the Free Software Foundation.  Sun designates this
008:         * particular file as subject to the "Classpath" exception as provided
009:         * by Sun in the LICENSE file that accompanied this code.
010:         *
011:         * This code is distributed in the hope that it will be useful, but WITHOUT
012:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013:         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014:         * version 2 for more details (a copy is included in the LICENSE file that
015:         * accompanied this code).
016:         *
017:         * You should have received a copy of the GNU General Public License version
018:         * 2 along with this work; if not, write to the Free Software Foundation,
019:         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020:         *
021:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022:         * CA 95054 USA or visit www.sun.com if you need additional information or
023:         * have any questions.
024:         */
025:
026:        package sun.management;
027:
028:        import sun.misc.Perf;
029:        import sun.management.counter.*;
030:        import sun.management.counter.perf.*;
031:        import java.nio.ByteBuffer;
032:        import java.io.IOException;
033:        import java.net.InetAddress;
034:        import java.net.UnknownHostException;
035:        import java.util.List;
036:        import java.util.Arrays;
037:        import java.util.Collections;
038:        import java.security.AccessController;
039:        import java.security.PrivilegedAction;
040:        import sun.security.action.GetPropertyAction;
041:
042:        /**
043:         * Implementation of VMManagement interface that accesses the management 
044:         * attributes and operations locally within the same Java virtual
045:         * machine.
046:         */
047:        class VMManagementImpl implements  VMManagement {
048:
049:            private static String version;
050:
051:            private static boolean compTimeMonitoringSupport;
052:            private static boolean threadContentionMonitoringSupport;
053:            private static boolean currentThreadCpuTimeSupport;
054:            private static boolean otherThreadCpuTimeSupport;
055:            private static boolean bootClassPathSupport;
056:            private static boolean objectMonitorUsageSupport;
057:            private static boolean synchronizerUsageSupport;
058:
059:            static {
060:                version = getVersion0();
061:                if (version == null) {
062:                    throw new InternalError("Invalid Management Version");
063:                }
064:                initOptionalSupportFields();
065:            }
066:
067:            private native static String getVersion0();
068:
069:            private native static void initOptionalSupportFields();
070:
071:            // Optional supports
072:            public boolean isCompilationTimeMonitoringSupported() {
073:                return compTimeMonitoringSupport;
074:            }
075:
076:            public boolean isThreadContentionMonitoringSupported() {
077:                return threadContentionMonitoringSupport;
078:            }
079:
080:            public boolean isCurrentThreadCpuTimeSupported() {
081:                return currentThreadCpuTimeSupport;
082:            }
083:
084:            public boolean isOtherThreadCpuTimeSupported() {
085:                return otherThreadCpuTimeSupport;
086:            }
087:
088:            public boolean isBootClassPathSupported() {
089:                return bootClassPathSupport;
090:            }
091:
092:            public boolean isObjectMonitorUsageSupported() {
093:                return objectMonitorUsageSupport;
094:            }
095:
096:            public boolean isSynchronizerUsageSupported() {
097:                return synchronizerUsageSupport;
098:            }
099:
100:            public native boolean isThreadContentionMonitoringEnabled();
101:
102:            public native boolean isThreadCpuTimeEnabled();
103:
104:            // Class Loading Subsystem
105:            public int getLoadedClassCount() {
106:                long count = getTotalClassCount() - getUnloadedClassCount();
107:                return (int) count;
108:            }
109:
110:            public native long getTotalClassCount();
111:
112:            public native long getUnloadedClassCount();
113:
114:            public native boolean getVerboseClass();
115:
116:            // Memory Subsystem
117:            public native boolean getVerboseGC();
118:
119:            // Runtime Subsystem
120:            public String getManagementVersion() {
121:                return version;
122:            }
123:
124:            public String getVmId() {
125:                int pid = getProcessId();
126:                String hostname = "localhost";
127:                try {
128:                    hostname = InetAddress.getLocalHost().getHostName();
129:                } catch (UnknownHostException e) {
130:                    // ignore
131:                }
132:
133:                return pid + "@" + hostname;
134:            }
135:
136:            private native int getProcessId();
137:
138:            public String getVmName() {
139:                return System.getProperty("java.vm.name");
140:            }
141:
142:            public String getVmVendor() {
143:                return System.getProperty("java.vm.vendor");
144:            }
145:
146:            public String getVmVersion() {
147:                return System.getProperty("java.vm.version");
148:            }
149:
150:            public String getVmSpecName() {
151:                return System.getProperty("java.vm.specification.name");
152:            }
153:
154:            public String getVmSpecVendor() {
155:                return System.getProperty("java.vm.specification.vendor");
156:            }
157:
158:            public String getVmSpecVersion() {
159:                return System.getProperty("java.vm.specification.version");
160:            }
161:
162:            public String getClassPath() {
163:                return System.getProperty("java.class.path");
164:            }
165:
166:            public String getLibraryPath() {
167:                return System.getProperty("java.library.path");
168:            }
169:
170:            public String getBootClassPath() {
171:                PrivilegedAction<String> pa = new GetPropertyAction(
172:                        "sun.boot.class.path");
173:                String result = AccessController.doPrivileged(pa);
174:                return result;
175:            }
176:
177:            private List<String> vmArgs = null;
178:
179:            public synchronized List<String> getVmArguments() {
180:                if (vmArgs == null) {
181:                    String[] args = getVmArguments0();
182:                    List<String> l = ((args != null && args.length != 0) ? Arrays
183:                            .asList(args)
184:                            : Collections.<String> emptyList());
185:                    vmArgs = Collections.unmodifiableList(l);
186:                }
187:                return vmArgs;
188:            }
189:
190:            public native String[] getVmArguments0();
191:
192:            public native long getStartupTime();
193:
194:            public native int getAvailableProcessors();
195:
196:            // Compilation Subsystem
197:            public String getCompilerName() {
198:                String name = AccessController
199:                        .doPrivileged(new PrivilegedAction<String>() {
200:                            public String run() {
201:                                return System
202:                                        .getProperty("sun.management.compiler");
203:                            }
204:                        });
205:                return name;
206:            }
207:
208:            public native long getTotalCompileTime();
209:
210:            // Thread Subsystem
211:            public native long getTotalThreadCount();
212:
213:            public native int getLiveThreadCount();
214:
215:            public native int getPeakThreadCount();
216:
217:            public native int getDaemonThreadCount();
218:
219:            // Operating System
220:            public String getOsName() {
221:                return System.getProperty("os.name");
222:            }
223:
224:            public String getOsArch() {
225:                return System.getProperty("os.arch");
226:            }
227:
228:            public String getOsVersion() {
229:                return System.getProperty("os.version");
230:            }
231:
232:            // Hotspot-specific runtime support
233:            public native long getSafepointCount();
234:
235:            public native long getTotalSafepointTime();
236:
237:            public native long getSafepointSyncTime();
238:
239:            public native long getTotalApplicationNonStoppedTime();
240:
241:            public native long getLoadedClassSize();
242:
243:            public native long getUnloadedClassSize();
244:
245:            public native long getClassLoadingTime();
246:
247:            public native long getMethodDataSize();
248:
249:            public native long getInitializedClassCount();
250:
251:            public native long getClassInitializationTime();
252:
253:            public native long getClassVerificationTime();
254:
255:            // Performance Counter Support
256:            private PerfInstrumentation perfInstr = null;
257:            private boolean noPerfData = false;
258:
259:            private synchronized PerfInstrumentation getPerfInstrumentation() {
260:                if (noPerfData || perfInstr != null) {
261:                    return perfInstr;
262:                }
263:
264:                // construct PerfInstrumentation object 
265:                Perf perf = AccessController
266:                        .doPrivileged(new Perf.GetPerfAction());
267:                try {
268:                    ByteBuffer bb = perf.attach(0, "r");
269:                    if (bb.capacity() == 0) {
270:                        noPerfData = true;
271:                        return null;
272:                    }
273:                    perfInstr = new PerfInstrumentation(bb);
274:                } catch (IllegalArgumentException e) {
275:                    // If the shared memory doesn't exist e.g. if -XX:-UsePerfData 
276:                    // was set
277:                    noPerfData = true;
278:                } catch (IOException e) {
279:                    throw new InternalError(e.getMessage());
280:                }
281:                return perfInstr;
282:            }
283:
284:            public List<Counter> getInternalCounters(String pattern) {
285:                PerfInstrumentation perf = getPerfInstrumentation();
286:                if (perf != null) {
287:                    return perf.findByPattern(pattern);
288:                } else {
289:                    return Collections.emptyList();
290:                }
291:            }
292:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.