Package org.opennms.core.utils
Class PropertiesCache
- java.lang.Object
-
- org.opennms.core.utils.PropertiesCache
-
public class PropertiesCache extends java.lang.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 java.lang.String
CACHE_TIMEOUT
static java.lang.String
CHECK_LAST_MODIFY_STRING
static int
DEFAULT_CACHE_TIMEOUT
protected com.google.common.cache.Cache<java.lang.String,PropertiesCache.PropertiesHolder>
m_cache
-
Constructor Summary
Constructors Modifier Constructor Description PropertiesCache()
protected
PropertiesCache(com.google.common.cache.CacheBuilder<java.lang.Object,java.lang.Object> cacheBuilder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
clearjava.util.Properties
findProperties(java.io.File propFile)
findPropertiesjava.util.Properties
getProperties(java.io.File propFile)
Get the current properties object from the cache loading it in memoryjava.lang.String
getProperty(java.io.File propFile, java.lang.String key)
getPropertyvoid
saveProperties(java.io.File propFile, java.util.Map<java.lang.String,java.lang.String> attributeMappings)
void
saveProperties(java.io.File propFile, java.util.Properties properties)
savePropertiesvoid
setProperty(java.io.File propFile, java.lang.String key, java.lang.String value)
setPropertyvoid
updateProperties(java.io.File propFile, java.util.Map<java.lang.String,java.lang.String> props)
updateProperties
-
-
-
Field Detail
-
CHECK_LAST_MODIFY_STRING
public static final java.lang.String CHECK_LAST_MODIFY_STRING
- See Also:
- Constant Field Values
-
CACHE_TIMEOUT
public static final java.lang.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<java.lang.String,PropertiesCache.PropertiesHolder> m_cache
-
-
Method Detail
-
clear
public void clear()
clear
-
getProperties
public java.util.Properties getProperties(java.io.File propFile) throws java.io.IOException
Get the current properties object from the cache loading it in memory- Parameters:
propFile
- aFile
object.- Returns:
- a
Properties
object. - Throws:
java.io.IOException
- if any.
-
findProperties
public java.util.Properties findProperties(java.io.File propFile) throws java.io.IOException
findProperties
- Parameters:
propFile
- aFile
object.- Returns:
- a
Properties
object. - Throws:
java.io.IOException
- if any.
-
saveProperties
public void saveProperties(java.io.File propFile, java.util.Properties properties) throws java.io.IOException
saveProperties
- Parameters:
propFile
- aFile
object.properties
- aProperties
object.- Throws:
java.io.IOException
- if any.
-
saveProperties
public void saveProperties(java.io.File propFile, java.util.Map<java.lang.String,java.lang.String> attributeMappings) throws java.io.IOException
- Throws:
java.io.IOException
-
updateProperties
public void updateProperties(java.io.File propFile, java.util.Map<java.lang.String,java.lang.String> props) throws java.io.IOException
updateProperties
- Parameters:
propFile
- aFile
object.props
- aMap
object.- Throws:
java.io.IOException
- if any.
-
setProperty
public void setProperty(java.io.File propFile, java.lang.String key, java.lang.String value) throws java.io.IOException
setProperty
- Parameters:
propFile
- aFile
object.key
- aString
object.value
- aString
object.- Throws:
java.io.IOException
- if any.
-
getProperty
public java.lang.String getProperty(java.io.File propFile, java.lang.String key) throws java.io.IOException
getProperty
- Parameters:
propFile
- aFile
object.key
- aString
object.- Returns:
- a
String
object. - Throws:
java.io.IOException
- if any.
-
-