Package org.apache.tiles.definition.dao
Class CachingLocaleUrlDefinitionDAO
- java.lang.Object
-
- org.apache.tiles.definition.dao.BaseLocaleUrlDefinitionDAO
-
- org.apache.tiles.definition.dao.CachingLocaleUrlDefinitionDAO
-
- All Implemented Interfaces:
DefinitionDAO<java.util.Locale>
,PatternDefinitionResolverAware<java.util.Locale>
,RefreshMonitor
- Direct Known Subclasses:
ResolvingLocaleUrlDefinitionDAO
public class CachingLocaleUrlDefinitionDAO extends BaseLocaleUrlDefinitionDAO implements PatternDefinitionResolverAware<java.util.Locale>
A definitions DAO (loading URLs and using Locale as a customization key) that caches definitions that have been loaded in a raw way (i.e. with inheritance that is not resolved).
It can check if the URLs change, but by default this feature is turned off.
- Since:
- 2.1.0
- Version:
- $Rev: 1752405 $ $Date: 2016-07-13 22:13:34 +1000 (Wed, 13 Jul 2016) $
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CHECK_REFRESH_INIT_PARAMETER
Initialization parameter to set whether we want to refresh URLs when they change.protected boolean
checkRefresh
Flag that, whentrue
, enables automatic checking of URLs changing.protected PatternDefinitionResolver<java.util.Locale>
definitionResolver
Resolves definitions using patterns.protected java.util.Map<java.util.Locale,java.util.Map<java.lang.String,Definition>>
locale2definitionMap
The locale-specific set of definitions objects.-
Fields inherited from class org.apache.tiles.definition.dao.BaseLocaleUrlDefinitionDAO
applicationContext, lastModifiedDates, reader, sources
-
-
Constructor Summary
Constructors Constructor Description CachingLocaleUrlDefinitionDAO(org.apache.tiles.request.ApplicationContext applicationContext)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.Map<java.lang.String,Definition>
checkAndloadDefinitions(java.util.Locale customizationKey)
Checks if sources have changed.protected java.util.Map<java.lang.String,Definition>
copyDefinitionMap(java.util.Map<java.lang.String,Definition> localeDefsMap)
Copies the definition map to be passed to a higher level of customization key.Definition
getDefinition(java.lang.String name, java.util.Locale customizationKey)
Returns a definition, given its name and the customization key.protected Definition
getDefinitionFromResolver(java.lang.String name, java.util.Locale customizationKey)
Returns a definition from the definition resolver.java.util.Map<java.lang.String,Definition>
getDefinitions(java.util.Locale customizationKey)
Returns all the definitions used of a customization key.protected java.util.Map<java.lang.String,Definition>
loadDefinitions(java.util.Locale customizationKey)
Tries to load definitions if necessary.protected java.util.Map<java.lang.String,Definition>
loadDefinitionsFromResources(java.util.Locale customizationKey)
Loads definitions from the sources.protected java.util.Map<java.lang.String,Definition>
loadParentDefinitions(java.util.Locale parentLocale)
Loads parent definitions, i.e.protected java.util.Map<java.lang.String,Definition>
loadRawDefinitionsFromResources(java.util.Locale customizationKey)
Loads the raw definitions from the sources associated with a locale.void
setCheckRefresh(boolean checkRefresh)
Sets the flag to check source refresh.void
setPatternDefinitionResolver(PatternDefinitionResolver<java.util.Locale> definitionResolver)
Sets the pattern definition resolver to use.-
Methods inherited from class org.apache.tiles.definition.dao.BaseLocaleUrlDefinitionDAO
loadDefinitionsFromResource, refreshRequired, setReader, setSources
-
-
-
-
Field Detail
-
CHECK_REFRESH_INIT_PARAMETER
public static final java.lang.String CHECK_REFRESH_INIT_PARAMETER
Initialization parameter to set whether we want to refresh URLs when they change.- Since:
- 2.1.0
- See Also:
- Constant Field Values
-
locale2definitionMap
protected java.util.Map<java.util.Locale,java.util.Map<java.lang.String,Definition>> locale2definitionMap
The locale-specific set of definitions objects.- Since:
- 2.1.0
-
checkRefresh
protected boolean checkRefresh
Flag that, whentrue
, enables automatic checking of URLs changing.- Since:
- 2.1.0
-
definitionResolver
protected PatternDefinitionResolver<java.util.Locale> definitionResolver
Resolves definitions using patterns.- Since:
- 2.2.0
-
-
Method Detail
-
setPatternDefinitionResolver
public void setPatternDefinitionResolver(PatternDefinitionResolver<java.util.Locale> definitionResolver)
Sets the pattern definition resolver to use.- Specified by:
setPatternDefinitionResolver
in interfacePatternDefinitionResolverAware<java.util.Locale>
- Parameters:
definitionResolver
- The pattern definition resolver.
-
getDefinition
public Definition getDefinition(java.lang.String name, java.util.Locale customizationKey)
Returns a definition, given its name and the customization key.- Specified by:
getDefinition
in interfaceDefinitionDAO<java.util.Locale>
- Parameters:
name
- The name of the definition.customizationKey
- The customization key.- Returns:
- The requested definition, if found, otherwise
null
. The inheritance of the definition must not be resolved.
-
getDefinitions
public java.util.Map<java.lang.String,Definition> getDefinitions(java.util.Locale customizationKey)
Returns all the definitions used of a customization key.- Specified by:
getDefinitions
in interfaceDefinitionDAO<java.util.Locale>
- Parameters:
customizationKey
- The customization key.- Returns:
- All the definitions that are connected to the customization key. The inheritance of the definitions must not be resolved.
-
setCheckRefresh
public void setCheckRefresh(boolean checkRefresh)
Sets the flag to check source refresh. If not called, the default isfalse
.- Parameters:
checkRefresh
- Whentrue
, enables automatic checking of sources changing.- Since:
- 2.1.0
-
getDefinitionFromResolver
protected Definition getDefinitionFromResolver(java.lang.String name, java.util.Locale customizationKey)
Returns a definition from the definition resolver.- Parameters:
name
- The name of the definition.customizationKey
- The customization key to use.- Returns:
- The resolved definition.
-
checkAndloadDefinitions
protected java.util.Map<java.lang.String,Definition> checkAndloadDefinitions(java.util.Locale customizationKey)
Checks if sources have changed. If yes, it clears the cache. Then continues loading definitions.- Parameters:
customizationKey
- The locale to use when loading sources.- Returns:
- The loaded definitions.
- Since:
- 2.1.0
-
loadDefinitions
protected java.util.Map<java.lang.String,Definition> loadDefinitions(java.util.Locale customizationKey)
Tries to load definitions if necessary.- Parameters:
customizationKey
- The locale to use when loading sources.- Returns:
- The loaded definitions.
- Since:
- 2.1.0
-
loadDefinitionsFromResources
protected java.util.Map<java.lang.String,Definition> loadDefinitionsFromResources(java.util.Locale customizationKey)
Loads definitions from the sources.- Parameters:
customizationKey
- The locale to use when loading Resources.- Returns:
- The loaded definitions.
- Since:
- 2.1.0
-
loadRawDefinitionsFromResources
protected java.util.Map<java.lang.String,Definition> loadRawDefinitionsFromResources(java.util.Locale customizationKey)
Loads the raw definitions from the sources associated with a locale.- Parameters:
customizationKey
- The locale to use when loading Resources.- Returns:
- The loaded definitions.
- Since:
- 2.1.3
-
loadParentDefinitions
protected java.util.Map<java.lang.String,Definition> loadParentDefinitions(java.util.Locale parentLocale)
Loads parent definitions, i.e. definitions mapped to a parent locale.- Parameters:
parentLocale
- The locale to use when loading URLs.- Returns:
- The loaded parent definitions.
- Since:
- 2.1.0
-
copyDefinitionMap
protected java.util.Map<java.lang.String,Definition> copyDefinitionMap(java.util.Map<java.lang.String,Definition> localeDefsMap)
Copies the definition map to be passed to a higher level of customization key.- Parameters:
localeDefsMap
- The map of definition to be copied.- Returns:
- The copy of the definition map. This particular implementation
return the
localeDefsMap
itself. - Since:
- 2.1.4
-
-