Package org.springframework.context.annotation

# Class AnnotationScopeMetadataResolver

java.lang.Object
org.springframework.context.annotation.AnnotationScopeMetadataResolver

All Implemented Interfaces:
  `ScopeMetadataResolver`

public class AnnotationScopeMetadataResolver extends Object implements ScopeMetadataResolver
A `ScopeMetadataResolver` 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 new `AnnotationScopeMetadataResolver`.
`AnnotationScopeMetadataResolver(ScopedProxyMode defaultProxyMode)`
Construct a new `AnnotationScopeMetadataResolver` using the supplied default `ScopedProxyMode`.

## Method Summary

Modifier and Type
Method
Description
`ScopeMetadata`
`resolveScopeMetadata(org.springframework.beans.factory.config.BeanDefinition definition)`
Resolve the `ScopeMetadata` appropriate to the supplied bean `definition`.
`void`
`setScopeAnnotationType(Class<? extends Annotation> scopeAnnotationType)`
Set the type of annotation that is checked for by this `AnnotationScopeMetadataResolver`.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### scopeAnnotationType

protected Class<? extends Annotation> scopeAnnotationType

## Constructor Details

### AnnotationScopeMetadataResolver

public AnnotationScopeMetadataResolver()
Construct a new `AnnotationScopeMetadataResolver`.

See Also:
  - `AnnotationScopeMetadataResolver(ScopedProxyMode)`
  - `ScopedProxyMode.NO`

### AnnotationScopeMetadataResolver

public AnnotationScopeMetadataResolver(ScopedProxyMode defaultProxyMode)
Construct a new `AnnotationScopeMetadataResolver` using the supplied default `ScopedProxyMode`.

Parameters:
  `defaultProxyMode` - the default scoped-proxy mode

## Method Details

### setScopeAnnotationType

public void setScopeAnnotationType(Class<? extends Annotation> scopeAnnotationType)
Set the type of annotation that is checked for by this `AnnotationScopeMetadataResolver`.

Parameters:
  `scopeAnnotationType` - the target annotation type

### resolveScopeMetadata

public ScopeMetadata resolveScopeMetadata(org.springframework.beans.factory.config.BeanDefinition definition)
Description copied from interface: `ScopeMetadataResolver`
Resolve the `ScopeMetadata` appropriate to the supplied bean `definition`.

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 supplied `definition`, or to use metadata present in the `AttributeAccessor.attributeNames()` of the supplied `definition`.

Specified by:
  `resolveScopeMetadata` in interface `ScopeMetadataResolver`
Parameters:
  `definition` - the target bean definition
Returns:
  the relevant scope metadata; never `null`