Package javax.management

Examples of javax.management.NotificationEmitter


       
        threshold = Math.min( threshold, 5*1024*1024 );
       
        MemoryMXBean mbean = ManagementFactory.getMemoryMXBean();

        NotificationEmitter emitter = (NotificationEmitter) mbean;

       
        emitter.addNotificationListener(
          new NotificationListener()
          {
            private long  last_mb_log = Long.MAX_VALUE;
           
            private boolean increase_tried;
View Full Code Here


    */
   public void register(NotificationListener listener) {
      if (this.pool != null) {
         // register for notification ...
         MemoryMXBean mbean = ManagementFactory.getMemoryMXBean();
         NotificationEmitter emitter = (NotificationEmitter) mbean;
         emitter.addNotificationListener(listener, null, this.pool);
      }
   }
View Full Code Here

  public OMemoryWatchDog(final float iThreshold) {
    OMemoryWatchDog.setPercentageUsageThreshold(iThreshold);

    final MemoryMXBean memBean = ManagementFactory.getMemoryMXBean();

    final NotificationEmitter memEmitter = (NotificationEmitter) memBean;
    memEmitter.addNotificationListener(new NotificationListener() {
      public synchronized void handleNotification(Notification n, Object hb) {
        if (n.getType().equals(MemoryNotificationInfo.MEMORY_THRESHOLD_EXCEEDED)) {
          alertTimes++;
          long maxMemory = tenuredGenPool.getUsage().getMax();
          long usedMemory = tenuredGenPool.getUsage().getUsed();
View Full Code Here

        // prepare the dump location
        setDumpLocation(null);

        // register for memory threshold notifications
        NotificationEmitter memEmitter = (NotificationEmitter) getMemory();
        memEmitter.addNotificationListener(this, null, null);

        // set the initial automatic dump threshold
        int defaultThreshold;
        String propThreshold = context.getProperty(MemoryUsageConstants.PROP_DUMP_THRESHOLD);
        if (propThreshold != null)
View Full Code Here

        setInterval(interval);
    }

    void dispose()
    {
        NotificationEmitter memEmitter = (NotificationEmitter) getMemory();
        try
        {
            memEmitter.removeNotificationListener(this);
        }
        catch (ListenerNotFoundException e)
        {
            // don't care
        }
View Full Code Here

  public OMemoryWatchDog(final float iThreshold) {
    OMemoryWatchDog.setPercentageUsageThreshold(iThreshold);

    final MemoryMXBean memBean = ManagementFactory.getMemoryMXBean();

    final NotificationEmitter memEmitter = (NotificationEmitter) memBean;
    memEmitter.addNotificationListener(new NotificationListener() {
      public synchronized void handleNotification(Notification n, Object hb) {
        if (n.getType().equals(MemoryNotificationInfo.MEMORY_THRESHOLD_EXCEEDED)) {
          alertTimes++;
          long maxMemory = tenuredGenPool.getUsage().getMax();
          long usedMemory = tenuredGenPool.getUsage().getUsed();
View Full Code Here

  public OMemoryWatchDog(final float iThreshold) {
    OMemoryWatchDog.setPercentageUsageThreshold(iThreshold);

    final MemoryMXBean memBean = ManagementFactory.getMemoryMXBean();

    final NotificationEmitter memEmitter = (NotificationEmitter) memBean;
    memEmitter.addNotificationListener(new NotificationListener() {
      public void handleNotification(Notification n, Object hb) {
        if (n.getType().equals(MemoryNotificationInfo.MEMORY_THRESHOLD_EXCEEDED)) {
          alertTimes++;
          long maxMemory = tenuredGenPool.getUsage().getMax();
          long usedMemory = tenuredGenPool.getUsage().getUsed();
View Full Code Here

            throw new ListenerNotFoundException("Unknown listener");

        if (removeAll)
            broadcaster.removeNotificationListener(listenerWrapper);
        else {
            NotificationEmitter emitter = (NotificationEmitter) broadcaster;
            emitter.removeNotificationListener(listenerWrapper,
                                               filter,
                                               handback);
        }
    }
View Full Code Here

      throws Exception
   {
      MBeanServer server = MBeanServerFactory.newMBeanServer();
      EmitterInvocationHandlerTest test = new EmitterInvocationHandlerTest();
      server.registerMBean(test, invocationHandlerTestName);
      NotificationEmitter proxy = (NotificationEmitter) MBeanServerInvocationHandler.newProxyInstance(
         server, invocationHandlerTestName, InvocationHandlerTestMBean.class, true);

      proxy.addNotificationListener(this, null, null);

      messages.clear();
      test.sendNotification();
      assertTrue(messages.size() == 1);
   }
View Full Code Here

      throws Exception
   {
      MBeanServer server = MBeanServerFactory.newMBeanServer();
      EmitterInvocationHandlerTest test = new EmitterInvocationHandlerTest();
      server.registerMBean(test, invocationHandlerTestName);
      NotificationEmitter proxy = (NotificationEmitter) MBeanServerInvocationHandler.newProxyInstance(
         server, invocationHandlerTestName, InvocationHandlerTestMBean.class, true);

      proxy.addNotificationListener(this, null, null);

      messages.clear();
      test.sendNotification();
      assertTrue(messages.size() == 1);

      proxy.removeNotificationListener(this);

      messages.clear();
      test.sendNotification();
      assertTrue(messages.size() == 0);
   }
View Full Code Here

TOP

Related Classes of javax.management.NotificationEmitter

Copyright © 2018 www.massapicom. 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.