donaldp     01/11/02 15:42:13

  Modified:    src/java/org/apache/avalon/cornerstone/blocks/scheduler
                        DefaultTimeScheduler.java
  Log:
  Make sure if you try to add an entry in the past that neither an exception or 
a warning is issued - instead it is silently ignored.
  
  Submitted By: Ken Geis <[EMAIL PROTECTED]>
  
  Revision  Changes    Path
  1.5       +14 -5     
jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/scheduler/DefaultTimeScheduler.java
  
  Index: DefaultTimeScheduler.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/scheduler/DefaultTimeScheduler.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DefaultTimeScheduler.java 2001/11/02 22:28:35     1.4
  +++ DefaultTimeScheduler.java 2001/11/02 23:42:13     1.5
  @@ -78,8 +78,10 @@
   
           final TimeScheduledEntry entry = new TimeScheduledEntry( name, 
trigger, target );
           m_entries.put( name, entry );
  -        rescheduleEntry( entry, false );
  +        final boolean added = rescheduleEntry( entry, false );
   
  +        if( !added ) return;
  +
           try
           {
               if( entry == m_priorityQueue.peek() )
  @@ -130,9 +132,10 @@
        *
        * @param timeEntry the entry
        * @param clone true if new entry is to be created
  +     * @return true if added to queue, false if not added
        */
  -    protected void rescheduleEntry( final TimeScheduledEntry timeEntry,
  -                                    final boolean clone )
  +    private boolean rescheduleEntry( final TimeScheduledEntry timeEntry,
  +                                       final boolean clone )
       {
           TimeScheduledEntry entry = timeEntry;
   
  @@ -161,6 +164,12 @@
               {
                   synchronized( m_monitor ) { m_monitor.notify(); }
               }
  +
  +            return true;
  +        }
  +        else
  +        {
  +            return false;
           }
       }
   
  @@ -171,7 +180,7 @@
        * @return the entry
        * @exception NoSuchElementException if no entry is found with that name
        */
  -    protected TimeScheduledEntry getEntry( final String name )
  +    private TimeScheduledEntry getEntry( final String name )
           throws NoSuchElementException
       {
           //use the kill-o-matic against any entry with same name
  @@ -186,7 +195,7 @@
           }
       }
   
  -    protected void runEntry( final TimeScheduledEntry entry )
  +    private void runEntry( final TimeScheduledEntry entry )
       {
           final Logger logger = getLogger();
           final Runnable runnable = new Runnable()
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to