Package javax.management

Examples of javax.management.NotificationEmitter.addNotificationListener()


        super();
        final MemoryMXBean mbean = ManagementFactory.getMemoryMXBean();
        final NotificationEmitter emitter = (NotificationEmitter) mbean;

        // register with the Java5 memory management system.
        emitter.addNotificationListener(new NotificationHandler(), null, null);
    }

    /**
     * Get the <code>Logger</code>.
     *
 
View Full Code Here


        NotificationFilter filter = null;
        Object handback = null;
        final ScanState before;
        final NotificationEmitter emitter = (NotificationEmitter)
                makeNotificationEmitter(proxy,DirectoryScannerMXBean.class);
        emitter.addNotificationListener(listener, filter, handback);
        before = proxy.getState();
        op.call();
        try {
            final Notification notification =
                    queue.poll(3000,TimeUnit.MILLISECONDS);
View Full Code Here

        };
        NotificationFilter filter = null;
        Object handback = null;
        final ScanState before;
        final NotificationEmitter emitter = (NotificationEmitter)proxy;
        emitter.addNotificationListener(listener, filter, handback);
        before = proxy.getState();
        op.call();
        try {
            final Notification notification =
                    queue.poll(3000,TimeUnit.MILLISECONDS);
View Full Code Here

        emitter.removeNotificationListener(this, null, memoryPoolMXBean);
      } catch (Exception e) {  }
      MemoryUsage memUsage = memoryPoolMXBean.getUsage();
      if (memUsage != null) {
        if (memoryPoolMXBean.isUsageThresholdSupported()) {
          emitter.addNotificationListener(this, null, memoryPoolMXBean);
          long memUsageTreshold =
                  new Double(new Long(memUsage.getMax()).doubleValue() *
                  treshold).longValue();
          memoryPoolMXBean.setUsageThreshold(memUsageTreshold);
          log.config("Setting treshold: " + memUsageTreshold +
View Full Code Here

  
    void registerForMemoryThresholdNotifications() {
      MemoryMXBean memMXBean = ManagementFactory.getMemoryMXBean();
      NotificationEmitter emitter = (NotificationEmitter) memMXBean;
      emitter.addNotificationListener(this, null, null);
      for (String listener : listenersList) {
        try {
            emitter.addNotificationListener(
          (NotificationListener)Class.forName(listener).newInstance(),
          null, null);
View Full Code Here

      MemoryMXBean memMXBean = ManagementFactory.getMemoryMXBean();
      NotificationEmitter emitter = (NotificationEmitter) memMXBean;
      emitter.addNotificationListener(this, null, null);
      for (String listener : listenersList) {
        try {
            emitter.addNotificationListener(
          (NotificationListener)Class.forName(listener).newInstance(),
          null, null);
        } catch (Exception ex) {
                        _logger.log(Level.WARNING, " Error in loading class " + listener, ex) ;
        }
View Full Code Here

      NotificationEmitter emitter = (NotificationEmitter)MBeanServerInvocationHandler.newProxyInstance(server, name, LocalServiceMBean.class, true);

      try
      {
         emitter.addNotificationListener(new TestListener(), null, null);
         fail("The MBean is not a NotificationEmitter");
      }
      catch (IllegalArgumentException x)
      {
      }
View Full Code Here

      LocalEmitterService mbean = new LocalEmitterService();
      server.registerMBean(mbean, name);

      NotificationEmitter proxy = (NotificationEmitter)MBeanServerInvocationHandler.newProxyInstance(server, name, NotificationEmitter.class, true);
      TestListener listener = new TestListener();
      proxy.addNotificationListener(listener, null, null);
      mbean.test();
      if (!listener.received) fail();
   }

   public void testGetNotificationInfo() throws Exception
View Full Code Here

      LocalEmitterService mbean = new LocalEmitterService();
      server.registerMBean(mbean, name);

      NotificationEmitter proxy = (NotificationEmitter)MBeanServerInvocationHandler.newProxyInstance(server, name, NotificationEmitter.class, true);
      TestListener listener = new TestListener();
      proxy.addNotificationListener(listener, null, null);
      proxy.removeNotificationListener(listener);
      mbean.test();
      if (listener.received) fail();
   }
View Full Code Here

      NotificationEmitter proxy = (NotificationEmitter)MBeanServerInvocationHandler.newProxyInstance(server, name, NotificationEmitter.class, true);
      TestListener listener = new TestListener();
      TestFilter filter = new TestFilter();
      Object handback = new Object();
      proxy.addNotificationListener(listener, filter, handback);
      proxy.removeNotificationListener(listener, filter, handback);
      mbean.test();
      if (listener.received) fail();
   }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.