use of org.opennms.netmgt.model.ServiceDaemon in project opennms by OpenNMS.
the class JmxDaemonStatusDao method buildProxy.
private ServiceDaemon buildProxy(ObjectName mBeanName) {
MBeanProxyFactoryBean mBeanProxyFactoryBean = new MBeanProxyFactoryBean();
try {
mBeanProxyFactoryBean.setObjectName(mBeanName.getCanonicalName());
} catch (MalformedObjectNameException e) {
throw new JmxObjectNameException("Object name '" + mBeanName.getCanonicalName() + "' was malformed!", e);
}
mBeanProxyFactoryBean.setProxyInterface(ServiceDaemon.class);
mBeanProxyFactoryBean.afterPropertiesSet();
return (ServiceDaemon) mBeanProxyFactoryBean.getObject();
}
use of org.opennms.netmgt.model.ServiceDaemon in project opennms by OpenNMS.
the class JmxDaemonStatusDao method getCurrentDaemonStatus.
/**
* <p>getCurrentDaemonStatus</p>
*
* @return a {@link java.util.Map} object.
*/
@Override
public Map<String, ServiceInfo> getCurrentDaemonStatus() {
// TODO Auto-generated method stub
Map<String, ServiceInfo> serviceInfo = new HashMap<String, ServiceInfo>();
// go to the JMX Server and ask for all the MBeans...
// ArrayList<MBeanServer> mbeans =
// MBeanServerFactory.findMBeanServer(null);
// get their names and corresponding status and plugit into Service Info
Set<ObjectName> mBeanNames;
try {
mBeanNames = queryMbeanServerForNames(new ObjectName("opennms:*"), null);
} catch (MalformedObjectNameException e) {
throw new JmxObjectNameException("Object name 'opennms:*' was malformed!", e);
} catch (NullPointerException e) {
throw new JmxObjectNameException("Object name param is null.", e);
}
for (ObjectName mBeanName : mBeanNames) {
ServiceDaemon serviceDaemon = buildProxy(mBeanName);
String name = serviceDaemon.getName();
String status = serviceDaemon.getStatusText();
serviceInfo.put(name, new ServiceInfo(name, status));
}
// Map the name of the service to ServiceInfo...
// for testing adding a dummy service info node...
serviceInfo.put("test", new ServiceInfo("test", "started"));
return Collections.unmodifiableMap(serviceInfo);
}
Aggregations