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 javax.management.MBeanServer;
27 import java.lang.management.*;
28 
29 public class ServerClassLoadingMXBean extends ServerMXBean implements ClassLoadingMXBean {
30         private static final String LOADED_CLASSES = "LoadedClassCount";
31         private static final String TOTAL_CLASSES = "TotalLoadedClassCount";
32         private static final String UNLOADED_CLASSES = "UnloadedClassCount";
33         private static final String VERBOSE = "Verbose";
34 
ServerClassLoadingMXBean(MBeanServer mbeanServer)35         public ServerClassLoadingMXBean(MBeanServer mbeanServer) {
36                 super(mbeanServer, ManagementFactory.CLASS_LOADING_MXBEAN_NAME);
37         }
38 
getLoadedClassCount()39         public int getLoadedClassCount() {
40                 return getIntAttribute(LOADED_CLASSES);
41         }
42 
getTotalLoadedClassCount()43         public long getTotalLoadedClassCount() {
44                 return getLongAttribute(TOTAL_CLASSES);
45         }
46 
getUnloadedClassCount()47         public long getUnloadedClassCount() {
48                 return getLongAttribute(UNLOADED_CLASSES);
49         }
50 
isVerbose()51         public boolean isVerbose() {
52                 return getBooleanAttribute(VERBOSE);
53         }
54 
setVerbose(boolean verbose)55         public void setVerbose(boolean verbose) {
56                 setBooleanAttribute(VERBOSE, verbose);
57         }
58 }
59