List of usage examples for javax.management MBeanServerNotification MBeanServerNotification
public MBeanServerNotification(String type, Object source, long sequenceNumber, ObjectName objectName)
From source file:net.sbbi.upnp.jmx.upnp.UPNPConnectorServer.java
public void start() throws IOException { MBeanServer server = getMBeanServer(); if (exposeMBeansAsUPNP.booleanValue()) { try {/*from w w w.jav a 2s . co m*/ ObjectName delegate = new ObjectName("JMImplementation:type=MBeanServerDelegate"); NotificationEmitter emmiter = (NotificationEmitter) MBeanServerInvocationHandler .newProxyInstance(server, delegate, NotificationEmitter.class, false); // register for MBeans registration emmiter.addNotificationListener(this, null, this); } catch (Exception ex) { IOException ioEx = new IOException("UPNPConnector start error"); ioEx.initCause(ex); throw ioEx; } } if (exposeUPNPAsMBeans.booleanValue()) { int timeout = 2500; if (env.containsKey(EXPOSE_UPNP_DEVICES_AS_MBEANS_TIMEOUT)) { timeout = ((Integer) env.get(EXPOSE_UPNP_DEVICES_AS_MBEANS_TIMEOUT)).intValue(); } try { discoveryBeanName = new ObjectName("UPNPLib discovery:name=Discovery MBean_" + this.hashCode()); UPNPDiscoveryMBean bean = new UPNPDiscovery(timeout, handleSSDPMessages.booleanValue(), true); server.registerMBean(bean, discoveryBeanName); } catch (Exception ex) { IOException ioEx = new IOException("Error occured during MBeans discovery"); ioEx.initCause(ex); throw ioEx; } } if (exposeExistingMBeansAsUPNP.booleanValue()) { int c = 0; Set objectInstances = super.getMBeanServer().queryNames(null, null); for (Iterator i = objectInstances.iterator(); i.hasNext();) { ObjectName name = (ObjectName) i.next(); MBeanServerNotification not = new MBeanServerNotification( MBeanServerNotification.REGISTRATION_NOTIFICATION, this, c++, name); handleNotification(not, this); } } }