com.googlecode.ehcache.annotations.impl
Class CacheAttributeSourceImpl

java.lang.Object
  extended by com.googlecode.ehcache.annotations.impl.CacheAttributeSourceImpl
All Implemented Interfaces:
CacheAttributeSource, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.InitializingBean

public class CacheAttributeSourceImpl
extends java.lang.Object
implements CacheAttributeSource, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.InitializingBean

Provides logic for determining if a class + method are advised and to then setup the data needed for the advice.

Version:
$Revision: 659 $
Author:
Eric Dalquist

Field Summary
protected  org.slf4j.Logger logger
          Logger available to subclasses.
 
Constructor Summary
CacheAttributeSourceImpl()
           
 
Method Summary
 void afterPropertiesSet()
           
protected  boolean allowPublicMethodsOnly()
          Should only public methods be allowed to be advised?
 AdviceType getAdviceType(java.lang.reflect.Method method, java.lang.Class<?> targetClass)
          Determines if the method has should be cached or involved with cache entry removal.
 CacheableAttribute getCacheableAttribute(java.lang.reflect.Method method, java.lang.Class<?> targetClass)
          Gets the runtime caching information for a method.
protected  CacheableInterceptor getCacheInterceptor(java.lang.String cacheableInteceptorName)
          Get the CacheableInterceptor by name.
protected  CacheKeyGenerator<? extends java.io.Serializable> getCacheKeyGenerator(java.lang.String keyGeneratorName, KeyGenerator keyGenerator)
          Get the CacheKeyGenerator by name.
protected  net.sf.ehcache.CacheManager getCacheManager()
           
protected  CacheResolverFactory getCacheResolverFactory(java.lang.String resolverFactoryName, ResolverFactory resolverFactory)
          Get the CacheResolverFactory by name.
protected  CacheKeyGenerator<? extends java.io.Serializable> getOrCreateCacheKeyGenerator(KeyGenerator keyGenerator)
           
protected  CacheResolverFactory getOrCreateCacheResolverFactory(ResolverFactory resolverFactory)
           
protected
<T> T
getOrCreateChildBean(java.lang.Class<T> beanType, java.lang.String beanClass, Property[] properties)
           
 TriggersRemoveAttribute getTriggersRemoveAttribute(java.lang.reflect.Method method, java.lang.Class<?> targetClass)
          Gets the runtime triggers-remove information for a method.
protected  TriggersRemoveInterceptor getTriggersRemoveInterceptor(java.lang.String triggersRemoveInterceptorName)
          Get the TriggersRemoveInterceptor by name.
protected  CacheableAttribute parseCacheableAnnotation(Cacheable ann, java.lang.reflect.Method method, ParameterMask parameterMask)
          Construct a CacheableAttribute from a Cacheable annotation.
protected  ParameterMask parsePartialCacheKeyAnnotations(java.lang.reflect.Method method)
          Parse the parameters annotated with PartialCacheKey.
protected  TriggersRemoveAttribute parseTriggersRemoveAnnotation(TriggersRemove ann, java.lang.reflect.Method method, ParameterMask parameterMask)
          Construct a TriggersRemoveAttribute from a TriggersRemove annotation.
 void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
           
 void setCacheManager(net.sf.ehcache.CacheManager cacheManager)
           
 void setCacheResolverFactory(CacheResolverFactory cacheResolverFactory)
           
 void setCreateCaches(boolean createCaches)
           
 void setDefaultCacheableInterceptor(CacheableInterceptor defaultCacheableInterceptor)
           
 void setDefaultCacheKeyGenerator(CacheKeyGenerator<? extends java.io.Serializable> defaultCacheKeyGenerator)
           
 void setDefaultTriggersRemoveInterceptor(TriggersRemoveInterceptor defaultTriggersRemoveInterceptor)
           
 void setExecutor(org.springframework.scheduling.SchedulingTaskExecutor executor)
           
 void setReflectionHelper(ReflectionHelper reflectionHelper)
           
 void setScheduler(java.lang.Object scheduler)
           
 void setSelfPopulatingCacheScope(SelfPopulatingCacheScope selfPopulatingCacheScope)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.slf4j.Logger logger
Logger available to subclasses.

Constructor Detail

CacheAttributeSourceImpl

public CacheAttributeSourceImpl()
Method Detail

setScheduler

public void setScheduler(java.lang.Object scheduler)

setExecutor

public void setExecutor(org.springframework.scheduling.SchedulingTaskExecutor executor)

setBeanFactory

public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
                    throws org.springframework.beans.BeansException
Specified by:
setBeanFactory in interface org.springframework.beans.factory.BeanFactoryAware
Throws:
org.springframework.beans.BeansException

setCreateCaches

public void setCreateCaches(boolean createCaches)

setDefaultCacheKeyGenerator

public void setDefaultCacheKeyGenerator(CacheKeyGenerator<? extends java.io.Serializable> defaultCacheKeyGenerator)

setDefaultCacheableInterceptor

public void setDefaultCacheableInterceptor(CacheableInterceptor defaultCacheableInterceptor)

setDefaultTriggersRemoveInterceptor

public void setDefaultTriggersRemoveInterceptor(TriggersRemoveInterceptor defaultTriggersRemoveInterceptor)

setSelfPopulatingCacheScope

public void setSelfPopulatingCacheScope(SelfPopulatingCacheScope selfPopulatingCacheScope)

setCacheManager

