1 /*
2  * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * This code is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 only, as
7  * published by the Free Software Foundation.
8  *
9  * This code is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12  * version 2 for more details (a copy is included in the LICENSE file that
13  * accompanied this code).
14  *
15  * You should have received a copy of the GNU General Public License version
16  * 2 along with this work; if not, write to the Free Software Foundation,
17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18  *
19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20  * or visit www.oracle.com if you need additional information or have any
21  * questions.
22  */
23 
24 package nsk.monitoring.share.server;
25 
26 import java.util.*;
27 import javax.management.MBeanServer;
28 import java.lang.management.*;
29 
30 public class ServerRuntimeMXBean extends ServerMXBean implements RuntimeMXBean {
31         private static final String BOOT_CLASSPATH= "BootClassPath";
32         private static final String CLASSPATH= "ClassPath";
33         private static final String INPUT_ARGUMENTS = "InputArguments";
34         private static final String LIBRARY_PATH = "LibraryPath";
35         private static final String MANAGEMENT_SPEC_VERSION = "ManagementSpecVersion";
36         private static final String NAME = "Name";
37         private static final String SPEC_NAME = "SpecName";
38         private static final String SPEC_VENDOR = "SpecVendor";
39         private static final String SPEC_VERSION = "SpecVersion";
40         private static final String START_TIME = "StartTime";
41         private static final String UPTIME = "Uptime";
42         private static final String VM_NAME = "VmName";
43         private static final String VM_VENDOR = "VmVendor";
44         private static final String VM_VERSION = "VmVersion";
45         private static final String BOOT_CLASSPATH_SUPPORTED = "BootClassPathSupported";
46 
ServerRuntimeMXBean(MBeanServer mbeanServer)47         public ServerRuntimeMXBean(MBeanServer mbeanServer) {
48                 super(mbeanServer, ManagementFactory.RUNTIME_MXBEAN_NAME);
49         }
50 
getBootClassPath()51         public String getBootClassPath() {
52                 return getStringAttribute(BOOT_CLASSPATH);
53         }
54 
getClassPath()55         public String getClassPath() {
56                 return getStringAttribute(CLASSPATH);
57         }
58 
getInputArguments()59         public List<String> getInputArguments() {
60                 throw new UnsupportedOperationException("TODO");
61         }
62 
getLibraryPath()63         public String getLibraryPath() {
64                 return getStringAttribute(LIBRARY_PATH);
65         }
66 
getManagementSpecVersion()67         public String getManagementSpecVersion() {
68                 return getStringAttribute(MANAGEMENT_SPEC_VERSION);
69         }
70 
getName()71         public String getName() {
72                 return getStringAttribute(NAME);
73         }
74 
getSpecName()75         public String getSpecName() {
76                 return getStringAttribute(SPEC_NAME);
77         }
78 
getSpecVendor()79         public String getSpecVendor() {
80                 return getStringAttribute(SPEC_VENDOR);
81         }
82 
getSpecVersion()83         public String getSpecVersion() {
84                 return getStringAttribute(SPEC_VERSION);
85         }
86 
getStartTime()87         public long getStartTime() {
88                 return getLongAttribute(START_TIME);
89         }
90 
getSystemProperties()91         public Map<String, String> getSystemProperties() {
92                 throw new UnsupportedOperationException("TODO");
93         }
94 
getUptime()95         public long getUptime() {
96                 return getLongAttribute(UPTIME);
97         }
98 
getVmName()99         public String getVmName() {
100                 return getStringAttribute(VM_NAME);
101         }
102 
getVmVendor()103         public String getVmVendor() {
104                 return getStringAttribute(VM_VENDOR);
105         }
106 
getVmVersion()107         public String getVmVersion() {
108                 return getStringAttribute(VM_VERSION);
109         }
110 
isBootClassPathSupported()111         public boolean isBootClassPathSupported() {
112                 return getBooleanAttribute(BOOT_CLASSPATH_SUPPORTED);
113         }
114 }
115