Class AnnotationScopeMetadataResolver
- java.lang.Object
- org.springframework.context.annotation.AnnotationScopeMetadataResolver
- All Implemented Interfaces:
ScopeMetadataResolver
public class AnnotationScopeMetadataResolver extends Object implements ScopeMetadataResolver
AScopeMetadataResolver
implementation that by default checks for the presence of Spring's@Scope
annotation on the bean class.The exact type of annotation that is checked for is configurable via
setScopeAnnotationType(Class)
.- Since:
- 2.5
- Author:
- Mark Fisher, Juergen Hoeller, Sam Brannen
- See Also:
Scope
Field Summary
Fields Modifier and Type Field Description protected Class<? extends Annotation>
scopeAnnotationType
Constructor Summary
Constructors Constructor Description AnnotationScopeMetadataResolver()
Construct a newAnnotationScopeMetadataResolver
.AnnotationScopeMetadataResolver(ScopedProxyMode defaultProxyMode)
Construct a newAnnotationScopeMetadataResolver
using the supplied defaultScopedProxyMode
.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ScopeMetadata
resolveScopeMetadata(BeanDefinition definition)
Resolve theScopeMetadata
appropriate to the supplied beandefinition
.void
setScopeAnnotationType(Class<? extends Annotation> scopeAnnotationType)
Set the type of annotation that is checked for by thisAnnotationScopeMetadataResolver
.
Field Detail
scopeAnnotationType
protected Class<? extends Annotation> scopeAnnotationType
Constructor Detail
AnnotationScopeMetadataResolver
public AnnotationScopeMetadataResolver()
Construct a newAnnotationScopeMetadataResolver
.
AnnotationScopeMetadataResolver
public AnnotationScopeMetadataResolver(ScopedProxyMode defaultProxyMode)
Construct a newAnnotationScopeMetadataResolver
using the supplied defaultScopedProxyMode
.- Parameters:
defaultProxyMode
- the default scoped-proxy mode
Method Detail
setScopeAnnotationType
public void setScopeAnnotationType(Class<? extends Annotation> scopeAnnotationType)
Set the type of annotation that is checked for by thisAnnotationScopeMetadataResolver
.- Parameters:
scopeAnnotationType
- the target annotation type
resolveScopeMetadata
public ScopeMetadata resolveScopeMetadata(BeanDefinition definition)
Description copied from interface:ScopeMetadataResolver
Resolve theScopeMetadata
appropriate to the supplied beandefinition
.Implementations can of course use any strategy they like to determine the scope metadata, but some implementations that spring immediately to mind might be to use source level annotations present on
the class
of the supplieddefinition
, or to use metadata present in theAttributeAccessor.attributeNames()
of the supplieddefinition
.- Specified by:
resolveScopeMetadata
in interfaceScopeMetadataResolver
- Parameters:
definition
- the target bean definition- Returns:
- the relevant scope metadata; never
null