Top Description Fields Constructors Methods
org.springframework.context.annotation

public abstract Class AdviceModeImportSelector<A extends Annotation>

extends Object
implements ImportSelector
Class Inheritance
All Implemented Interfaces
org.springframework.context.annotation.ImportSelector
Known Direct Subclasses
org.springframework.scheduling.annotation.AsyncConfigurationSelector, org.springframework.cache.annotation.CachingConfigurationSelector
Type Parameters
<A>
annotation containing AdviceMode attribute
Imports
java.lang.annotation.Annotation, org.springframework.core.GenericTypeResolver, org.springframework.core.annotation.AnnotationAttributes, org.springframework.core.type.AnnotationMetadata, org.springframework.lang.Nullable, org.springframework.util.Assert

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

Field Summary

Modifier and TypeField and Description
public static final String
DEFAULT_ADVICE_MODE_ATTRIBUTE_NAME

The default advice mode attribute name.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected String
getAdviceModeAttributeName()

The name of the AdviceMode attribute for the annotation specified by the generic type A.

public final String[]
selectImports(AnnotationMetadata importingClassMetadata)

Implements org.springframework.context.annotation.ImportSelector.selectImports.

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.

protected abstract String[]

Returns:

array containing classes to import (empty array if none; null if the given AdviceMode is unknown)
selectImports
(AdviceMode
the value of the advice mode attribute for the annotation specified via generics.
adviceMode
)

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

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_ADVICE_MODE_ATTRIBUTE_NAMEback to summary
public static final String DEFAULT_ADVICE_MODE_ATTRIBUTE_NAME

The default advice mode attribute name.

Constructor Detail

AdviceModeImportSelectorback to summary
public AdviceModeImportSelector()

Method Detail

getAdviceModeAttributeNameback to summary
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.

selectImportsback to summary
public final String[] selectImports(AnnotationMetadata importingClassMetadata)

Implements org.springframework.context.annotation.ImportSelector.selectImports.

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.

Returns:String[]

Doc from org.springframework.context.annotation.ImportSelector.selectImports.

the class names, or an empty array if none

Annotations
@Override
Exceptions
IllegalArgumentException:
if expected annotation A is not present on the importing @Configuration class or if selectImports(AdviceMode) returns null
selectImportsback to summary
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:AdviceMode

the value of the advice mode attribute for the annotation specified via generics.

Returns:String[]

array containing classes to import (empty array if none; null if the given AdviceMode is unknown)

Annotations
@Nullable