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 forImportSelector
implementations that select imports based on anAdviceMode
value from an annotation (such as the@Enable*
annotations).- Since:
- 3.1
- Author:
- Chris Beams
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_ADVICE_MODE_ATTRIBUTE_NAME
The default advice mode attribute name.
Constructor Summary
Constructors Constructor Description AdviceModeImportSelector()
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected String
getAdviceModeAttributeName()
The name of theAdviceMode
attribute for the annotation specified by the generic typeA
.protected abstract String[]
selectImports(AdviceMode adviceMode)
Determine which classes should be imported based on the givenAdviceMode
.String[]
selectImports(AnnotationMetadata importingClassMetadata)
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 typeAdviceMode
.
Field Detail
DEFAULT_ADVICE_MODE_ATTRIBUTE_NAME
public static final String DEFAULT_ADVICE_MODE_ATTRIBUTE_NAME
The default advice mode attribute name.- See Also:
- Constant Field Values
Constructor Detail
AdviceModeImportSelector
public AdviceModeImportSelector()
Method Detail
getAdviceModeAttributeName
protected String getAdviceModeAttributeName()
The name of theAdviceMode
attribute for the annotation specified by the generic typeA
. The default is "mode", but subclasses may override in order to customize.
selectImports
public final String[] selectImports(AnnotationMetadata importingClassMetadata)
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 typeAdviceMode
.The
selectImports(AdviceMode)
method is then invoked, allowing the concrete implementation to choose imports in a safe and convenient fashion.- Specified by:
selectImports
in interfaceImportSelector
- Returns:
- the class names, or an empty array if none
- Throws:
IllegalArgumentException
- if expected annotationA
is not present on the importing@Configuration
class or ifselectImports(AdviceMode)
returnsnull
selectImports
protected abstract String[] selectImports(AdviceMode adviceMode)
Determine which classes should be imported based on the givenAdviceMode
.Returning
null
from this method indicates that theAdviceMode
could not be handled or was unknown and that anIllegalArgumentException
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 givenAdviceMode
is unknown)