public void setCacheManager(net.sf.ehcache.CacheManager cacheManager)

setReflectionHelper

public void setReflectionHelper(ReflectionHelper reflectionHelper)

setCacheResolverFactory

public void setCacheResolverFactory(CacheResolverFactory cacheResolverFactory)

afterPropertiesSet

public void afterPropertiesSet()
                        throws java.lang.Exception
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
java.lang.Exception

getAdviceType

public AdviceType getAdviceType(java.lang.reflect.Method method,
                                java.lang.Class<?> targetClass)
Description copied from interface: CacheAttributeSource
Determines if the method has should be cached or involved with cache entry removal. Returns AdviceType.NONE if the method doesn't participate with either.

Specified by:
getAdviceType in interface CacheAttributeSource
Parameters:
method - The method to inspect
targetClass - The class the method exists on
Returns:
The type of advice on the method, AdviceType.NONE if the method is not advised. Will never return null.

getCacheableAttribute

public CacheableAttribute getCacheableAttribute(java.lang.reflect.Method method,
                                                java.lang.Class<?> targetClass)
Description copied from interface: CacheAttributeSource
Gets the runtime caching information for a method. If the method is not eligible for caching null is returned.

Specified by:
getCacheableAttribute in interface CacheAttributeSource
Parameters:
method - The method to inspect
targetClass - The class the method exists on
Returns:
Runtime caching configuration for the method, null if the method is not cachable.

getTriggersRemoveAttribute

public TriggersRemoveAttribute getTriggersRemoveAttribute(java.lang.reflect.Method method,
                                                          java.lang.Class<?> targetClass)
Description copied from interface: CacheAttributeSource
Gets the runtime triggers-remove information for a method. If the method is not eligible for triggers-remove null is returned.

Specified by:
getTriggersRemoveAttribute in interface CacheAttributeSource
Parameters:
method - The method to inspect
targetClass - The class the method exists on
Returns:
Runtime triggers-remove configuration for the method, null if the method is not involved with triggers-remove.

allowPublicMethodsOnly

protected boolean allowPublicMethodsOnly()
Should only public methods be allowed to be advised?

The default implementation returns false.


getCacheManager

protected net.sf.ehcache.CacheManager getCacheManager()
Returns:
The injected CacheManager.

parsePartialCacheKeyAnnotations

protected ParameterMask parsePartialCacheKeyAnnotations(java.lang.reflect.Method method)
Parse the parameters annotated with PartialCacheKey.

Parameters:
method - The method who's parameters should be checked.
Returns:
The parameter mask for the annotated parameters.

parseCacheableAnnotation

protected CacheableAttribute parseCacheableAnnotation(Cacheable ann,
                                                      java.lang.reflect.Method method,
                                                      ParameterMask parameterMask)
Construct a CacheableAttribute from a Cacheable annotation.

Parameters:
ann - The annotation to build the attributes from
Returns:
The constructed cacheable advise attributes

parseTriggersRemoveAnnotation

protected TriggersRemoveAttribute parseTriggersRemoveAnnotation(TriggersRemove ann,
                                                                java.lang.reflect.Method method,
                                                                ParameterMask parameterMask)
Construct a TriggersRemoveAttribute from a TriggersRemove annotation.

Parameters:
ann - The annotation to build the attributes from
Returns:
The constructed triggers remove advise attributes

getCacheInterceptor

protected final CacheableInterceptor getCacheInterceptor(java.lang.String cacheableInteceptorName)
Get the CacheableInterceptor by name. Returning a default resolver factory if the name is empty or null

Parameters:
resolverFactoryName - Name of the resolver factory to retrieve
Returns:
The named generator or the default generator if the name was empty or null

getTriggersRemoveInterceptor

protected final TriggersRemoveInterceptor getTriggersRemoveInterceptor(java.lang.String triggersRemoveInterceptorName)
Get the TriggersRemoveInterceptor by name. Returning a default resolver factory if the name is empty or null

Parameters:
resolverFactoryName - Name of the resolver factory to retrieve
Returns:
The named generator or the default generator if the name was empty or null

getCacheResolverFactory

protected final CacheResolverFactory getCacheResolverFactory(java.lang.String resolverFactoryName,
                                                             ResolverFactory resolverFactory)
Get the CacheResolverFactory by name. Returning a default resolver factory if the name is empty or null

Parameters:
resolverFactoryName - Name of the resolver factory to retrieve
Returns:
The named generator or the default generator if the name was empty or null

getCacheKeyGenerator

protected final CacheKeyGenerator<? extends java.io.Serializable> getCacheKeyGenerator(java.lang.String keyGeneratorName,
                                                                                       KeyGenerator keyGenerator)
Get the CacheKeyGenerator by name. Returning a default generator if the name is empty or null

Parameters:
keyGeneratorName - Name of the generator to retrieve
Returns:
The named generator or the default generator if the name was empty or null

getOrCreateCacheKeyGenerator

protected final CacheKeyGenerator<? extends java.io.Serializable> getOrCreateCacheKeyGenerator(KeyGenerator keyGenerator)

getOrCreateCacheResolverFactory

protected final CacheResolverFactory getOrCreateCacheResolverFactory(ResolverFactory resolverFactory)

getOrCreateChildBean

protected final <T> T getOrCreateChildBean(java.lang.Class<T> beanType,
                                           java.lang.String beanClass,
                                           Property[] properties)


Copyright © 2011. All Rights Reserved.