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 interface
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.static interface
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. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoid
contributeTypeConfigurations
(GenerationContext generationContext) Contribute type configurations to the givenGenerationContext
.static AotContext
from
(BeanFactory beanFactory) Create anAotContext
backed by the givenBeanFactory
.static AotContext
from
(BeanFactory beanFactory, Environment environment) Create anAotContext
backed by the givenBeanFactory
.Returns a reference to theConfigurableListableBeanFactory
backing thisAotContext
.default @Nullable ClassLoader
default ClassLoader
default TypeScanner
Returns a newTypeScanner
used to scan fortypes
that 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.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.default boolean
isGeneratedRepositoriesEnabled
(@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 boolean
Checks 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()
directlyvoid
typeConfiguration
(Class<?> type, Consumer<AotTypeConfiguration> configurationConsumer) Obtain aAotTypeConfiguration
for the givenResolvableType
to customize the AOT processing for the given type.default void
typeConfiguration
(ResolvableType resolvableType, Consumer<AotTypeConfiguration> configurationConsumer) Obtain aAotTypeConfiguration
for the givenResolvableType
to 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 anAotContext
backed by the givenBeanFactory
.- Parameters:
beanFactory
- reference to theBeanFactory
; must not be null.- Returns:
- a new instance of
AotContext
. - See Also:
-
from
Create anAotContext
backed 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_ENABLED
acts 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_ENABLED
flag.- 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 theConfigurableListableBeanFactory
backing thisAotContext
.- Returns:
- a reference to the
ConfigurableListableBeanFactory
backing thisAotContext
. - See Also:
-
getClassLoader
Returns theClassLoader
used by thisAotContext
to resolvetypes
. By default, this is the sameClassLoader
used by theBeanFactory
to resolvetypes
declared in bean definitions.- Returns:
- the
ClassLoader
used by thisAotContext
to resolvetypes
. - See Also:
-
getRequiredClassLoader
Returns the requiredClassLoader
used by thisAotContext
to resolvetypes
. By default, this is the sameClassLoader
used by theBeanFactory
to resolvetypes
declared in bean definitions.- Returns:
- the
ClassLoader
used by thisAotContext
to resolvetypes
. - Throws:
IllegalStateException
- if noClassLoader
is 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.TypeIntrospector
to obtain further detail about atype
given its fully-qualified type name -
getTypeScanner
Returns a newTypeScanner
used to scan fortypes
that will be contributed to the AOT processing infrastructure.- Returns:
- a
TypeScanner
used to scan fortypes
that 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 fortypes
in the givennamed packages
annotated with the store-specificidentifying annotations
.- Parameters:
identifyingAnnotations
-Collection
ofAnnotations
identifying store-specific modeltypes
; must not be null.packageNames
-Collection
ofpackage names
to scan.- Returns:
- a
Set
oftypes
found 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.IntrospectedBeanDefinition
to obtain further detail about the underlying bean definition. An introspected bean definition can also point to an absent bean definition.- Parameters:
reference
-BeanReference
to 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.IntrospectedBeanDefinition
to obtain further detail about the underlying bean definition. An introspected bean definition can also point to an absent bean definition.- Parameters:
beanName
-String
containing 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 aAotTypeConfiguration
for the givenResolvableType
to 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 aAotTypeConfiguration
for the givenResolvableType
to 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 perGenerationContext
after all type configurations have been registered.- Parameters:
generationContext
- the context to contribute the type configurations to.
-