org.gridkit.nimble.probe.jmx.MBeanLocator Maven / Gradle / Ivy
package org.gridkit.nimble.probe.jmx;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
import org.gridkit.lab.monitoring.probe.TargetLocator;
public class MBeanLocator implements TargetLocator, Serializable {
private static final long serialVersionUID = 20121106L;
private final MBeanConnector connector;
private final ObjectName query;
public MBeanLocator(MBeanConnector connector, ObjectName query) {
this.connector = connector;
this.query = query;
}
@Override
public Collection findTargets() {
List result = new ArrayList();
for(MBeanServerConnection conn: connector.connect()) {
try {
for(ObjectName name: conn.queryNames(query, null)) {
result.add(new MBeanTarget(conn, name));
}
} catch (IOException e) {
// TODO logging
// ignore
}
}
return result;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy