Package javax.management.monitor

Examples of javax.management.monitor.StringMonitor


      expected.add(MonitorNotification.OBSERVED_OBJECT_ERROR);
      expected.add(MonitorNotification.RUNTIME_ERROR);
      expected.add(MonitorNotification.STRING_TO_COMPARE_VALUE_DIFFERED);
      expected.add(MonitorNotification.STRING_TO_COMPARE_VALUE_MATCHED);

      MBeanNotificationInfo[] mbni = new StringMonitor().getNotificationInfo();
      checkNotificationInfo("String", mbni, expected);
   }
View Full Code Here


    */
   private void initStringMonitor(boolean differ, boolean match, String compare)
   {
      try
      {
         StringMonitor stringMonitor = new StringMonitor();
         stringMonitor.setNotifyDiffer(differ);
         stringMonitor.setNotifyMatch(match);
         stringMonitor.setStringToCompare(compare);
         StringSupport support = new StringSupport();
         monitor = stringMonitor;
         monitored = support;
         initMonitor();
      }
View Full Code Here

      expected.add(MonitorNotification.OBSERVED_OBJECT_ERROR);
      expected.add(MonitorNotification.RUNTIME_ERROR);
      expected.add(MonitorNotification.STRING_TO_COMPARE_VALUE_DIFFERED);
      expected.add(MonitorNotification.STRING_TO_COMPARE_VALUE_MATCHED);

      MBeanNotificationInfo[] mbni = new StringMonitor().getNotificationInfo();
      checkNotificationInfo("String", mbni, expected);
   }
View Full Code Here

    */
   private void initStringMonitor(boolean differ, boolean match, String compare)
   {
      try
      {
         StringMonitor stringMonitor = new StringMonitor();
         stringMonitor.setNotifyDiffer(differ);
         stringMonitor.setNotifyMatch(match);
         stringMonitor.setStringToCompare(compare);
         StringSupport support = new StringSupport();
         monitor = stringMonitor;
         monitored = support;
         initMonitor();
      }
View Full Code Here

   */
  private void startStringService(boolean match, boolean differ,
                                   String value)
    throws Exception
  {
    installMonitorService(new StringMonitor());
    AttributeList attributes = new AttributeList();
    attributes.add(new Attribute("NotifyDiffer", new Boolean(differ)));
    attributes.add(new Attribute("NotifyMatch", new Boolean(match)));
    attributes.add(new Attribute("StringToCompare", value));
    attributes.add(new Attribute("GranularityPeriod", new Long(PERIOD)));
View Full Code Here

public final class AMXStringMonitorImpl extends JMXMonitorBase
  // implements AMXStringMonitor
{
  AMXStringMonitorImpl()
  {
    super( new StringMonitor() );
  }
View Full Code Here

      super(name);
   }

   protected Monitor createMonitor()
   {
      return new StringMonitor();
   }
View Full Code Here

      return new StringMonitor();
   }

   public void testCorrectInitialization() throws Exception
   {
      StringMonitor monitor = (StringMonitor)createMonitor();
      assertEquals("", monitor.getStringToCompare());
      assertFalse(monitor.getNotifyDiffer());
      assertFalse(monitor.getNotifyMatch());
   }
View Full Code Here

      assertFalse(monitor.getNotifyMatch());
   }

   public void testSetStringToCompare() throws Exception
   {
      StringMonitor monitor = (StringMonitor)createMonitor();
      try
      {
         monitor.setStringToCompare(null);
         fail();
      }
      catch (IllegalArgumentException x)
      {
      }
View Full Code Here

   {
      ObjectName name = new ObjectName(":mbean=target");
      ObjectName monitorName = new ObjectName(":monitor=gauge");

      MBeanServer server = newMBeanServer();
      StringMonitor monitor = (StringMonitor)createMonitor();
      String reference = "XYZ";
      monitor.setStringToCompare(reference);
      monitor.setNotifyMatch(true);
      monitor.setNotifyDiffer(true);
      monitor.addObservedObject(name);
      monitor.setObservedAttribute("String");
      int period = 1000;
      monitor.setGranularityPeriod(period);
      server.registerMBean(monitor, monitorName);

      MonitorTarget target = new MonitorTarget();
      target.setString(reference);
      server.registerMBean(target, name);

      final MutableInteger times = new MutableInteger(0);
      final MutableObject holder = new MutableObject(null);
      NotificationListener listener = new NotificationListener()
      {
         public void handleNotification(Notification notification, Object handback)
         {
            times.set(times.get() + 1);
            holder.set(notification);
         }
      };
      server.addNotificationListener(monitorName, listener, null, null);

      monitor.start();

      try
      {
         sleep(period * 3);
         assertEquals(times.get(), 1);
         MonitorNotification notification = (MonitorNotification)holder.get();
         assertEquals(notification.getType(), MonitorNotification.STRING_TO_COMPARE_VALUE_MATCHED);

         times.set(0);
         holder.set(null);
         target.setString("xx");

         sleep(period * 3);
         assertEquals(times.get(), 1);
         notification = (MonitorNotification)holder.get();
         assertEquals(notification.getType(), MonitorNotification.STRING_TO_COMPARE_VALUE_DIFFERED);

         times.set(0);
         holder.set(null);
         target.setString(reference);

         sleep(period * 3);
         assertEquals(times.get(), 1);
         notification = (MonitorNotification)holder.get();
         assertEquals(notification.getType(), MonitorNotification.STRING_TO_COMPARE_VALUE_MATCHED);

         times.set(0);
         holder.set(null);
         target.setString("yyyy");

         sleep(period * 3);
         assertEquals(times.get(), 1);
         notification = (MonitorNotification)holder.get();
         assertEquals(notification.getType(), MonitorNotification.STRING_TO_COMPARE_VALUE_DIFFERED);

         times.set(0);
         holder.set(null);
         target.setString("zzzzz");

         sleep(period * 3);
         assertEquals(times.get(), 0);
         assertNull(holder.get());
      }
      finally
      {
         monitor.stop();
      }
   }
View Full Code Here

TOP

Related Classes of javax.management.monitor.StringMonitor

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.