User: ejort   
  Date: 02/03/08 10:21:59

  Modified:    src/main/javax/management/timer Timer.java
  Log:
  Better timer tests
  
  Revision  Changes    Path
  1.6       +15 -16    jmx/src/main/javax/management/timer/Timer.java
  
  Index: Timer.java
  ===================================================================
  RCS file: /cvsroot/jboss/jmx/src/main/javax/management/timer/Timer.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Timer.java        23 Jan 2002 21:22:34 -0000      1.5
  +++ Timer.java        8 Mar 2002 18:21:58 -0000       1.6
  @@ -26,7 +26,7 @@
    * The timer service.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Adrian Brock</a>
  - * @version $Revision: 1.5 $
  + * @version $Revision: 1.6 $
    */
   public class Timer
     extends NotificationBroadcasterSupport
  @@ -97,6 +97,11 @@
     boolean active = false;
   
     /**
  +   * Our object name.
  +   */
  +  ObjectName objectName;
  +
  +  /**
      * The registered notifications.
      */
     ConcurrentReaderHashMap notifications = new ConcurrentReaderHashMap();
  @@ -139,10 +144,7 @@
     {
        // Generate the next id.
       int newId = 0;
  -    synchronized (this)
  -    {
  -      newId = ++nextId;
  -    }
  +    newId = ++nextId;
       Integer id = new Integer(newId);
   
       // Validate and create the registration.
  @@ -272,10 +274,7 @@
       notifications.clear();
   
       // The spec says to reset the identifiers, seems like a bad idea to me
  -    synchronized (this)
  -    {
  -       nextId = 0;
  -    }
  +    nextId = 0;
     }
   
     public void removeNotification(Integer id)
  @@ -360,6 +359,9 @@
     public ObjectName preRegister(MBeanServer server, ObjectName objectName)
       throws Exception
     {
  +    // Save the object name
  +    this.objectName = objectName;
  +
       // Use the passed object name.
       return objectName;
     }
  @@ -445,12 +447,8 @@
         // Yes, unless start and not sending past notifications.
         if (rn.sendType != SEND_NO)
         {
  -        long seq = 0;
  -        synchronized (this)
  -        {
  -          seq = ++sequenceNumber;
  -        }
  -        sendNotification(new TimerNotification(rn.type, this, seq,
  +        long seq = ++sequenceNumber;
  +        sendNotification(new TimerNotification(rn.type, objectName, seq,
                            rn.nextDate, rn.message, rn.id, rn.userData));
         }
   
  @@ -466,7 +464,7 @@
           }
         }
         while (isActive() == true && rn.sendType != SEND_START && rn.nextDate != 0
  -             && rn.nextDate < System.currentTimeMillis());
  +             && rn.occurences == 0 && rn.nextDate < System.currentTimeMillis());
       }
   
       // We've finished with this notification
  @@ -685,6 +683,7 @@
         // Keep going until we are stopped
         while (isActive())
         {
  +        // Run any due notifications
           Iterator iterator = notifications.values().iterator();
           while (iterator.hasNext())
           {
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to