jetbrains.buildServer.configuration
Class ChangeObserver

java.lang.Object
  extended by jetbrains.buildServer.configuration.ChangeObserver
Direct Known Subclasses:
FilesWatcher, FileWatcher

public class ChangeObserver
extends java.lang.Object

Component watches for changes provided by ChangeProviders and notifies about changes ChangeListeners. Providers and listeners are registered using corresponding add* remove* methods. Interval of checking for changes is set in constructor. Note: all change observers reuse single thread. Please ensure that both watchers and listeners work fast enough.


Constructor Summary
ChangeObserver(long intervalForCheckingsMsecs)
           
 
Method Summary
 void checkForModifications()
          Performs unscheduled checking for modifications.
 void clear()
          Clears all of the listeners and change providers
 long getSleepingPeriod()
          Returns sleeping period
 void registerChangeProvider(ChangeProvider provider)
          Registers ChangeProvider
 void registerListener(ChangeListener listener)
          Registers ChangeListener
 void runActionWithDisabledObserver(java.lang.Runnable runnable)
          Runs the specified runnable with disabled observer.
 void setSkipListenersNotification(boolean value)
          Disables or enables change listeners notification
 void setSleepingPeriod(long time)
          Sets sleeping period in this observer.
static void shutdownAll()
          Shutdowns all of the change observers
 void start()
          Starts observer
 void stop()
          Stops observer
 void unregisterChangeProvider(ChangeProvider provider)
          Removes ChangeProvider
 void unregisterListener(ChangeListener listener)
          Removes previously registered ChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChangeObserver

public ChangeObserver(long intervalForCheckingsMsecs)
Parameters:
intervalForCheckingsMsecs - how often should ask related ChangeProviders for changes
Method Detail

registerListener

public void registerListener(ChangeListener listener)
Registers ChangeListener

Parameters:
listener - ChangeListener

unregisterListener

public void unregisterListener(ChangeListener listener)
Removes previously registered ChangeListener

Parameters:
listener - ChangeListener

registerChangeProvider

public void registerChangeProvider(ChangeProvider provider)
Registers ChangeProvider

Parameters:
provider - ChangeProvider

unregisterChangeProvider

public void unregisterChangeProvider(ChangeProvider provider)
Removes ChangeProvider

Parameters:
provider - ChangeProvider

start

public void start()
Starts observer


stop

public void stop()
Stops observer


shutdownAll

public static void shutdownAll()
Shutdowns all of the change observers


setSleepingPeriod

public void setSleepingPeriod(long time)
Sets sleeping period in this observer. The observer should be restarted after this.

Parameters:
time - sleeping period

getSleepingPeriod

public long getSleepingPeriod()
Returns sleeping period

Returns:
sleeping period

clear

public void clear()
Clears all of the listeners and change providers


setSkipListenersNotification

public void setSkipListenersNotification(boolean value)
Disables or enables change listeners notification

Parameters:
value - if true change listeners will be notified (default)

runActionWithDisabledObserver

public void runActionWithDisabledObserver(@NotNull
                                          java.lang.Runnable runnable)
Runs the specified runnable with disabled observer. After the runnable finishes the observer continues to watch for changes.

Parameters:
runnable - runnable

checkForModifications

public void checkForModifications()
Performs unscheduled checking for modifications.