⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 moncreator.java

📁 mobile to system control
💻 JAVA
字号:
/* *   This file is part of MobiMon. * *   MobiMon is free software; you can redistribute it and/or modify *   it under the terms of the GNU General Public License as published by *   the Free Software Foundation; either version 2 of the License, or *   (at your option) any later version. * *   MobiMon is distributed in the hope that it will be useful, *   but WITHOUT ANY WARRANTY; without even the implied warranty of *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *   GNU General Public License for more details. *   You should have received a copy of the GNU General Public License *   along with MobiMon; if not, write to the Free Software *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA *//* * MonCreator.java * * Created on March 2, 2003, 7:37 PM */package mobimon.mbeans;import javax.management.*;import javax.management.monitor.*;/** * * @author  jan */public class MonCreator implements MonCreatorMBean, MBeanRegistration {        private MBeanServer server;        /** Creates a new instance of MonCreator */    public MonCreator() {    }        public void createStringMonitor(ObjectName mbean, String attribute,    long interval, String compareWith, boolean notifyDiffer,    boolean notifyMatch)    throws MalformedObjectNameException, InstantiationException,    InstanceAlreadyExistsException, MBeanRegistrationException,    NotCompliantMBeanException {        ObjectName newMonitorName = new ObjectName("Monitor:"        + mbean.getKeyPropertyListString() + ",attr=" + attribute);        StringMonitor smon = new StringMonitor();        smon.addObservedObject(mbean);        smon.setObservedAttribute(attribute);        if (interval > 0) smon.setGranularityPeriod(interval);        smon.setStringToCompare(compareWith);        smon.setNotifyMatch(notifyMatch);        smon.setNotifyDiffer(notifyDiffer);        server.registerMBean(smon, newMonitorName);        smon.start();    }        public ObjectName preRegister(MBeanServer server, ObjectName name)    throws java.lang.Exception {                if (name == null)            name = new ObjectName("MMAgent:name=MonCreator");                this.server = server;        return name;    }        public void postRegister(Boolean registrationDone) {    }        public void preDeregister() throws java.lang.Exception {    }        public void postDeregister() {    }        public void createCounterMonitor(ObjectName mbean, String attribute,    long interval, Number threshold, Number offset, Number modulus,    boolean differenceMode, boolean notify)    throws MalformedObjectNameException, InstantiationException,    InstanceAlreadyExistsException, MBeanRegistrationException,    NotCompliantMBeanException {        ObjectName newMonitorName = new ObjectName("Monitor:"        + mbean.getKeyPropertyListString() + ",attr=" + attribute);        CounterMonitor cmon = new CounterMonitor();        cmon.addObservedObject(mbean);        cmon.setObservedAttribute(attribute);        if (interval > 0) cmon.setGranularityPeriod(interval);        cmon.setInitThreshold(threshold);        cmon.setOffset(offset);        cmon.setModulus(modulus);        cmon.setDifferenceMode(differenceMode);        cmon.setNotify(notify);        server.registerMBean(cmon, newMonitorName);        cmon.start();    }        public void createGaugeMonitor(ObjectName mbean, String attribute,    long interval, Number high, Number low, boolean differenceMode,    boolean notifyHigh, boolean notifyLow)    throws MalformedObjectNameException, InstantiationException,    InstanceAlreadyExistsException, MBeanRegistrationException,    NotCompliantMBeanException {        ObjectName newMonitorName = new ObjectName("Monitor:"        + mbean.getKeyPropertyListString() + ",attr=" + attribute);        GaugeMonitor gmon = new GaugeMonitor();        gmon.addObservedObject(mbean);        gmon.setObservedAttribute(attribute);        if (interval > 0) gmon.setGranularityPeriod(interval);        gmon.setThresholds(high, low);        gmon.setDifferenceMode(differenceMode);        gmon.setNotifyHigh(notifyHigh);        gmon.setNotifyLow(notifyLow);        server.registerMBean(gmon, newMonitorName);        gmon.start();    }    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -