Package org.opennms.core.utils
Class PropertiesCache
- java.lang.Object
-
- org.opennms.core.utils.PropertiesCache
-
public class PropertiesCache extends Object
Caches properties files in order to improve performance.- Version:
- $Id: $
- Author:
- Mathew Brozowski
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
PropertiesCache.PropertiesHolder
-
Field Summary
Fields Modifier and Type Field Description static String
CACHE_TIMEOUT
static String
CHECK_LAST_MODIFY_STRING
static int
DEFAULT_CACHE_TIMEOUT
protected com.google.common.cache.Cache<String,PropertiesCache.PropertiesHolder>
m_cache
-
Constructor Summary
Constructors Modifier Constructor Description PropertiesCache()
protected
PropertiesCache(com.google.common.cache.CacheBuilder<Object,Object> cacheBuilder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
clearProperties
findProperties(File propFile)
findPropertiesProperties
getProperties(File propFile)
Get the current properties object from the cache loading it in memoryString
getProperty(File propFile, String key)
getPropertyvoid
saveProperties(File propFile, Map<String,String> attributeMappings)
void
saveProperties(File propFile, Properties properties)
savePropertiesvoid
setProperty(File propFile, String key, String value)
setPropertyvoid
updateProperties(File propFile, Map<String,String> props)
updateProperties
-
-
-
Field Detail
-
CHECK_LAST_MODIFY_STRING
public static final String CHECK_LAST_MODIFY_STRING
- See Also:
- Constant Field Values
-
CACHE_TIMEOUT
public static final String CACHE_TIMEOUT
- See Also:
- Constant Field Values
-
DEFAULT_CACHE_TIMEOUT
public static final int DEFAULT_CACHE_TIMEOUT
- See Also:
- Constant Field Values
-
m_cache
protected final com.google.common.cache.Cache<String,PropertiesCache.PropertiesHolder> m_cache
-
-
Method Detail
-
clear
public void clear()
clear
-
getProperties
public Properties getProperties(File propFile) throws IOException
Get the current properties object from the cache loading it in memory- Parameters:
propFile
- aFile
object.- Returns:
- a
Properties
object. - Throws:
IOException
- if any.
-
findProperties
public Properties findProperties(File propFile) throws IOException
findProperties
- Parameters:
propFile
- aFile
object.- Returns:
- a
Properties
object. - Throws:
IOException
- if any.
-
saveProperties
public void saveProperties(File propFile, Properties properties) throws IOException
saveProperties
- Parameters:
propFile
- aFile
object.properties
- aProperties
object.- Throws:
IOException
- if any.
-
saveProperties
public void saveProperties(File propFile, Map<String,String> attributeMappings) throws IOException
- Throws:
IOException
-
updateProperties
public void updateProperties(File propFile, Map<String,String> props) throws IOException
updateProperties
- Parameters:
propFile
- aFile
object.props
- aMap
object.- Throws:
IOException
- if any.
-
setProperty
public void setProperty(File propFile, String key, String value) throws IOException
setProperty
- Parameters:
propFile
- aFile
object.key
- aString
object.value
- aString
object.- Throws:
IOException
- if any.
-
getProperty
public String getProperty(File propFile, String key) throws IOException
getProperty
- Parameters:
propFile
- aFile
object.key
- aString
object.- Returns:
- a
String
object. - Throws:
IOException
- if any.
-
-