Package org.opennms.core.utils
Class PropertiesCache
- java.lang.Object
-
- org.opennms.core.utils.PropertiesCache
-
public class PropertiesCache extends java.lang.ObjectCaches properties files in order to improve performance.- Version:
- $Id: $
- Author:
- Mathew Brozowski
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classPropertiesCache.PropertiesHolder
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCACHE_TIMEOUTstatic java.lang.StringCHECK_LAST_MODIFY_STRINGstatic intDEFAULT_CACHE_TIMEOUTprotected com.google.common.cache.Cache<java.lang.String,PropertiesCache.PropertiesHolder>m_cache
-
Constructor Summary
Constructors Modifier Constructor Description PropertiesCache()protectedPropertiesCache(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 voidclear()clearjava.util.PropertiesfindProperties(java.io.File propFile)findPropertiesjava.util.PropertiesgetProperties(java.io.File propFile)Get the current properties object from the cache loading it in memoryjava.lang.StringgetProperty(java.io.File propFile, java.lang.String key)getPropertyvoidsaveProperties(java.io.File propFile, java.util.Map<java.lang.String,java.lang.String> attributeMappings)voidsaveProperties(java.io.File propFile, java.util.Properties properties)savePropertiesvoidsetProperty(java.io.File propFile, java.lang.String key, java.lang.String value)setPropertyvoidupdateProperties(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.IOExceptionGet the current properties object from the cache loading it in memory- Parameters:
propFile- aFileobject.- Returns:
- a
Propertiesobject. - Throws:
java.io.IOException- if any.
-
findProperties
public java.util.Properties findProperties(java.io.File propFile) throws java.io.IOExceptionfindProperties
- Parameters:
propFile- aFileobject.- Returns:
- a
Propertiesobject. - Throws:
java.io.IOException- if any.
-
saveProperties
public void saveProperties(java.io.File propFile, java.util.Properties properties) throws java.io.IOExceptionsaveProperties
- Parameters:
propFile- aFileobject.properties- aPropertiesobject.- 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.IOExceptionupdateProperties
- Parameters:
propFile- aFileobject.props- aMapobject.- 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.IOExceptionsetProperty
- Parameters:
propFile- aFileobject.key- aStringobject.value- aStringobject.- Throws:
java.io.IOException- if any.
-
getProperty
public java.lang.String getProperty(java.io.File propFile, java.lang.String key) throws java.io.IOExceptiongetProperty
- Parameters:
propFile- aFileobject.key- aStringobject.- Returns:
- a
Stringobject. - Throws:
java.io.IOException- if any.
-
-