jetbrains.buildServer.serverSide
Class FileWatchingPropertiesModel

java.lang.Object
  extended by jetbrains.buildServer.serverSide.BasePropertiesModel
      extended by jetbrains.buildServer.serverSide.FileWatchingPropertiesModel
All Implemented Interfaces:
TeamCityProperties.Model
Direct Known Subclasses:
TeamCityServerPropertiesModel

public class FileWatchingPropertiesModel
extends BasePropertiesModel

Provides implementation of TeamCityProperties model that encapsulates check of user-provided file. Call to startFileWatching() enables file watcher. By default file is checked every 10 seconds. This class is not intended to be used from non-TeamCity core code.
Use setFileWatcherSleepingPeriod(long) or "teamcity.internal.properties.reread.interval.ms" property to change the default value. The properties is checked in the loading/watching file.
Performance note: all access methods are never blocked to read the value from the file. In case the file is removed, last used properties map is in effect.
Also note that the errors are not reported to the log, because the log environment might be not initialized yet (it can require a system property for that =). Created ages ago, moved here on 27.02.13 19:44

Since:
8.0
Author:
Eugene Petrenko (eugene.petrenko@jetbrains.com), Maxim Podkolzine (maxim.podkolzine@jetbrains.com)

Field Summary
static java.lang.String DEFAULT_PROPERTIES_FILE_NAME
           
 
Fields inherited from class jetbrains.buildServer.serverSide.BasePropertiesModel
EMPTY_PROPERTIES
 
Constructor Summary
FileWatchingPropertiesModel(java.io.File propertiesFile)
           
 
Method Summary
 void forceReloadProperties()
           
 FileWatcher getFileWatcher()
           
 java.util.Map<java.lang.String,java.lang.String> getUserDefinedProperties()
           
 java.io.File getWatchingFilePath()
          Returns the full path to the internal.properties file.
 void setFileWatcherSleepingPeriod(long currentSleepingInterval)
           
 void startFileWatching()
           
 void stopFileWatching()
           
 
Methods inherited from class jetbrains.buildServer.serverSide.BasePropertiesModel
getPropertyOrNull, getSystemProperties, getSystemProperty, getUserDefinedProperty, propertiesToMap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PROPERTIES_FILE_NAME

public static final java.lang.String DEFAULT_PROPERTIES_FILE_NAME
See Also:
Constant Field Values
Constructor Detail

FileWatchingPropertiesModel

public FileWatchingPropertiesModel(@NotNull
                                   java.io.File propertiesFile)
Method Detail

getUserDefinedProperties

@NotNull
public java.util.Map<java.lang.String,java.lang.String> getUserDefinedProperties()
Specified by:
getUserDefinedProperties in interface TeamCityProperties.Model
Overrides:
getUserDefinedProperties in class BasePropertiesModel
Returns:
User provided properties map. In some implementations internal.properties file is used

getFileWatcher

@Nullable
public FileWatcher getFileWatcher()

setFileWatcherSleepingPeriod

public void setFileWatcherSleepingPeriod(long currentSleepingInterval)

stopFileWatching

public void stopFileWatching()

startFileWatching

public void startFileWatching()

forceReloadProperties

public void forceReloadProperties()

getWatchingFilePath

@NotNull
public java.io.File getWatchingFilePath()
Returns the full path to the internal.properties file. If properties file is not initialized yet, an empty string is returned.

Returns:
full path