Package mx4j.log

Examples of mx4j.log.LoggerBroadcasterMBean


   {
      MBeanServer server = newMBeanServer();
      ObjectName name = new ObjectName(":type=test");
      // Register a logger mbean
      server.createMBean("mx4j.log.LoggerBroadcaster", name, null);
      LoggerBroadcasterMBean redirector = (LoggerBroadcasterMBean)MBeanServerInvocationHandler.newProxyInstance(server, name, LoggerBroadcasterMBean.class, false);

      try
      {
         // Register a notification listener
         final MutableInteger notified = new MutableInteger(0);
         NotificationListener listener = new NotificationListener()
         {
            public void handleNotification(Notification notification, Object handback)
            {
               notified.set(notified.get() + 1);
            }
         };

         server.addNotificationListener(name, listener, null, null);

         // Redirect logging
         redirector.start();

         // Create some log
         ObjectName mlet = new ObjectName(":type=mlet");
         server.createMBean("javax.management.loading.MLet", mlet, null);
         // This should create some log
         server.invoke(mlet, "addURL", new Object[]{new URL("http://mx4j.sourceforge.net")}, new String[]{"java.net.URL"});

         // Test if redirection worked
         if (notified.get() < 1) fail("Notification listener not called");
      }
      finally
      {
         redirector.stop();
      }
   }
View Full Code Here

TOP

Related Classes of mx4j.log.LoggerBroadcasterMBean

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.