@Override public void addNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object context) throws InstanceNotFoundException { mbeanServer.addNotificationListener(name, listener, filter, context); }
@Override public void addNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object context) throws InstanceNotFoundException { mbeanServer.addNotificationListener(name, listener, filter, context); }
@Override public void addNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object context) throws InstanceNotFoundException { mbeanServer.addNotificationListener(name, listener, filter, context); }
@Override public void addNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object context) throws InstanceNotFoundException { mbeanServer.addNotificationListener(name, listener, filter, context); }
@Override public void addNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object context) throws InstanceNotFoundException { mbeanServer.addNotificationListener(name, listener, filter, context); }
@Override public void addNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object context) throws InstanceNotFoundException { mbeanServer.addNotificationListener(name, listener, filter, context); }
@Override public void addNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object context) throws InstanceNotFoundException { mbeanServer.addNotificationListener(name, listener, filter, context); }
@Override public void addNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object context) throws InstanceNotFoundException { mbeanServer.addNotificationListener(name, listener, filter, context); }
@Override public void addNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException { mbs.addNotificationListener(name, listener, filter, handback); }
@Override public void addNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException { mbs.addNotificationListener(name, listener, filter, handback); }
/** * Registers itself as a NotificationListener for Notifications sent from MBean with the * ObjectName given as source. * * @param source source of notifications * @throws InstanceNotFoundException The MBean name provided does not match any of the registered * MBeans. */ /* default */void registerNotificationListener(ObjectName source) throws InstanceNotFoundException { mBeanServer.addNotificationListener(source, this, null/* handback */, source); }
/** {@inheritDoc} */ @Override public void addNotificationListener(ObjectName name, NotificationListener lsnr, NotificationFilter filter, Object handback) throws InstanceNotFoundException { origin.addNotificationListener(name, lsnr, filter, handback); }
/** {@inheritDoc} */ @Override public void addNotificationListener(ObjectName name, ObjectName lsnr, NotificationFilter filter, Object handback) throws InstanceNotFoundException { origin.addNotificationListener(name, lsnr, filter, handback); }
/** * Register the configured {@link NotificationListener NotificationListeners} * with the {@link MBeanServer}. */ private void registerNotificationListeners() throws MBeanExportException { if (this.notificationListeners != null) { Assert.state(this.server != null, "No MBeanServer available"); for (NotificationListenerBean bean : this.notificationListeners) { try { ObjectName[] mappedObjectNames = bean.getResolvedObjectNames(); if (mappedObjectNames == null) { // Mapped to all MBeans registered by the MBeanExporter. mappedObjectNames = getRegisteredObjectNames(); } if (this.registeredNotificationListeners.put(bean, mappedObjectNames) == null) { for (ObjectName mappedObjectName : mappedObjectNames) { this.server.addNotificationListener(mappedObjectName, bean.getNotificationListener(), bean.getNotificationFilter(), bean.getHandback()); } } } catch (Throwable ex) { throw new MBeanExportException("Unable to register NotificationListener", ex); } } } }
/** * Adds a NotificationHubListener * */ public void addHubNotificationListener(String memberName, ObjectName objectName) { try { synchronized (listenerObjectMap) { NotificationHubListener listener = listenerObjectMap.get(objectName); if (listener == null) { listener = new NotificationHubListener(objectName); listener.incNumCounter(); mbeanServer.addNotificationListener(objectName, listener, null, null); listenerObjectMap.put(objectName, listener); } else { listener.incNumCounter(); } } } catch (InstanceNotFoundException e) { throw new ManagementException(e); } }
/** * Register the configured {@link NotificationListener NotificationListeners} * with the {@link MBeanServer}. */ private void registerNotificationListeners() throws MBeanExportException { if (this.notificationListeners != null) { Assert.state(this.server != null, "No MBeanServer available"); for (NotificationListenerBean bean : this.notificationListeners) { try { ObjectName[] mappedObjectNames = bean.getResolvedObjectNames(); if (mappedObjectNames == null) { // Mapped to all MBeans registered by the MBeanExporter. mappedObjectNames = getRegisteredObjectNames(); } if (this.registeredNotificationListeners.put(bean, mappedObjectNames) == null) { for (ObjectName mappedObjectName : mappedObjectNames) { this.server.addNotificationListener(mappedObjectName, bean.getNotificationListener(), bean.getNotificationFilter(), bean.getHandback()); } } } catch (Throwable ex) { throw new MBeanExportException("Unable to register NotificationListener", ex); } } } }
@Test public void testMBean() throws Exception { // start the MBeanExporter ConfigurableApplicationContext ctx = loadContext("org/springframework/jmx/export/notificationPublisherTests.xml"); this.server.addNotificationListener(ObjectNameManager.getInstance("spring:type=PublisherMBean"), listener, null, null); MyNotificationPublisherMBean publisher = (MyNotificationPublisherMBean) ctx.getBean("publisherMBean"); publisher.sendNotification(); assertEquals("Notification not sent", 1, listener.count); }
@Test public void testSimpleBean() throws Exception { // start the MBeanExporter ConfigurableApplicationContext ctx = loadContext("org/springframework/jmx/export/notificationPublisherTests.xml"); this.server.addNotificationListener(ObjectNameManager.getInstance("spring:type=Publisher"), listener, null, null); MyNotificationPublisher publisher = (MyNotificationPublisher) ctx.getBean("publisher"); assertNotNull("NotificationPublisher should not be null", publisher.getNotificationPublisher()); publisher.sendNotification(); assertEquals("Notification not sent", 1, listener.count); }
@Test public void testLazyInit() throws Exception { // start the MBeanExporter ConfigurableApplicationContext ctx = loadContext("org/springframework/jmx/export/notificationPublisherLazyTests.xml"); assertFalse("Should not have instantiated the bean yet", ctx.getBeanFactory().containsSingleton("publisher")); // need to touch the MBean proxy server.getAttribute(ObjectNameManager.getInstance("spring:type=Publisher"), "Name"); this.server.addNotificationListener(ObjectNameManager.getInstance("spring:type=Publisher"), listener, null, null); MyNotificationPublisher publisher = (MyNotificationPublisher) ctx.getBean("publisher"); assertNotNull("NotificationPublisher should not be null", publisher.getNotificationPublisher()); publisher.sendNotification(); assertEquals("Notification not sent", 1, listener.count); }
@Test public void testSimpleBeanRegisteredManually() throws Exception { // start the MBeanExporter ConfigurableApplicationContext ctx = loadContext("org/springframework/jmx/export/notificationPublisherTests.xml"); MBeanExporter exporter = (MBeanExporter) ctx.getBean("exporter"); MyNotificationPublisher publisher = new MyNotificationPublisher(); exporter.registerManagedResource(publisher, ObjectNameManager.getInstance("spring:type=Publisher2")); this.server.addNotificationListener(ObjectNameManager.getInstance("spring:type=Publisher2"), listener, null, null); assertNotNull("NotificationPublisher should not be null", publisher.getNotificationPublisher()); publisher.sendNotification(); assertEquals("Notification not sent", 1, listener.count); }