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 classPropertiesCache.PropertiesHolder
-
Field Summary
Fields Modifier and Type Field Description static StringCACHE_TIMEOUTstatic StringCHECK_LAST_MODIFY_STRINGstatic intDEFAULT_CACHE_TIMEOUTprotected com.google.common.cache.Cache<String,PropertiesCache.PropertiesHolder>m_cache
-
Constructor Summary
Constructors Modifier Constructor Description PropertiesCache()protectedPropertiesCache(com.google.common.cache.CacheBuilder<Object,Object> cacheBuilder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()clearPropertiesfindProperties(File propFile)findPropertiesPropertiesgetProperties(File propFile)Get the current properties object from the cache loading it in memoryStringgetProperty(File propFile, String key)getPropertyvoidsaveProperties(File propFile, Map<String,String> attributeMappings)voidsaveProperties(File propFile, Properties properties)savePropertiesvoidsetProperty(File propFile, String key, String value)setPropertyvoidupdateProperties(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- aFileobject.- Returns:
- a
Propertiesobject. - Throws:
IOException- if any.
-
findProperties
public Properties findProperties(File propFile) throws IOException
findProperties
- Parameters:
propFile- aFileobject.- Returns:
- a
Propertiesobject. - Throws:
IOException- if any.
-
saveProperties
public void saveProperties(File propFile, Properties properties) throws IOException
saveProperties
- Parameters:
propFile- aFileobject.properties- aPropertiesobject.- 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- aFileobject.props- aMapobject.- Throws:
IOException- if any.
-
setProperty
public void setProperty(File propFile, String key, String value) throws IOException
setProperty
- Parameters:
propFile- aFileobject.key- aStringobject.value- aStringobject.- Throws:
IOException- if any.
-
getProperty
public String getProperty(File propFile, String key) throws IOException
getProperty
- Parameters:
propFile- aFileobject.key- aStringobject.- Returns:
- a
Stringobject. - Throws:
IOException- if any.
-
-