Package org.springframework.data.aot
Interface AotContext
- All Superinterfaces:
EnvironmentCapable
- All Known Subinterfaces:
AotRepositoryContext
- All Known Implementing Classes:
AotRepositoryContextSupport
The context in which the AOT processing happens. Grants access to the
beanFactory and ClassLoader.
Mainly for internal use within the framework.
- Since:
- 3.0
- Author:
- Christoph Strobl, John Blum, Mark Paluch
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceDeprecated, for removal: This API element is subject to removal in a future version.since 4.0 as this isn't widely used and can be easily implemented within user code.static interfaceDeprecated, for removal: This API element is subject to removal in a future version.since 4.0 as this isn't widely used and can be easily implemented within user code. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidcontributeTypeConfigurations(GenerationContext generationContext) Contribute type configurations to the givenGenerationContext.static AotContextfrom(BeanFactory beanFactory) Create anAotContextbacked by the givenBeanFactory.static AotContextfrom(BeanFactory beanFactory, Environment environment) Create anAotContextbacked by the givenBeanFactory.Returns a reference to theConfigurableListableBeanFactorybacking thisAotContext.default @Nullable ClassLoaderdefault ClassLoaderdefault TypeScannerReturns a newTypeScannerused to scan fortypesthat will be contributed to the AOT processing infrastructure.introspectBeanDefinition(String beanName) Deprecated, for removal: This API element is subject to removal in a future version.since 4.0, usegetBeanFactory()and interact with the bean factory directly.introspectBeanDefinition(BeanReference reference) Deprecated, for removal: This API element is subject to removal in a future version.since 4.0, usegetBeanFactory()and interact with the bean factory directly.default AotContext.TypeIntrospectorintrospectType(String typeName) Deprecated, for removal: This API element is subject to removal in a future version.since 4.0 as this isn't widely used and can be easily implemented within user code.default booleanisGeneratedRepositoriesEnabled(@Nullable String moduleName) Checks if repository code generation is enabled for a given module by checking environment variables for general enablement (GENERATED_REPOSITORIES_ENABLED) and store-specific ones following the pattern spring.aot.<module-name>.repositories.enabled.default booleanChecks if repository metadata file writing is enabled by checking environment variables for general enablement (GENERATED_REPOSITORIES_JSON_ENABLED)scanPackageForTypes(Collection<Class<? extends Annotation>> identifyingAnnotations, Collection<String> packageNames) Deprecated, for removal: This API element is subject to removal in a future version.since 4.0, usegetTypeScanner()directlyvoidtypeConfiguration(Class<?> type, Consumer<AotTypeConfiguration> configurationConsumer) Obtain aAotTypeConfigurationfor the givenResolvableTypeto customize the AOT processing for the given type.default voidtypeConfiguration(ResolvableType resolvableType, Consumer<AotTypeConfiguration> configurationConsumer) Obtain aAotTypeConfigurationfor the givenResolvableTypeto customize the AOT processing for the given type.Methods inherited from interface org.springframework.core.env.EnvironmentCapable
getEnvironment
-
Field Details
-
GENERATED_REPOSITORIES_ENABLED
- See Also:
-
GENERATED_REPOSITORIES_JSON_ENABLED
- See Also:
-
-
Method Details
-
from
Create anAotContextbacked by the givenBeanFactory.- Parameters:
beanFactory- reference to theBeanFactory; must not be null.- Returns:
- a new instance of
AotContext. - See Also:
-
from
Create anAotContextbacked by the givenBeanFactory.- Parameters:
beanFactory- reference to theBeanFactory; must not be null.environment- reference to theEnvironment; must not be null.- Returns:
- a new instance of
AotContext. - See Also:
-
isGeneratedRepositoriesEnabled
Checks if repository code generation is enabled for a given module by checking environment variables for general enablement (GENERATED_REPOSITORIES_ENABLED) and store-specific ones following the pattern spring.aot.<module-name>.repositories.enabled.GENERATED_REPOSITORIES_ENABLEDacts as a main switch, if disabled, store specific flags have no effect.Unset properties are considered being true.
- Parameters:
moduleName- name of the module. Can be null or empty, in which case it will only check the generalGENERATED_REPOSITORIES_ENABLEDflag.- Returns:
- indicator if repository code generation is enabled.
- Since:
- 4.0
-
isGeneratedRepositoriesMetadataEnabled
default boolean isGeneratedRepositoriesMetadataEnabled()Checks if repository metadata file writing is enabled by checking environment variables for general enablement (GENERATED_REPOSITORIES_JSON_ENABLED)Unset properties are considered being true.
- Returns:
- indicator if repository metadata should be written
- Since:
- 4.0
-
getBeanFactory
ConfigurableListableBeanFactory getBeanFactory()Returns a reference to theConfigurableListableBeanFactorybacking thisAotContext.- Returns:
- a reference to the
ConfigurableListableBeanFactorybacking thisAotContext. - See Also:
-
getClassLoader
Returns theClassLoaderused by thisAotContextto resolvetypes. By default, this is the sameClassLoaderused by theBeanFactoryto resolvetypesdeclared in bean definitions.- Returns:
- the
ClassLoaderused by thisAotContextto resolvetypes. - See Also:
-
getRequiredClassLoader
Returns the requiredClassLoaderused by thisAotContextto resolvetypes. By default, this is the sameClassLoaderused by theBeanFactoryto resolvetypesdeclared in bean definitions.- Returns:
- the
ClassLoaderused by thisAotContextto resolvetypes. - Throws:
IllegalStateException- if noClassLoaderis available.
-
introspectType
@Deprecated(since="4.0", forRemoval=true) default AotContext.TypeIntrospector introspectType(String typeName) Deprecated, for removal: This API element is subject to removal in a future version.since 4.0 as this isn't widely used and can be easily implemented within user code.Returns aAotContext.TypeIntrospectorto obtain further detail about atypegiven its fully-qualified type name -
getTypeScanner
Returns a newTypeScannerused to scan fortypesthat will be contributed to the AOT processing infrastructure.- Returns:
- a
TypeScannerused to scan fortypesthat will be contributed to the AOT processing infrastructure. - See Also:
-
scanPackageForTypes
@Deprecated(since="4.0", forRemoval=true) default Set<Class<?>> scanPackageForTypes(Collection<Class<? extends Annotation>> identifyingAnnotations, Collection<String> packageNames) Deprecated, for removal: This API element is subject to removal in a future version.since 4.0, usegetTypeScanner()directlyScans fortypesin the givennamed packagesannotated with the store-specificidentifying annotations.- Parameters:
identifyingAnnotations-CollectionofAnnotationsidentifying store-specific modeltypes; must not be null.packageNames-Collectionofpackage namesto scan.- Returns:
- a
Setoftypesfound during the scan. - See Also:
-
introspectBeanDefinition
@Deprecated(since="4.0", forRemoval=true) default AotContext.IntrospectedBeanDefinition introspectBeanDefinition(BeanReference reference) Deprecated, for removal: This API element is subject to removal in a future version.since 4.0, usegetBeanFactory()and interact with the bean factory directly.Returns aAotContext.IntrospectedBeanDefinitionto obtain further detail about the underlying bean definition. An introspected bean definition can also point to an absent bean definition.- Parameters:
reference-BeanReferenceto the managed bean.- Returns:
- the introspected bean definition.
-
introspectBeanDefinition
@Deprecated(since="4.0", forRemoval=true) default AotContext.IntrospectedBeanDefinition introspectBeanDefinition(String beanName) Deprecated, for removal: This API element is subject to removal in a future version.since 4.0, usegetBeanFactory()and interact with the bean factory directly.Returns aAotContext.IntrospectedBeanDefinitionto obtain further detail about the underlying bean definition. An introspected bean definition can also point to an absent bean definition.- Parameters:
beanName-Stringcontaining the name of the bean to evaluate; must not be null.- Returns:
- the introspected bean definition.
-
typeConfiguration
default void typeConfiguration(ResolvableType resolvableType, Consumer<AotTypeConfiguration> configurationConsumer) Obtain aAotTypeConfigurationfor the givenResolvableTypeto customize the AOT processing for the given type. Repeated calls to the same type will result in merging the configuration.- Parameters:
resolvableType- the resolvable type to configure.configurationConsumer- configuration consumer function.- Since:
- 4.0
-
typeConfiguration
Obtain aAotTypeConfigurationfor the givenResolvableTypeto customize the AOT processing for the given type. Repeated calls to the same type will result in merging the configuration.- Parameters:
type- the type to configure.configurationConsumer- configuration consumer function.- Since:
- 4.0
-
contributeTypeConfigurations
Contribute type configurations to the givenGenerationContext. This method is called once perGenerationContextafter all type configurations have been registered.- Parameters:
generationContext- the context to contribute the type configurations to.
-