Source Code Cross Referenced for RuntimeMXBeanImpl.java in  » Apache-Harmony-Java-SE » org-package » org » apache » harmony » lang » 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 » Apache Harmony Java SE » org package » org.apache.harmony.lang.management 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:
018:        package org.apache.harmony.lang.management;
019:
020:        import java.lang.management.ManagementPermission;
021:        import java.lang.management.RuntimeMXBean;
022:        import java.security.AccessController;
023:        import java.security.PrivilegedAction;
024:        import java.util.ArrayList;
025:        import java.util.Enumeration;
026:        import java.util.HashMap;
027:        import java.util.List;
028:        import java.util.Map;
029:        import java.util.Properties;
030:
031:        /**
032:         * Runtime type for {@link java.lang.management.RuntimeMXBean}
033:         * 
034:         * @since 1.5
035:         */
036:        public final class RuntimeMXBeanImpl extends DynamicMXBeanImpl
037:                implements  RuntimeMXBean {
038:
039:            private static RuntimeMXBeanImpl instance = new RuntimeMXBeanImpl();
040:
041:            /**
042:             * Constructor intentionally private to prevent instantiation by others.
043:             * Sets the metadata for this bean.
044:             */
045:            private RuntimeMXBeanImpl() {
046:                setMBeanInfo(ManagementUtils.getMBeanInfo(RuntimeMXBean.class
047:                        .getName()));
048:            }
049:
050:            /**
051:             * Singleton accessor method.
052:             * 
053:             * @return the <code>RuntimeMXBeanImpl</code> singleton.
054:             */
055:            static RuntimeMXBeanImpl getInstance() {
056:                return instance;
057:            }
058:
059:            /*
060:             * (non-Javadoc)
061:             * 
062:             * @see java.lang.management.RuntimeMXBean#getBootClassPath()
063:             */
064:            public String getBootClassPath() {
065:                if (!isBootClassPathSupported()) {
066:                    throw new UnsupportedOperationException(
067:                            "VM does not support boot classpath.");
068:                }
069:
070:                SecurityManager security = System.getSecurityManager();
071:                if (security != null) {
072:                    security
073:                            .checkPermission(new ManagementPermission("monitor"));
074:                }
075:
076:                return AccessController
077:                        .doPrivileged(new PrivilegedAction<String>() {
078:                            public String run() {
079:                                return System
080:                                        .getProperty("sun.boot.class.path");
081:                            }// end method run
082:                        });
083:            }
084:
085:            /*
086:             * (non-Javadoc)
087:             * 
088:             * @see java.lang.management.RuntimeMXBean#getClassPath()
089:             */
090:            public String getClassPath() {
091:                return System.getProperty("java.class.path");
092:            }
093:
094:            /*
095:             * (non-Javadoc)
096:             * 
097:             * @see java.lang.management.RuntimeMXBean#getLibraryPath()
098:             */
099:            public String getLibraryPath() {
100:                return System.getProperty("java.library.path");
101:            }
102:
103:            /*
104:             * (non-Javadoc)
105:             * 
106:             * @see java.lang.management.RuntimeMXBean#getManagementSpecVersion()
107:             */
108:            public String getManagementSpecVersion() {
109:                return "1.0";
110:            }
111:
112:            /**
113:             * @return the name of this running virtual machine.
114:             * @see #getName()
115:             */
116:            private native String getNameImpl();
117:
118:            /*
119:             * (non-Javadoc)
120:             * 
121:             * @see java.lang.management.RuntimeMXBean#getName()
122:             */
123:            public String getName() {
124:                return this .getNameImpl();
125:            }
126:
127:            /*
128:             * (non-Javadoc)
129:             * 
130:             * @see java.lang.management.RuntimeMXBean#getSpecName()
131:             */
132:            public String getSpecName() {
133:                return System.getProperty("java.vm.specification.name");
134:            }
135:
136:            /*
137:             * (non-Javadoc)
138:             * 
139:             * @see java.lang.management.RuntimeMXBean#getSpecVendor()
140:             */
141:            public String getSpecVendor() {
142:                return System.getProperty("java.vm.specification.vendor");
143:            }
144:
145:            /*
146:             * (non-Javadoc)
147:             * 
148:             * @see java.lang.management.RuntimeMXBean#getSpecVersion()
149:             */
150:            public String getSpecVersion() {
151:                return System.getProperty("java.vm.specification.version");
152:            }
153:
154:            /**
155:             * @return the virtual machine start time in milliseconds.
156:             * @see #getStartTime()
157:             */
158:            private native long getStartTimeImpl();
159:
160:            /*
161:             * (non-Javadoc)
162:             * 
163:             * @see java.lang.management.RuntimeMXBean#getStartTime()
164:             */
165:            public long getStartTime() {
166:                return this .getStartTimeImpl();
167:            }
168:
169:            /**
170:             * @return the number of milliseconds the virtual machine has been running.
171:             * @see #getUptime()
172:             */
173:            private native long getUptimeImpl();
174:
175:            /*
176:             * (non-Javadoc)
177:             * 
178:             * @see java.lang.management.RuntimeMXBean#getUptime()
179:             */
180:            public long getUptime() {
181:                return this .getUptimeImpl();
182:            }
183:
184:            /*
185:             * (non-Javadoc)
186:             * 
187:             * @see java.lang.management.RuntimeMXBean#getVmName()
188:             */
189:            public String getVmName() {
190:                return System.getProperty("java.vm.name");
191:            }
192:
193:            /*
194:             * (non-Javadoc)
195:             * 
196:             * @see java.lang.management.RuntimeMXBean#getVmVendor()
197:             */
198:            public String getVmVendor() {
199:                return System.getProperty("java.vm.vendor");
200:            }
201:
202:            /*
203:             * (non-Javadoc)
204:             * 
205:             * @see java.lang.management.RuntimeMXBean#getVmVersion()
206:             */
207:            public String getVmVersion() {
208:                return System.getProperty("java.vm.version");
209:            }
210:
211:            /**
212:             * @return <code>true</code> if supported, <code>false</code> otherwise.
213:             * @see #isBootClassPathSupported()
214:             */
215:            private native boolean isBootClassPathSupportedImpl();
216:
217:            /*
218:             * (non-Javadoc)
219:             * 
220:             * @see java.lang.management.RuntimeMXBean#isBootClassPathSupported()
221:             */
222:            public boolean isBootClassPathSupported() {
223:                return this .isBootClassPathSupportedImpl();
224:            }
225:
226:            /*
227:             * (non-Javadoc)
228:             * 
229:             * @see java.lang.management.RuntimeMXBean#getInputArguments()
230:             */
231:            public List<String> getInputArguments() {
232:                SecurityManager security = System.getSecurityManager();
233:                if (security != null) {
234:                    security
235:                            .checkPermission(new ManagementPermission("monitor"));
236:                }
237:
238:                // TODO : Retrieve the input args from the VM
239:                return new ArrayList<String>();
240:            }
241:
242:            /*
243:             * (non-Javadoc)
244:             * 
245:             * @see java.lang.management.RuntimeMXBean#getSystemProperties()
246:             */
247:            public Map<String, String> getSystemProperties() {
248:                Map<String, String> result = new HashMap<String, String>();
249:                Properties props = System.getProperties();
250:                Enumeration<?> propNames = props.propertyNames();
251:                while (propNames.hasMoreElements()) {
252:                    String propName = (String) propNames.nextElement();
253:                    String propValue = props.getProperty(propName);
254:                    result.put(propName, propValue);
255:                }// end while
256:                return result;
257:            }
258:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.