Package org.apache.wicket.resource
Class PropertiesFactory
- java.lang.Object
-
- org.apache.wicket.resource.PropertiesFactory
-
- All Implemented Interfaces:
IPropertiesFactory
public class PropertiesFactory extends java.lang.Object implements IPropertiesFactory
Default implementation ofIPropertiesFactorywhich uses theIResourceStreamLocatoras defined byResourceSettings.getResourceStreamLocator()to load thePropertiesobjects. Depending on the settings, it will assignModificationWatchers to the loaded resources to support reloading.- Author:
- Juergen Donnerstag
- See Also:
ResourceSettings.getPropertiesFactory()
-
-
Constructor Summary
Constructors Constructor Description PropertiesFactory(IPropertiesFactoryContext context)Construct.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(IPropertiesChangeListener listener)Add a listener which will be called when a change to the underlying resource stream (e.g.protected voidaddToWatcher(java.lang.String path, org.apache.wicket.util.resource.IResourceStream resourceStream, org.apache.wicket.util.watch.IModificationWatcher watcher)Add the resource stream to the file being watchedvoidclearCache()Remove all cached properties.protected java.util.Map<java.lang.String,Properties>getCache()For subclasses to get access to the cachejava.util.List<IPropertiesLoader>getPropertiesLoaders()Gets theListof properties loader.Propertiesload(java.lang.Class<?> clazz, java.lang.String path)Load the properties associated with the pathprotected org.apache.wicket.util.value.ValueMaploadFromLoader(IPropertiesLoader loader, org.apache.wicket.util.resource.IResourceStream resourceStream)protected java.util.Map<java.lang.String,Properties>newPropertiesCache()
-
-
-
Constructor Detail
-
PropertiesFactory
public PropertiesFactory(IPropertiesFactoryContext context)
Construct.- Parameters:
context- context for properties factory
-
-
Method Detail
-
getPropertiesLoaders
public java.util.List<IPropertiesLoader> getPropertiesLoaders()
Gets theListof properties loader. You may add or remove properties loaders at your will.- Returns:
- the
Listof properties loader
-
newPropertiesCache
protected java.util.Map<java.lang.String,Properties> newPropertiesCache()
- Returns:
- new Cache implementation
-
addListener
public void addListener(IPropertiesChangeListener listener)
Description copied from interface:IPropertiesFactoryAdd a listener which will be called when a change to the underlying resource stream (e.g. properties file) has been detected- Specified by:
addListenerin interfaceIPropertiesFactory- See Also:
IPropertiesFactory.addListener(org.apache.wicket.resource.IPropertiesChangeListener)
-
clearCache
public final void clearCache()
Description copied from interface:IPropertiesFactoryRemove all cached properties.- Specified by:
clearCachein interfaceIPropertiesFactory- See Also:
IPropertiesFactory.clearCache()
-
load
public Properties load(java.lang.Class<?> clazz, java.lang.String path)
Description copied from interface:IPropertiesFactoryLoad the properties associated with the path- Specified by:
loadin interfaceIPropertiesFactory- Parameters:
clazz- The class requesting the propertiespath- The path to identify the resource- Returns:
- The properties
- See Also:
IPropertiesFactory.load(java.lang.Class, java.lang.String)
-
loadFromLoader
protected org.apache.wicket.util.value.ValueMap loadFromLoader(IPropertiesLoader loader, org.apache.wicket.util.resource.IResourceStream resourceStream)
- Parameters:
loader-resourceStream-- Returns:
- properties
-
addToWatcher
protected void addToWatcher(java.lang.String path, org.apache.wicket.util.resource.IResourceStream resourceStream, org.apache.wicket.util.watch.IModificationWatcher watcher)Add the resource stream to the file being watched- Parameters:
path-resourceStream-watcher-
-
getCache
protected final java.util.Map<java.lang.String,Properties> getCache()
For subclasses to get access to the cache- Returns:
- Map
-
-