0N/A/*
2362N/A * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/Apackage sun.management.snmp.jvminstr;
0N/A
0N/A// java imports
0N/A//
0N/Aimport java.io.Serializable;
0N/A
0N/Aimport java.lang.management.ClassLoadingMXBean;
0N/Aimport java.lang.management.ManagementFactory;
0N/A// jmx imports
0N/A//
0N/Aimport javax.management.MBeanServer;
0N/Aimport com.sun.jmx.snmp.SnmpString;
0N/Aimport com.sun.jmx.snmp.SnmpStatusException;
0N/A
0N/A// jdmk imports
0N/A//
0N/Aimport com.sun.jmx.snmp.agent.SnmpMib;
0N/A
0N/Aimport sun.management.snmp.jvmmib.JvmClassLoadingMBean;
0N/Aimport sun.management.snmp.jvmmib.EnumJvmClassesVerboseLevel;
0N/Aimport sun.management.snmp.util.MibLogger;
0N/A
0N/A/**
0N/A * The class is used for implementing the "JvmClassLoading" group.
0N/A */
0N/Apublic class JvmClassLoadingImpl implements JvmClassLoadingMBean {
0N/A
0N/A /**
0N/A * Variable for storing the value of "JvmClassesVerboseLevel".
0N/A *
0N/A * "verbose: if the -verbose:class flag is set.
0N/A * silent: otherwise.
0N/A *
0N/A * See java.management.ClassLoadingMXBean.isVerbose(),
0N/A * java.management.ClassLoadingMXBean.setVerbose()
0N/A * "
0N/A *
0N/A */
0N/A static final EnumJvmClassesVerboseLevel JvmClassesVerboseLevelVerbose =
0N/A new EnumJvmClassesVerboseLevel("verbose");
0N/A static final EnumJvmClassesVerboseLevel JvmClassesVerboseLevelSilent =
0N/A new EnumJvmClassesVerboseLevel("silent");
0N/A
0N/A /**
0N/A * Constructor for the "JvmClassLoading" group.
0N/A * If the group contains a table, the entries created through an
0N/A * SNMP SET will not be registered in Java DMK.
0N/A */
0N/A public JvmClassLoadingImpl(SnmpMib myMib) {
0N/A }
0N/A
0N/A /**
0N/A * Constructor for the "JvmClassLoading" group.
0N/A * If the group contains a table, the entries created through an SNMP SET
0N/A * will be AUTOMATICALLY REGISTERED in Java DMK.
0N/A */
0N/A public JvmClassLoadingImpl(SnmpMib myMib, MBeanServer server) {
0N/A }
0N/A
0N/A static ClassLoadingMXBean getClassLoadingMXBean() {
0N/A return ManagementFactory.getClassLoadingMXBean();
0N/A }
0N/A
0N/A /**
0N/A * Getter for the "JvmClassesVerboseLevel" variable.
0N/A */
0N/A public EnumJvmClassesVerboseLevel getJvmClassesVerboseLevel()
0N/A throws SnmpStatusException {
0N/A if(getClassLoadingMXBean().isVerbose())
0N/A return JvmClassesVerboseLevelVerbose;
0N/A else
0N/A return JvmClassesVerboseLevelSilent;
0N/A }
0N/A
0N/A /**
0N/A * Setter for the "JvmClassesVerboseLevel" variable.
0N/A */
0N/A public void setJvmClassesVerboseLevel(EnumJvmClassesVerboseLevel x)
0N/A throws SnmpStatusException {
0N/A final boolean verbose;
0N/A if (JvmClassesVerboseLevelVerbose.equals(x)) verbose=true;
0N/A else if (JvmClassesVerboseLevelSilent.equals(x)) verbose=false;
0N/A // Should never happen, this case is handled by
0N/A // checkJvmClassesVerboseLevel();
0N/A else throw new
0N/A SnmpStatusException(SnmpStatusException.snmpRspWrongValue);
0N/A getClassLoadingMXBean().setVerbose(verbose);
0N/A }
0N/A
0N/A /**
0N/A * Checker for the "JvmClassesVerboseLevel" variable.
0N/A */
0N/A public void checkJvmClassesVerboseLevel(EnumJvmClassesVerboseLevel x)
0N/A throws SnmpStatusException {
0N/A //
0N/A // Add your own checking policy.
0N/A //
0N/A if (JvmClassesVerboseLevelVerbose.equals(x)) return;
0N/A if (JvmClassesVerboseLevelSilent.equals(x)) return;
0N/A throw new SnmpStatusException(SnmpStatusException.snmpRspWrongValue);
0N/A
0N/A }
0N/A
0N/A /**
0N/A * Getter for the "JvmClassesUnloadedCount" variable.
0N/A */
0N/A public Long getJvmClassesUnloadedCount() throws SnmpStatusException {
0N/A return new Long(getClassLoadingMXBean().getUnloadedClassCount());
0N/A }
0N/A
0N/A /**
0N/A * Getter for the "JvmClassesTotalLoadedCount" variable.
0N/A */
0N/A public Long getJvmClassesTotalLoadedCount() throws SnmpStatusException {
0N/A return new Long(getClassLoadingMXBean().getTotalLoadedClassCount());
0N/A }
0N/A
0N/A /**
0N/A * Getter for the "JvmClassesLoadedCount" variable.
0N/A */
0N/A public Long getJvmClassesLoadedCount() throws SnmpStatusException {
0N/A return new Long(getClassLoadingMXBean().getLoadedClassCount());
0N/A }
0N/A
0N/A}