Top Description Inners Fields Constructors Methods
org.springframework.cache.config

pack-priv Class AnnotationDrivenCacheBeanDefinitionParser

extends Object
implements BeanDefinitionParser
Class Inheritance
All Implemented Interfaces
org.springframework.beans.factory.xml.BeanDefinitionParser
Imports
org.w3c.dom.Element, org.springframework.aop.config.AopNamespaceUtils, org.springframework.beans.factory.config.BeanDefinition, .RuntimeBeanReference, org.springframework.beans.factory.parsing.BeanComponentDefinition, .CompositeComponentDefinition, org.springframework.beans.factory.support.RootBeanDefinition, org.springframework.beans.factory.xml.BeanDefinitionParser, .ParserContext, org.springframework.cache.interceptor.BeanFactoryCacheOperationSourceAdvisor, .CacheInterceptor, org.springframework.lang.Nullable, org.springframework.util.ClassUtils, .StringUtils

org.springframework.beans.factory.xml.BeanDefinitionParser implementation that allows users to easily configure all the infrastructure beans required to enable annotation-driven cache demarcation.

By default, all proxies are created as JDK proxies. This may cause some problems if you are injecting objects as concrete classes rather than interfaces. To overcome this restriction you can set the 'proxy-target-class' attribute to 'true', which will result in class-based proxies being created.

If the JSR-107 API and Spring's JCache implementation are present, the necessary infrastructure beans required to handle methods annotated with CacheResult, CachePut, CacheRemove or CacheRemoveAll are also registered.

Authors
Costin Leau, Stephane Nicoll
Since
3.1

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
AnnotationDrivenCacheBeanDefinitionParser.JCacheCachingConfigurer

Configure the necessary infrastructure to support the standard JSR-107 caching annotations.

private static class
AnnotationDrivenCacheBeanDefinitionParser.SpringCachingConfigurer

Configure the necessary infrastructure to support the Spring's caching annotations.

Field Summary

Modifier and TypeField and Description
private static final String
private static final String
private static final boolean
private static final boolean

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public BeanDefinition
parse(Element
the element that is to be parsed into one or more BeanDefinitions
element
,
ParserContext
the object encapsulating the current state of the parsing process; provides access to a org.springframework.beans.factory.support.BeanDefinitionRegistry
parserContext
)

Implements org.springframework.beans.factory.xml.BeanDefinitionParser.parse.

Parses the '<cache:annotation-driven>' tag.
private static void
parseCacheResolution(Element element, BeanDefinition def, boolean setBoth)

Parse the cache resolution strategy to use.

private static void
private void
registerCacheAdvisor(Element element, ParserContext parserContext)

private void
registerCacheAspect(Element element, ParserContext parserContext)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CACHE_ASPECT_CLASS_NAMEback to summary
private static final String CACHE_ASPECT_CLASS_NAME
JCACHE_ASPECT_CLASS_NAMEback to summary
private static final String JCACHE_ASPECT_CLASS_NAME
jcacheImplPresentback to summary
private static final boolean jcacheImplPresent
jsr107Presentback to summary
private static final boolean jsr107Present

Constructor Detail

AnnotationDrivenCacheBeanDefinitionParserback to summary
pack-priv AnnotationDrivenCacheBeanDefinitionParser()

Method Detail

parseback to summary
public BeanDefinition parse(Element element, ParserContext parserContext)

Implements org.springframework.beans.factory.xml.BeanDefinitionParser.parse.

Parses the '<cache:annotation-driven>' tag. Will register an AutoProxyCreator with the container as necessary.

Parameters
element:Element

Doc from org.springframework.beans.factory.xml.BeanDefinitionParser.parse.

the element that is to be parsed into one or more BeanDefinitions

parserContext:ParserContext

Doc from org.springframework.beans.factory.xml.BeanDefinitionParser.parse.

the object encapsulating the current state of the parsing process; provides access to a org.springframework.beans.factory.support.BeanDefinitionRegistry

Returns:BeanDefinition

Doc from org.springframework.beans.factory.xml.BeanDefinitionParser.parse.

the primary BeanDefinition

Annotations
@Override
@Nullable
parseCacheResolutionback to summary
private static void parseCacheResolution(Element element, BeanDefinition def, boolean setBoth)

Parse the cache resolution strategy to use. If a 'cache-resolver' attribute is set, it is injected. Otherwise the 'cache-manager' is set. If setBoth is true, both service are actually injected.

parseErrorHandlerback to summary
private static void parseErrorHandler(Element element, BeanDefinition def)
registerCacheAdvisorback to summary
private void registerCacheAdvisor(Element element, ParserContext parserContext)
registerCacheAspectback to summary
private void registerCacheAspect(Element element, ParserContext parserContext)
org.springframework.cache.config back to summary

private Class AnnotationDrivenCacheBeanDefinitionParser.JCacheCachingConfigurer

extends Object
Class Inheritance
  • java.lang.Object
  • org.springframework.cache.config.AnnotationDrivenCacheBeanDefinitionParser.JCacheCachingConfigurer

Configure the necessary infrastructure to support the standard JSR-107 caching annotations.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static RootBeanDefinition
private static void
registerCacheAdvisor(Element element, ParserContext parserContext)

private static void
registerCacheAspect(Element element, ParserContext parserContext)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

JCacheCachingConfigurerback to summary
private JCacheCachingConfigurer()

Method Detail

createJCacheOperationSourceBeanDefinitionback to summary
private static RootBeanDefinition createJCacheOperationSourceBeanDefinition(Element element, Object eleSource)
registerCacheAdvisorback to summary
private static void registerCacheAdvisor(Element element, ParserContext parserContext)
registerCacheAspectback to summary
private static void registerCacheAspect(Element element, ParserContext parserContext)
org.springframework.cache.config back to summary

private Class AnnotationDrivenCacheBeanDefinitionParser.SpringCachingConfigurer

extends Object
Class Inheritance
  • java.lang.Object
  • org.springframework.cache.config.AnnotationDrivenCacheBeanDefinitionParser.SpringCachingConfigurer

Configure the necessary infrastructure to support the Spring's caching annotations.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static void
registerCacheAdvisor(Element element, ParserContext parserContext)

private static void
registerCacheAspect(Element element, ParserContext parserContext)

Registers a cache aspect.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

SpringCachingConfigurerback to summary
private SpringCachingConfigurer()

Method Detail

registerCacheAdvisorback to summary
private static void registerCacheAdvisor(Element element, ParserContext parserContext)
registerCacheAspectback to summary
private static void registerCacheAspect(Element element, ParserContext parserContext)

Registers a cache aspect.

<bean id="cacheAspect" class="org.springframework.cache.aspectj.AnnotationCacheAspect" factory-method="aspectOf">
  <property name="cacheManager" ref="cacheManager"/>
  <property name="keyGenerator" ref="keyGenerator"/>
</bean>