Class CacheManager
- java.lang.Object
-
- org.neotropic.kuwaiba.core.persistence.reference.extras.caching.CacheManager
-
public class CacheManager extends Object
Manages the caching strategy- Author:
- Charles Edward Bedon Cortazar <charles.bedon@kuwaiba.org>
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addConfigurationValue(String configVariableName, Object configVariableValue)
Adds (or replaces) the value of a configuration variable.void
addFilterDefinition(String className, FilterDefinition filterDefinition)
Adds or replaces an entry of a single filter in all the filter definitions index for a class.void
addUpstreamClassHierarchy(String className, List<ClassMetadataLight> superClasses)
Adds or replaces an entry in the upstream class hierarchy index.void
addValidatorDefinitions(String className, List<ValidatorDefinition> validatorDefinitions)
Adds or replaces an entry in the validator definitions index.void
clearAll()
Clears all cached informationvoid
clearClassCache()
Clears only the cached elements associated to the data model.void
clearFiltersCache()
Clears the cached filter definitionsvoid
clearValidatorDefinitionsCache()
Clears the cached validator definitionsCacheSlot
getCacheSlot(String cacheSlotName)
HashMap<String,CacheSlot>
getCacheSlots()
ClassMetadata
getClass(String className)
Tries to retrieve a cached classObject
getConfigurationVariableValue(String configVariableName)
Gets the cached value of a configuration variable.FilterDefinition
getFilterDefinitionByClassNameAndFilterId(String className, long filterId)
Retrieves the cached filter definitions associated to the given class.List<FilterDefinition>
getFilterDefinitionsForClass(String className)
Retrieves the cached filter definitions associated to the given class.GroupProfile
getGroup(String groupName)
Tries to retrieve a cached userstatic CacheManager
getInstance()
GenericObjectList
getListType(String listTypeName)
Tries to retrieve a cached list typeList<ClassMetadata>
getPossibleChildren(String parent)
List<String>
getPossibleSpecialChildren(String parent)
List<ClassMetadataLight>
getSubclasses(String className)
List<ClassMetadataLight>
getSubclassesNorecursive(String className)
List<Object>
getUniqueAttributeValues(String className, String attributeName)
HashMap<String,List<Object>>
getUniqueClassAttributes(String className)
List<ClassMetadataLight>
getUpstreamClassHierarchy(String className)
Retrieves the cached upstream class hierarchy of a given class.UserProfile
getUser(String userName)
Tries to retrieve a cached userList<ValidatorDefinition>
getValidatorDefinitions(String className)
Retrieves the cached validator definitions associated to the given class.void
putCacheSlot(String cacheSlotName, Object content, int hoursOfValidity)
void
putClass(ClassMetadata newClass)
Put/replaces an entry into the class cachevoid
putGroup(GroupProfile newGroup)
Put/replaces an entry into the group cachevoid
putListType(GenericObjectList newListType)
Put/replaces an entry into the list type cachevoid
putPossibleChild(String parent, ClassMetadata child)
Adds an entry to the possible children indexvoid
putPossibleChildren(String parent, List<ClassMetadata> children)
Adds an entry to the possible children indexvoid
putPossibleSpecialChild(String parent, String child)
Adds a single entry to the possible special children indexvoid
putPossibleSpecialChildren(String parent, List<String> children)
Adds an entry to the possible special children indexvoid
putSubclasses(String className, List<ClassMetadataLight> subClasses)
Adds an entry to the subclasses indexvoid
putSubclassesNorecursive(String className, List<ClassMetadataLight> subClasses)
Adds an entry to the subclasses indexvoid
putSubClassNoRecursive(String parent, ClassMetadataLight newSubClass)
void
putUniqueAttributeValueIndex(String className, String attributeName, Object value)
adds an entry for every unique attribute value of every class that has unique attributesvoid
putUniqueAttributeValuesIndex(String className, String attributeName, List<Object> values)
void
putUser(UserProfile newUser)
Put/replaces an entry into the users cachevoid
removeClass(String className)
Remove a class from cachevoid
removeConfigurationVariableValue(String configVariableName)
Removes a cached value of a configuration variable (if present).void
removeFilterDefinitionsForClass(String className, long filterId)
Removes a cached filter definitionvoid
removeGroup(String groupName)
Removes an entry into the group cachevoid
removeListType(String listTypeName)
Removes an entry into the list typevoid
removeUniqueAttribute(String className, String attributeName)
void
removeUniqueAttributeValue(String className, String attributeName, Object attributeValue)
void
removeUser(String userName)
Removes an entry into the users cachevoid
setCacheSlots(HashMap<String,CacheSlot> cacheSlots)
void
updateFilterInFilterDefinition(String className, FilterDefinition filterDefinition)
Updates or replaces the Filter of an entry in the filter definitions index.
-
-
-
Method Detail
-
getInstance
public static CacheManager getInstance()
-
getClass
public ClassMetadata getClass(String className)
Tries to retrieve a cached class- Parameters:
className
- the class to be retrieved from the cache- Returns:
- the cached version of the class. Null if it's not cached
-
putClass
public void putClass(ClassMetadata newClass)
Put/replaces an entry into the class cache- Parameters:
newClass
-
-
removeClass
public void removeClass(String className)
Remove a class from cache- Parameters:
className
- The class name
-
putPossibleChildren
public void putPossibleChildren(String parent, List<ClassMetadata> children)
Adds an entry to the possible children index- Parameters:
parent
-children
-
-
putPossibleSpecialChildren
public void putPossibleSpecialChildren(String parent, List<String> children)
Adds an entry to the possible special children index- Parameters:
parent
- The parent classchildren
- the list of possible special children classes
-
putSubClassNoRecursive
public void putSubClassNoRecursive(String parent, ClassMetadataLight newSubClass)
-
putSubclasses
public void putSubclasses(String className, List<ClassMetadataLight> subClasses)
Adds an entry to the subclasses index- Parameters:
className
- the given classsubClasses
- the subclasses of the given class
-
putSubclassesNorecursive
public void putSubclassesNorecursive(String className, List<ClassMetadataLight> subClasses)
Adds an entry to the subclasses index- Parameters:
className
- the given classsubClasses
- the subclasses of the given class
-
putUniqueAttributeValueIndex
public void putUniqueAttributeValueIndex(String className, String attributeName, Object value)
adds an entry for every unique attribute value of every class that has unique attributes- Parameters:
className
- class nameattributeName
- attribute namevalue
- new value of an unique attribute
-
putUniqueAttributeValuesIndex
public void putUniqueAttributeValuesIndex(String className, String attributeName, List<Object> values)
-
putPossibleChild
public void putPossibleChild(String parent, ClassMetadata child)
Adds an entry to the possible children index- Parameters:
parent
-child
-
-
putPossibleSpecialChild
public void putPossibleSpecialChild(String parent, String child)
Adds a single entry to the possible special children index- Parameters:
parent
-child
-
-
getPossibleChildren
public List<ClassMetadata> getPossibleChildren(String parent)
-
getSubclasses
public List<ClassMetadataLight> getSubclasses(String className)
-
getSubclassesNorecursive
public List<ClassMetadataLight> getSubclassesNorecursive(String className)
-
getUniqueClassAttributes
public HashMap<String,List<Object>> getUniqueClassAttributes(String className)
-
getUniqueAttributeValues
public List<Object> getUniqueAttributeValues(String className, String attributeName)
-
getUser
public UserProfile getUser(String userName)
Tries to retrieve a cached user- Parameters:
userName
- the class to be retrieved from the cache- Returns:
- the cached version of the class. Null if it's not cached
-
putUser
public void putUser(UserProfile newUser)
Put/replaces an entry into the users cache- Parameters:
newUser
- user to be added
-
getGroup
public GroupProfile getGroup(String groupName)
Tries to retrieve a cached user- Parameters:
groupName
- the class to be retrieved from the cache- Returns:
- the cached version of the group. Null if it's not cached
-
putGroup
public void putGroup(GroupProfile newGroup)
Put/replaces an entry into the group cache- Parameters:
newGroup
- user to be added
-
removeUser
public void removeUser(String userName)
Removes an entry into the users cache- Parameters:
userName
-
-
removeGroup
public void removeGroup(String groupName)
Removes an entry into the group cache- Parameters:
groupName
-
-
removeUniqueAttributeValue
public void removeUniqueAttributeValue(String className, String attributeName, Object attributeValue)
-
getListType
public GenericObjectList getListType(String listTypeName)
Tries to retrieve a cached list type- Parameters:
listTypeName
- the list type to be retrieved from the cache- Returns:
- the cached version of the group. Null if it's not cached
-
putListType
public void putListType(GenericObjectList newListType)
Put/replaces an entry into the list type cache- Parameters:
newListType
- list type to be added
-
removeListType
public void removeListType(String listTypeName)
Removes an entry into the list type- Parameters:
listTypeName
- list type to be deleted
-
addUpstreamClassHierarchy
public void addUpstreamClassHierarchy(String className, List<ClassMetadataLight> superClasses)
Adds or replaces an entry in the upstream class hierarchy index.- Parameters:
className
- The name of the class the provided class hierarchy belongs to.superClasses
- The super classes of the given class (including itself)
-
getUpstreamClassHierarchy
public List<ClassMetadataLight> getUpstreamClassHierarchy(String className)
Retrieves the cached upstream class hierarchy of a given class.- Parameters:
className
- The name of the class.- Returns:
- The list of cached super classes up to RootObject (including itself). Null of the class provided is not cached
-
addValidatorDefinitions
public void addValidatorDefinitions(String className, List<ValidatorDefinition> validatorDefinitions)
Adds or replaces an entry in the validator definitions index.- Parameters:
className
- The name of the class the provided class hierarchy belongs to.validatorDefinitions
- The super classes of the given class (including itself)
-
getValidatorDefinitions
public List<ValidatorDefinition> getValidatorDefinitions(String className)
Retrieves the cached validator definitions associated to the given class.- Parameters:
className
- The name of the class.- Returns:
- The list of cached validator definitions. Null of the class provided is not cached
-
clearValidatorDefinitionsCache
public void clearValidatorDefinitionsCache()
Clears the cached validator definitions
-
addFilterDefinition
public void addFilterDefinition(String className, FilterDefinition filterDefinition)
Adds or replaces an entry of a single filter in all the filter definitions index for a class.- Parameters:
className
- The name of the classfilterDefinition
- a filter definition for the class to be included in the cache
-
updateFilterInFilterDefinition
public void updateFilterInFilterDefinition(String className, FilterDefinition filterDefinition)
Updates or replaces the Filter of an entry in the filter definitions index. this happen when the script has changes an ins compiled again- Parameters:
className
- The name of the class the provided class hierarchy belongs to.filterDefinition
- the filter definition to update
-
getFilterDefinitionsForClass
public List<FilterDefinition> getFilterDefinitionsForClass(String className)
Retrieves the cached filter definitions associated to the given class.- Parameters:
className
- The name of the class.- Returns:
- The list of cached filter definitions. Null of the class provided is not cached
-
getFilterDefinitionByClassNameAndFilterId
public FilterDefinition getFilterDefinitionByClassNameAndFilterId(String className, long filterId)
Retrieves the cached filter definitions associated to the given class.- Parameters:
className
- The name of the class.filterId
- the filter definition id.- Returns:
- The list of cached filter definitions. Null of the class provided is not cached
-
removeFilterDefinitionsForClass
public void removeFilterDefinitionsForClass(String className, long filterId)
Removes a cached filter definition- Parameters:
className
- The name of the class.filterId
- the filter definition id.
-
clearFiltersCache
public void clearFiltersCache()
Clears the cached filter definitions
-
addConfigurationValue
public void addConfigurationValue(String configVariableName, Object configVariableValue)
Adds (or replaces) the value of a configuration variable.- Parameters:
configVariableName
- The name of the configuration variable.configVariableValue
- The value of the configuration value.
-
getConfigurationVariableValue
public Object getConfigurationVariableValue(String configVariableName)
Gets the cached value of a configuration variable.- Parameters:
configVariableName
- The name of the configuration variable.- Returns:
- The value of the config variable, or null if it is not cached.
-
removeConfigurationVariableValue
public void removeConfigurationVariableValue(String configVariableName)
Removes a cached value of a configuration variable (if present).- Parameters:
configVariableName
- The name of the config variable.
-
clearAll
public void clearAll()
Clears all cached information
-
clearClassCache
public void clearClassCache()
Clears only the cached elements associated to the data model. Call it after performing any change in the class hierarchy of the property of the classes. Note that this method doesn't actually clears the main classIndex, only de dependencies, such as the possibleChildrenIndex, possibleSpecialChildrenIndex, subClassesIndex, subClassesNoRecursiveIndex and uniqueClassAttributesIndex
-
-