Example usage for javax.management.monitor GaugeMonitor addObservedObject

List of usage examples for javax.management.monitor GaugeMonitor addObservedObject

Introduction

In this page you can find the example usage for javax.management.monitor GaugeMonitor addObservedObject.

Prototype

public synchronized void addObservedObject(ObjectName object) throws IllegalArgumentException 

Source Link

Document

Adds the specified object in the set of observed MBeans, if this object is not already present.

Usage

From source file:admin.jmx.StepExecutionServiceLevelMonitor.java

public GaugeMonitor getObject() throws Exception {
    GaugeMonitor monitor = new GaugeMonitor();
    monitor.setNotifyHigh(true);/*from w  w  w .j  a  va  2s . c  o m*/
    monitor.addObservedObject(new ObjectName(
            String.format("%s:type=JobExecution,name=%s,step=%s", defaultDomain, jobName, stepName)));
    monitor.setObservedAttribute(observedAttribute);
    if (observedAttribute.endsWith("Duration")) {
        monitor.setThresholds(new Double(upperThreshold), new Double(lowerThreshold));
    } else {
        monitor.setThresholds(new Integer(upperThreshold), new Integer(lowerThreshold));
    }
    if (autoStart) {
        monitor.start();
    }
    return monitor;
}