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

org.springframework.context.annotation

## Class AdviceModeImportSelector<A extends Annotation>

- java.lang.Object
- - org.springframework.context.annotation.AdviceModeImportSelector<A>

- Type Parameters:
    `A` - Annotation containing AdviceMode attribute
  All Implemented Interfaces:
    ImportSelector
  Direct Known Subclasses:
    AsyncConfigurationSelector, CachingConfigurationSelector, TransactionManagementConfigurationSelector

      public abstract class AdviceModeImportSelector<A extends Annotation>
      extends Object
      implements ImportSelector

  Convenient base class for `ImportSelector` implementations that select imports based on an `AdviceMode` value from an annotation (such as the `@Enable*` annotations).
  Since:
    3.1
  Author:
    Chris Beams

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `DEFAULT_ADVICE_MODE_ATTRIBUTE_NAME`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AdviceModeImportSelector()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected String` | `getAdviceModeAttributeName()` The name of the `AdviceMode` attribute for the annotation specified by the generic type `A`.
    `protected abstract String[]` | `selectImports(AdviceMode adviceMode)` Determine which classes should be imported based on the given `AdviceMode`.
    `String[]` | `selectImports(AnnotationMetadata importingClassMetadata)` Select and return the names of which class(es) should be imported based on the `AnnotationMetadata` of the importing @`Configuration` class.

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

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

- - ### Field Detail

    - #### DEFAULT_ADVICE_MODE_ATTRIBUTE_NAME

          public static final String DEFAULT_ADVICE_MODE_ATTRIBUTE_NAME

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### AdviceModeImportSelector

          public AdviceModeImportSelector()

  - ### Method Detail

    - #### getAdviceModeAttributeName

          protected String getAdviceModeAttributeName()

      The name of the `AdviceMode` attribute for the annotation specified by the generic type `A`. The default is "mode", but subclasses may override in order to customize.

    - #### selectImports

          public final String[] selectImports(AnnotationMetadata importingClassMetadata)

      Select and return the names of which class(es) should be imported based on the `AnnotationMetadata` of the importing @`Configuration` class.

      This implementation resolves the type of annotation from generic metadata and validates that (a) the annotation is in fact present on the importing `@Configuration` class and (b) that the given annotation has an advice mode attribute of type `AdviceMode`.

      The `selectImports(AdviceMode)` method is then invoked, allowing the concrete implementation to choose imports in a safe and convenient fashion.

      Specified by:
        `selectImports` in interface `ImportSelector`
      Throws:
        `IllegalArgumentException` - if expected annotation `A` is not present on the importing `@Configuration` class or if `selectImports(AdviceMode)` returns `null`

    - #### selectImports

          protected abstract String[] selectImports(AdviceMode adviceMode)

      Determine which classes should be imported based on the given `AdviceMode`.

      Returning `null` from this method indicates that the `AdviceMode` could not be handled or was unknown and that an `IllegalArgumentException` should be thrown.

      Parameters:
        `adviceMode` - the value of the advice mode attribute for the annotation specified via generics.
      Returns:
        array containing classes to import; empty array if none, `null` if the given `AdviceMode` is unknown.