Rename OverrideMetadata for Bean Overrides
Prior to this commit, OverrideMetadata was the only public type in the org.springframework.test.context.bean.override package whose name did not start with BeanOverride. In addition, an OverrideMetadata component plays multiple roles in addition to serving as a holder for metadata. This commit therefore renames OverrideMetadata to BeanOverrideHandler. In addition, this commit updates the affected documentation and renames the following related methods in the Bean Override support. - BeanOverrideHandler: createOverride() -> createOverrideInstance() - BeanOverrideHandler: track() -> trackOverrideInstance() - BeanOverrideProcessor: createMetadata() -> createHandler() - BeanOverrideContextCustomizer: getMetadata() -> getBeanOverrideHandlers() - BeanOverrideRegistrar: registerNameForMetadata() -> registerBeanOverrideHandler() - BeanOverrideRegistrar: markWrapEarly() -> registerWrappingBeanOverrideHandler() Closes gh-33702
This commit is contained in:
@@ -22,12 +22,12 @@ https://site.mockito.org/[Mockito] third-party library.
|
||||
The three annotations mentioned above build upon the `@BeanOverride` meta-annotation and
|
||||
associated infrastructure, which allows one to define custom bean overriding variants.
|
||||
|
||||
To create custom bean override support, the following is needed:
|
||||
To implement custom bean override support, the following is needed:
|
||||
|
||||
* An annotation meta-annotated with `@BeanOverride` that defines the
|
||||
`BeanOverrideProcessor` to use
|
||||
* A custom `BeanOverrideProcessor` implementation
|
||||
* One or more concrete `OverrideMetadata` implementations provided by the processor
|
||||
* One or more concrete `BeanOverrideHandler` implementations created by the processor
|
||||
|
||||
The Spring TestContext framework includes implementations of the following APIs that
|
||||
support bean overriding and are responsible for setting up the rest of the infrastructure.
|
||||
@@ -43,11 +43,11 @@ properties file].
|
||||
|
||||
The bean overriding infrastructure searches in test classes for any field meta-annotated
|
||||
with `@BeanOverride` and instantiates the corresponding `BeanOverrideProcessor` which is
|
||||
responsible for registering appropriate `OverrideMetadata`.
|
||||
responsible for creating an appropriate `BeanOverrideHandler`.
|
||||
|
||||
The internal `BeanOverrideBeanFactoryPostProcessor` then uses that information to alter
|
||||
the test's `ApplicationContext` by registering and replacing beans as defined by the
|
||||
corresponding `BeanOverrideStrategy`:
|
||||
The internal `BeanOverrideBeanFactoryPostProcessor` then uses bean override handlers to
|
||||
alter the test's `ApplicationContext` by creating, replacing, or wrapping beans as
|
||||
defined by the corresponding `BeanOverrideStrategy`:
|
||||
|
||||
`REPLACE`::
|
||||
Replaces the bean. Throws an exception if a corresponding bean does not exist.
|
||||
@@ -65,11 +65,11 @@ heuristics it can perform to locate a bean. Either the `BeanOverrideProcessor` c
|
||||
the name of the bean to override, or it can be unambiguously selected given the type of
|
||||
the annotated field and its qualifying annotations.
|
||||
|
||||
Typically, the bean is selected by type by the `BeanOverrideFactoryPostProcessor`.
|
||||
Typically, the bean is selected "by type" by the `BeanOverrideFactoryPostProcessor`.
|
||||
Alternatively, the user can directly provide the bean name in the custom annotation.
|
||||
|
||||
Some `BeanOverrideProcessor` implementations could also internally compute a bean name
|
||||
based on a convention or another advanced method.
|
||||
`BeanOverrideProcessor` implementations may also internally compute a bean name based on
|
||||
a convention or some other method.
|
||||
====
|
||||
|
||||
NOTE: Only _singleton_ beans can be overridden. Any attempt to override a non-singleton
|
||||
|
||||
Reference in New Issue
Block a user