Examples of MutableInteger


Examples of org.hibernate.envers.tools.MutableInteger

     *
     * @param entityName Main entity which should be selected.
     * @param alias Alias of the entity
     */
    public QueryBuilder(String entityName, String alias) {
        this(entityName, alias, new MutableInteger(), new MutableInteger());
    }
View Full Code Here

Examples of org.hibernate.envers.tools.MutableInteger

     *
     * @param entityName Main entity which should be selected.
     * @param alias Alias of the entity
     */
    public QueryBuilder(String entityName, String alias) {
        this(entityName, alias, new MutableInteger(), new MutableInteger());
    }
View Full Code Here

Examples of org.nlogo.nvm.MutableInteger

    LogoList list = argEvalList(context, 0);
    for (Iterator<Object> it = list.iterator(); it.hasNext();) {
      Object srcElt = it.next();
      LogoHashObject logoElt = new LogoHashObject(srcElt);
      if (counts.containsKey(logoElt)) {
        MutableInteger i = counts.get(logoElt);
        i.value_$eq(i.value() + 1);
      } else {
        counts.put(logoElt, new MutableInteger(1));
      }
    }

    Iterator<LogoHashObject> keys = counts.keySet().iterator();
    int currMaxCount = 0;
View Full Code Here

Examples of org.zkoss.lang.MutableInteger

   */
  public Radio getItemAtIndex(int index) {
    if (index < 0)
      throw new IndexOutOfBoundsException("Wrong index: "+index);

    final MutableInteger cur = new MutableInteger(0);
    Radio radio = getAt(this, cur, index);
    if (radio != null)
      return radio;
    if (_externs != null)
      for (Iterator it = _externs.iterator(); it.hasNext();) {
View Full Code Here

Examples of org.zkoss.lang.MutableInteger

  }
  /** Fix the selected index, _jsel, assuming there are no selected one
   * before (and excludes) j-the radio button.
   */
  /*package*/ void fixSelectedIndex() {
    final MutableInteger cur = new MutableInteger(0);
    _jsel = fixSelIndex(this, cur);

    if (_jsel < 0 && _externs != null)
      for (Iterator it = _externs.iterator(); it.hasNext();) {
        final Radio radio = (Radio)it.next();
View Full Code Here

Examples of test.MutableInteger

      monitor.addObservedObject(counterName);
      monitor.setGranularityPeriod(1000);
      monitor.setObservedAttribute("ObjectCounter");

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

      try
      {
         // Wait for notification to arrive
         while (holder.get() == null) sleep(10);

         // Be sure only one arrived
         sleep(5000);
         assertEquals(times.get(), 1);

         MonitorNotification notification = (MonitorNotification)holder.get();
         assertEquals(notification.getType(), MonitorNotification.OBSERVED_ATTRIBUTE_TYPE_ERROR);
      }
      finally
View Full Code Here

Examples of test.MutableInteger

      monitor.setNotify(true);
      // No modulus, no offset

      counter.setIntegerCounter(initThreshold.intValue() - 1);

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

      try
      {
         // Below threshold, no notifications should be sent
         sleep(period * 3);
         assertEquals(times.get(), 0);
         assertNull(holder.get());

         // Above threshold, just one notification should be sent
         counter.setIntegerCounter(initThreshold.intValue() + 1);
         sleep(period * 3);
         assertEquals(times.get(), 1);
         MonitorNotification notification = (MonitorNotification)holder.get();
         assertEquals(notification.getType(), MonitorNotification.THRESHOLD_VALUE_EXCEEDED);

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

Examples of test.MutableInteger

      monitor.setOffset(offset);
      // No modulus

      counter.setIntegerCounter(initThreshold.intValue() - 1);

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

      try
      {
         // Below threshold, no notifications should be sent
         sleep(period * 3);
         assertEquals(times.get(), 0);
         assertNull(holder.get());

         // Above threshold, just one notification should be sent
         counter.setIntegerCounter(initThreshold.intValue() + 1);
         sleep(period * 3);
         assertEquals(times.get(), 1);
         MonitorNotification notification = (MonitorNotification)holder.get();
         assertEquals(notification.getType(), MonitorNotification.THRESHOLD_VALUE_EXCEEDED);
         // The threshold should have offset
         Number threshold = monitor.getThreshold(counterName);
         assertEquals(threshold.intValue(), monitor.getInitThreshold().intValue() + offset.intValue());

         times.set(0);
         holder.set(null);
         sleep(period * 3);
         assertEquals(times.get(), 0);

         // Above threshold by more than 1 offset
         counter.setIntegerCounter(initThreshold.intValue() + offset.intValue() * 2 + 1);
         sleep(period * 3);
         assertEquals(times.get(), 1);
         notification = (MonitorNotification)holder.get();
         assertEquals(notification.getType(), MonitorNotification.THRESHOLD_VALUE_EXCEEDED);
         // The threshold should have offset correctly
         threshold = monitor.getThreshold(counterName);
         assertEquals(threshold.intValue(), monitor.getInitThreshold().intValue() + offset.intValue() * 3);

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

Examples of test.MutableInteger

      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

Examples of test.MutableInteger

         // Register an MBean Emitter
         ObjectName emitterName = ObjectName.getInstance(":mbean=emitter");
         MBeanEmitter emitter = new MBeanEmitter();
         server.registerMBean(emitter, emitterName);

         final MutableInteger counter1 = new MutableInteger(0);
         NotificationListener listener1 = new NotificationListener()
         {
            public void handleNotification(Notification notification, Object handback)
            {
               counter1.set(counter1.get() + 1);
            }
         };
         final MutableInteger counter2 = new MutableInteger(0);
         NotificationListener listener2 = new NotificationListener()
         {
            public void handleNotification(Notification notification, Object handback)
            {
               counter2.set(counter2.get() + 1);
            }
         };

         JMXServiceURL url = createJMXConnectorServerAddress();
         cntorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, getEnvironment(), server);
         cntorServer.start();
         sleep(5000);

         cntor = JMXConnectorFactory.connect(cntorServer.getAddress(), getEnvironment());
         MBeanServerConnection mbsc = cntor.getMBeanServerConnection();

         String type = "notification.type";

         // First listener
         mbsc.addNotificationListener(emitterName, listener1, null, null);
         // Second listener
         NotificationFilterSupport filter = new NotificationFilterSupport();
         filter.enableType(type);
         mbsc.addNotificationListener(emitterName, listener1, filter, null);
         // Third listener
         Object handback = new Object();
         mbsc.addNotificationListener(emitterName, listener1, null, handback);
         // Fourth listener
         mbsc.addNotificationListener(emitterName, listener2, null, null);

         // Wait for notification threads to start
         sleep(1000);

         Notification notification = new Notification(type, this, 0);
         emitter.emit(notification);
         // Wait for notification to arrive
         sleep(1000);

         // Be sure we got all notifications
         assertEquals(counter1.get(), 3);
         assertEquals(counter2.get(), 1);
         counter1.set(0);
         counter2.set(0);

         // Remove one listener
         mbsc.removeNotificationListener(emitterName, listener1, null, handback);

         emitter.emit(notification);
         // Wait for notification to arrive
         sleep(1000);

         assertEquals(counter1.get(), 2);
         assertEquals(counter2.get(), 1);
         counter1.set(0);
         counter2.set(0);

         // Remove all listeners
         mbsc.removeNotificationListener(emitterName, listener1);

         emitter.emit(notification);
         // Wait for notification to arrive
         sleep(1000);

         assertEquals(counter1.get(), 0);
         assertEquals(counter2.get(), 1);
         counter1.set(0);
         counter2.set(0);

         mbsc.removeNotificationListener(emitterName, listener2);

         emitter.emit(notification);
         // Wait for notification to arrive
         sleep(1000);

         assertEquals(counter1.get(), 0);
         assertEquals(counter2.get(), 0);
      } catch (Exception x)
      {
         x.printStackTrace();
         throw x;
      } finally
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.