Jsr330ScopeMetadataResolver (Spring Framework 3.2.1.RELEASE API)
Date: 2013-01-24

org.springframework.context.annotation

## Class Jsr330ScopeMetadataResolver

- java.lang.Object
- - org.springframework.context.annotation.Jsr330ScopeMetadataResolver

- All Implemented Interfaces:
    ScopeMetadataResolver

      public class Jsr330ScopeMetadataResolver
      extends Object
      implements ScopeMetadataResolver

  Simple `ScopeMetadataResolver` implementation that follows JSR-330 scoping rules: defaulting to prototype scope unless `Singleton` is present.

  This scope resolver can be used with `ClassPathBeanDefinitionScanner` and `AnnotatedBeanDefinitionReader` for standard JSR-330 compliance. However, in practice, you will typically use Spring's rich default scoping instead - or extend this resolver with custom scoping annotations that point to extended Spring scopes.

  Since:
    3.0
  Author:
    Juergen Hoeller
  See Also:
    `registerScope(java.lang.Class, java.lang.String)`, `resolveScopeName(java.lang.String)`, `ClassPathBeanDefinitionScanner.setScopeMetadataResolver(org.springframework.context.annotation.ScopeMetadataResolver)`, `AnnotatedBeanDefinitionReader.setScopeMetadataResolver(org.springframework.context.annotation.ScopeMetadataResolver)`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Jsr330ScopeMetadataResolver()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `registerScope(Class annotationType, String scopeName)` Register an extended JSR-330 scope annotation, mapping it onto a specific Spring scope by name.
    `void` | `registerScope(String annotationType, String scopeName)` Register an extended JSR-330 scope annotation, mapping it onto a specific Spring scope by name.
    `ScopeMetadata` | `resolveScopeMetadata(BeanDefinition definition)` Resolve the `ScopeMetadata` appropriate to the supplied bean `definition`.
    `protected String` | `resolveScopeName(String annotationType)` Resolve the given annotation type into a named Spring scope.

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

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

- - ### Constructor Detail

    - #### Jsr330ScopeMetadataResolver

          public Jsr330ScopeMetadataResolver()

  - ### Method Detail

    - #### registerScope

          public final void registerScope(Class annotationType,
                           String scopeName)

      Register an extended JSR-330 scope annotation, mapping it onto a specific Spring scope by name.
      Parameters:
        `annotationType` - the JSR-330 annotation type as a Class
        `scopeName` - the Spring scope name

    - #### registerScope

          public final void registerScope(String annotationType,
                           String scopeName)

      Register an extended JSR-330 scope annotation, mapping it onto a specific Spring scope by name.
      Parameters:
        `annotationType` - the JSR-330 annotation type by name
        `scopeName` - the Spring scope name

    - #### resolveScopeName

          protected String resolveScopeName(String annotationType)

      Resolve the given annotation type into a named Spring scope.

      The default implementation simply checks against registered scopes. Can be overridden for custom mapping rules, e.g. naming conventions.

      Parameters:
        `annotationType` - the JSR-330 annotation type
      Returns:
        the Spring scope name

    - #### resolveScopeMetadata

          public ScopeMetadata resolveScopeMetadata(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`