org.apache.bval
Class MetaBeanCache

java.lang.Object
  extended by org.apache.bval.MetaBeanCache
All Implemented Interfaces:
Serializable, MetaBeanFinder

public class MetaBeanCache
extends Object
implements MetaBeanFinder, Serializable

Description: a cache to hold metabeans by id and by class.

See Also:
Serialized Form

Field Summary
protected  ConcurrentMap<Class<?>,MetaBean> cacheByClass
          Cache keyed by class.
protected  ConcurrentMap<String,MetaBean> cacheById
          Cache keyed by id.
 
Constructor Summary
MetaBeanCache()
          Create a new MetaBeanCache instance.
MetaBeanCache(Map<String,MetaBean> beans)
          Create a new MetaBeanCache instance.
 
Method Summary
 void cache(MetaBean beanInfo)
          Cache the specified MetaBean.
 void clear()
          Clear the cache.
 Map<String,MetaBean> findAll()
          Return all cached MetaBeans by id.
 MetaBean findForClass(Class<?> clazz)
          Find the MetaBean for the specified class.
 MetaBean findForId(String beanInfoId)
          Find a MetaBean with a certain id.
 void removeFromCache(MetaBean beanInfo)
          Remove a single MetaBean from the cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cacheById

protected final ConcurrentMap<String,MetaBean> cacheById
Cache keyed by id.


cacheByClass

protected final ConcurrentMap<Class<?>,MetaBean> cacheByClass
Cache keyed by class.

Constructor Detail

MetaBeanCache

public MetaBeanCache()
Create a new MetaBeanCache instance.


MetaBeanCache

public MetaBeanCache(Map<String,MetaBean> beans)
Create a new MetaBeanCache instance.

Parameters:
beans -
Method Detail

clear

public void clear()
Clear the cache.


findForId

public MetaBean findForId(String beanInfoId)
Find a MetaBean with a certain id.

Specified by:
findForId in interface MetaBeanFinder
Parameters:
beanInfoId - - symbolic unique name of Meta Info
Returns:
BeanInfo

findForClass

public MetaBean findForClass(Class<?> clazz)
Find the MetaBean for the specified class.

Specified by:
findForClass in interface MetaBeanFinder
Parameters:
clazz - - bean class
Returns:
BeanInfo (never null)

findAll

public Map<String,MetaBean> findAll()
Return all cached MetaBeans by id.

Returns:
live map

cache

public void cache(MetaBean beanInfo)
Cache the specified MetaBean.

Parameters:
beanInfo -

removeFromCache

public void removeFromCache(MetaBean beanInfo)
Remove a single MetaBean from the cache.

Parameters:
beanInfo -


Copyright © 2010-2012 Apache Software Foundation. All Rights Reserved.