com.dtolabs.rundeck.core.common
Class PropertiesCache

java.lang.Object
  extended by com.dtolabs.rundeck.core.common.PropertiesCache

public class PropertiesCache
extends java.lang.Object

PropertiesCache caches properties file contents and reloads them if they have been modified.


Constructor Summary
PropertiesCache()
           
 
Method Summary
 java.util.Properties getProperties(java.io.File file)
          Get the java Properties stored in the file, loading from disk only if the file has been modified since the last read, or the cached data has been invalidated.
 boolean needsReload(java.io.File file)
          Returns true if the file does not exist, or has been modified since the last time it was loaded.
 void touch(java.io.File file)
          Clear cached data for the file, causing a reload for the next call of getProperties(java.io.File)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertiesCache

public PropertiesCache()
Method Detail

needsReload

public boolean needsReload(java.io.File file)
                    throws java.io.IOException
Returns true if the file does not exist, or has been modified since the last time it was loaded.

Parameters:
file - File to check
Returns:
true if the file needs to be reloaded.
Throws:
java.io.IOException

getProperties

public java.util.Properties getProperties(java.io.File file)
                                   throws java.io.IOException
Get the java Properties stored in the file, loading from disk only if the file has been modified since the last read, or the cached data has been invalidated.

Parameters:
file - java properties file
Returns:
java Properties
Throws:
java.io.IOException - due to file read or find error

touch

public void touch(java.io.File file)
Clear cached data for the file, causing a reload for the next call of getProperties(java.io.File)

Parameters:
file - file