0N/A/*
2362N/A * Copyright (c) 2003, 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
0N/A * published by the Free Software Foundation.
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/A
0N/A/*
0N/A * build @BUILD_TAG_PLACEHOLDER@
0N/A *
0N/A * @COPYRIGHT_MINI_LEGAL_NOTICE_PLACEHOLDER@
0N/A */
0N/A
0N/A/**
0N/A * Simple definition of a standard MBean, named "SimpleStandard".
0N/A *
0N/A * The "SimpleStandard" standard MBean shows how to expose attributes
0N/A * and operations for management by implementing its corresponding
0N/A * "SimpleStandardMBean" management interface.
0N/A *
0N/A * This MBean has two attributes and one operation exposed
0N/A * for management by a JMX agent:
0N/A * - the read/write "State" attribute,
0N/A * - the read only "NbChanges" attribute,
0N/A * - the "reset()" operation.
0N/A *
0N/A * This object also has one property and one method not exposed
0N/A * for management by a JMX agent:
0N/A * - the "NbResets" property,
0N/A * - the "getNbResets()" method.
0N/A */
0N/A
0N/Aimport javax.management.AttributeChangeNotification;
0N/Aimport javax.management.NotificationBroadcasterSupport;
0N/A
0N/Apublic class SimpleStandard
0N/A extends NotificationBroadcasterSupport
0N/A implements SimpleStandardMBean {
0N/A
0N/A /*
0N/A * -----------------------------------------------------
0N/A * CONSTRUCTORS
0N/A * -----------------------------------------------------
0N/A */
0N/A
0N/A /* "SimpleStandard" does not provide any specific constructors.
0N/A * However, "SimpleStandard" is JMX compliant with regards to
0N/A * contructors because the default contructor SimpleStandard()
0N/A * provided by the Java compiler is public.
0N/A */
0N/A
0N/A /*
0N/A * -----------------------------------------------------
0N/A * IMPLEMENTATION OF THE SimpleStandardMBean INTERFACE
0N/A * -----------------------------------------------------
0N/A */
0N/A
0N/A /**
0N/A * Getter: get the "State" attribute of the "SimpleStandard" standard MBean.
0N/A *
0N/A * @return the current value of the "State" attribute.
0N/A */
0N/A public String getState() {
0N/A return state;
0N/A }
0N/A
0N/A /**
0N/A * Setter: set the "State" attribute of the "SimpleStandard" standard MBean.
0N/A *
0N/A * @param s</VAR> the new value of the "State" attribute.
0N/A */
0N/A public void setState(String s) {
0N/A state = s;
0N/A nbChanges++;
0N/A }
0N/A
0N/A /**
0N/A * Getter: get the "NbChanges" attribute of the "SimpleStandard" standard
0N/A * MBean.
0N/A *
0N/A * @return the current value of the "NbChanges" attribute.
0N/A */
0N/A public int getNbChanges() {
0N/A return nbChanges;
0N/A }
0N/A
0N/A /**
0N/A * Operation: reset to their initial values the "State" and "NbChanges"
0N/A * attributes of the "SimpleStandard" standard MBean.
0N/A */
0N/A public void reset() {
0N/A AttributeChangeNotification acn =
0N/A new AttributeChangeNotification(this,
0N/A 0,
0N/A 0,
0N/A "NbChanges reset",
0N/A "NbChanges",
0N/A "Integer",
0N/A new Integer(nbChanges),
0N/A new Integer(0));
0N/A state = "initial state";
0N/A nbChanges = 0;
0N/A nbResets++;
0N/A sendNotification(acn);
0N/A }
0N/A
0N/A /*
0N/A * -----------------------------------------------------
0N/A * METHOD NOT EXPOSED FOR MANAGEMENT BY A JMX AGENT
0N/A * -----------------------------------------------------
0N/A */
0N/A
0N/A /**
0N/A * Return the "NbResets" property.
0N/A * This method is not a Getter in the JMX sense because it
0N/A * is not exposed in the "SimpleStandardMBean" interface.
0N/A *
0N/A * @return the current value of the "NbResets" property.
0N/A */
0N/A public int getNbResets() {
0N/A return nbResets;
0N/A }
0N/A
0N/A /*
0N/A * -----------------------------------------------------
0N/A * ATTRIBUTES ACCESSIBLE FOR MANAGEMENT BY A JMX AGENT
0N/A * -----------------------------------------------------
0N/A */
0N/A
0N/A private String state = "initial state";
0N/A private int nbChanges = 0;
0N/A
0N/A /*
0N/A * -----------------------------------------------------
0N/A * PROPERTY NOT ACCESSIBLE FOR MANAGEMENT BY A JMX AGENT
0N/A * -----------------------------------------------------
0N/A */
0N/A
0N/A private int nbResets = 0;
0N/A}