org.wanghy.cache.interceptor
Class AbstractNameMatchCacheAttributeSource

java.lang.Object
  extended byorg.wanghy.cache.interceptor.AbstractNameMatchCacheAttributeSource
Direct Known Subclasses:
NameMatchCacheFlushAttributeSource, NameMatchCachingAttributeSource

public abstract class AbstractNameMatchCacheAttributeSource
extends Object

Template for classes that allow attributes to be matched by registered name.

Version:
$Revision: 1.4 $ $Date: 2005/04/07 22:32:38 $
Author:
Alex Ruiz

Field Summary
private  Map attributeMap
          Map containing instances of CacheAttribute.
private static Log logger
          Message Logger.
 
Constructor Summary
AbstractNameMatchCacheAttributeSource()
          Constructor.
 
Method Summary
protected  void addAttribute(String methodName, CacheAttribute cacheAttribute)
          Add an attribute for a caching method.
protected  Map getAttributeMap()
          Returns an unmodifiable view of attributeMap.
protected  CacheAttribute getCacheAttribute(Method method)
          Returns an instance of CacheAttribute for the intercepted method.
protected abstract  PropertyEditor getCacheAttributeEditor()
          Returns a property editor that creates instances of CacheAttribute.
protected  boolean isMatch(String methodName, String mappedName)
          Returns true if the given method name matches the mapped name.
 void setProperties(Properties cacheAttributes)
          Parses the given properties into a name/attribute map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static Log logger
Message Logger.


attributeMap

private Map attributeMap
Map containing instances of CacheAttribute. The key of each entry is the name of the method to attach the attribute to.

Constructor Detail

AbstractNameMatchCacheAttributeSource

public AbstractNameMatchCacheAttributeSource()
Constructor.

Method Detail

addAttribute

protected final void addAttribute(String methodName,
                                  CacheAttribute cacheAttribute)
Add an attribute for a caching method. Method names can end with "*" for matching multiple methods.

Parameters:
methodName - the name of the method
cacheAttribute - attribute associated with the method

getAttributeMap

protected final Map getAttributeMap()
Returns an unmodifiable view of attributeMap.

Returns:
an unmodifiable view of the member variable attributeMap.

getCacheAttributeEditor

protected abstract PropertyEditor getCacheAttributeEditor()
Returns a property editor that creates instances of CacheAttribute.

Returns:
a property editor for cache attributes.

isMatch

protected boolean isMatch(String methodName,
                          String mappedName)
Returns true if the given method name matches the mapped name. The default implementation checks for "xxx*" and "*xxx" matches.

Parameters:
methodName - the method name of the class.
mappedName - the name in the descriptor.
Returns:
true if the names match.

setProperties

public final void setProperties(Properties cacheAttributes)
Parses the given properties into a name/attribute map. Expects method names as keys and String attributes definitions as values, parsable into CacheAttribute..

Parameters:
cacheAttributes - the given properties.

getCacheAttribute

protected final CacheAttribute getCacheAttribute(Method method)
Returns an instance of CacheAttribute for the intercepted method.

Parameters:
method - the definition of the intercepted method.
Returns:
a metadata attribute from the intercepted method.


Copyright © 2004-2005 Alex Ruiz. All Rights Reserved.