Interface BeanStoreOverridable<B extends BeanStoreOverridable<B>>
- Type Parameters:
B- The implementing builder's self type.
- All Known Implementing Classes:
EncoderSet.Builder,Microservice.Builder,MockRestClient.Builder,MockRestClient.Builder,ParserSet.Builder,SerializerSet.Builder
BeanStore — a layer
whose entries take precedence over the builder's local bean registrations during construction-time
reflective injection.
Implementing builders MUST install the supplied store in the overridingParent slot of the
underlying BasicBeanStore (see
BasicBeanStore(BeanStore, BeanStore)). The resulting bean-lookup order is:
- Overriding parent (the store passed to
overridingBeanStore(BeanStore)) — wins for any(type, name)it knows about. - The builder's local entries (e.g.
@Beanfactories declared on a@Restresource, beans registered directly viaaddBean(...)/addSupplier(...)). - The builder's regular parent bean store (e.g. a Spring
ApplicationContextbridge), if any. - Framework-default suppliers (registered via
addDefaultSupplier(...)).
The primary use case is test-time bean substitution: a test builds a TestBeanStore-style overlay
with mock beans, hands it to the builder via overridingBeanStore(BeanStore), and the system under
test resolves the mocks at construction time without any reflection on the SUT itself. This is the
Mode INJECT wiring pattern in the test-injection model — the overlay is installed before the SUT
exists.
Example:
Why a self-typed interface:
The B extends BeanStoreOverridable<B> self-type lets the method return the concrete builder
type rather than BeanStoreOverridable<?>, preserving the fluent chain at the call site:
SerializerSet.Builder
See Also:
BeanStore- The base lookup interface this layer extends.BasicBeanStore- The default writable implementation with theoverridingParentslot.
- Since:
- 10.0.0
-
Method Summary
Modifier and TypeMethodDescriptionoverridingBeanStore(BeanStore store) Installs the suppliedBeanStoreas theoverridingParentof the underlying bean store used by this builder during construction-time reflective injection.
-
Method Details
-
overridingBeanStore
Installs the suppliedBeanStoreas theoverridingParentof the underlying bean store used by this builder during construction-time reflective injection.Passing
nullclears any previously-installed overlay.- Parameters:
store- The override layer. Can benull to clear a previously-set value.- Returns:
- This object.
- Since:
- 10.0.0
-