org.javalid.core.support
Class CacheSupport

java.lang.Object
  extended by org.javalid.core.support.CacheSupport

public class CacheSupport
extends java.lang.Object

This special class provides cache support for the AnnotationValidatorImpl for caching bean instances. Access is only possible through one of the exposed methods, allowing the cache mechanism to change somewhere in the future if needed (e.g. using ehcache instead of the cache here).

Since:
1.0
Version:
1.0
Author:
M.Reuvers

Constructor Summary
CacheSupport()
           
 
Method Summary
 void addBeanToCache(java.lang.Object instance)
          Adds given instance to the cache (using instance.getClassName() as key).
 java.lang.Object getBeanFromCache(java.lang.Class clazz)
          Returns instance from cache if found, null otherwise.
 java.lang.Object getBeanFromCache(java.lang.String className)
          Returns instance from cache if found, null otherwise.
 boolean isBeanInCache(java.lang.Class clazz)
          Return true if for given clazz an instance is in the cache.
 boolean isBeanInCache(java.lang.String className)
          Return true if for given className an instance is in the cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CacheSupport

public CacheSupport()
Method Detail

isBeanInCache

public boolean isBeanInCache(java.lang.Class clazz)
Return true if for given clazz an instance is in the cache.

Parameters:
clazz - The clazz to check
Returns:
True if for given clazz an instance is in the cache

isBeanInCache

public boolean isBeanInCache(java.lang.String className)
Return true if for given className an instance is in the cache.

Parameters:
className - The className to check
Returns:
True if for given className an instance is in the cache

addBeanToCache

public void addBeanToCache(java.lang.Object instance)
Adds given instance to the cache (using instance.getClassName() as key). Overwrites any already existing under the same key.

Parameters:
instance - The instance to add to cache

getBeanFromCache

public java.lang.Object getBeanFromCache(java.lang.Class clazz)
Returns instance from cache if found, null otherwise. Uses clazz.getName() as key.

Parameters:
clazz - The class to check for
Returns:
Instance from cache if found, null otherwise.

getBeanFromCache

public java.lang.Object getBeanFromCache(java.lang.String className)
Returns instance from cache if found, null otherwise.

Parameters:
className - The className to get
Returns:
Instance from cache if found, null otherwise.