Torsten Curdt wrote:
> On Sun, 21 Apr 2002, Torsten Curdt wrote:
> 
> 
>>>Can someone enlighten me... the ActiveMonitor does not report any file
>>>changes hear as he is supposed to... I just don't get the events :(
>>
>>ok... I have been debugging the active monitor... and I run into this:
>>
>>
>>in FileResource.java:
>>
>>    public long lastModified()
>>    {
>>        return m_file.lastModified();
>>    }
>>
>>
>>in Resource.java:
>>
>>    public void testModifiedAfter( long time )
>>    {
>>        long lastModified = this.lastModified();
>>        if( lastModified > time )
>>        {
>>            m_eventSupport.firePropertyChange( Resource.MODIFIED,
>>                                               new Long( m_previousModified ),
>>                                               new Long( lastModified ) );
>>            m_previousModified = lastModified;
>>        }
>>    }
>>
>>Now what the active monitor does is to call the "testModifiedAfter" with
>>the "System.currentTimeMillis()" as an argument. On a change the
>>"testModifierAfter" is supposed to fire the "Resource.MODIFIED" event.
>>
>>But AFAICS the current code does something else.... If you break it down
>>you get:
>>
>>   if ( file.lastModified() > System.currentTimeMillis() ) {
>>      // fire event
>>   }
>>
>>Which is not much likely to happen... ;-)
>>Shouldn't it be:
>>
>>  if ( file.lastModified() > m_previousModified ) {
>>    // fire event
>>    m_previousModified = file.lastModified()
>>  }
>>
>>But then the "time" argument wouldn't make much sense...
> 
> 
> One way to solve this is to replace this:
> 
> in ActiveMonitor:
> 
>    for( int i = 0; i < resources.length; i++ )
>    {
>         resources[ i ].testModifiedAfter( currentTestTime );
>                                           ~~~~~~~~~~~~~~~
>    }
> 
> by this:
> 
>    for( int i = 0; i < resources.length; i++ )
>    {
>         resources[ i ].testModifiedAfter( resources[i].m_previousModified );
>                                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>    }
> 
> question is only if this is really desired...
> 
> Berin, how did you wanted this to work?
> Do you want me to provide a patch?
> --
> Torsten
> 


Go for it.


-- 

"They that give up essential liberty to obtain a little temporary safety
  deserve neither liberty nor safety."
                 - Benjamin Franklin


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

Reply via email to