Spring Beans - IoC Container and Dependency Injection providing comprehensive bean management infrastructure and dependency injection capabilities.
—
Core IoC container functionality for managing bean definitions, lifecycle, and dependency injection. The bean factory serves as the central registry and factory for application objects, providing sophisticated dependency resolution and lifecycle management capabilities.
The central interface for accessing Spring's IoC container, providing basic bean lookup and metadata query capabilities.
/**
* Root interface for accessing a Spring bean container.
* Provides basic functionality for retrieving beans and querying their metadata.
*/
interface BeanFactory {
/** Used to dereference a FactoryBean instance and distinguish it from beans created by the FactoryBean. */
String FACTORY_BEAN_PREFIX = "&";
/** Used to dereference a FactoryBean instance and distinguish it from beans created by the FactoryBean. */
char FACTORY_BEAN_PREFIX_CHAR = '&';
/**
* Return an instance, which may be shared or independent, of the specified bean.
* @param name the name of the bean to retrieve
* @return an instance of the bean
* @throws NoSuchBeanDefinitionException if there is no bean with the specified name
* @throws BeansException if the bean could not be obtained
*/
Object getBean(String name) throws BeansException;
/**
* Return an instance, which may be shared or independent, of the specified bean.
* @param name the name of the bean to retrieve
* @param requiredType type the bean must match; can be an interface or superclass
* @return an instance of the bean
* @throws NoSuchBeanDefinitionException if there is no such bean definition
* @throws BeanNotOfRequiredTypeException if the bean is not of the required type
* @throws BeansException if the bean could not be created
*/
<T> T getBean(String name, Class<T> requiredType) throws BeansException;
/**
* Return the bean instance that uniquely matches the given object type, if any.
* @param requiredType type the bean must match; can be an interface or superclass
* @return an instance of the single bean matching the required type
* @throws NoSuchBeanDefinitionException if no bean of the given type was found
* @throws NoUniqueBeanDefinitionException if more than one bean of the given type was found
* @throws BeansException if the bean could not be created
*/
<T> T getBean(Class<T> requiredType) throws BeansException;
/**
* Return an instance, which may be shared or independent, of the specified bean.
* @param name the name of the bean to retrieve
* @param args arguments to use when creating a bean instance using explicit arguments
* @return an instance of the bean
* @throws NoSuchBeanDefinitionException if there is no such bean definition
* @throws BeanDefinitionStoreException if arguments have been given but the affected bean isn't a prototype
* @throws BeansException if the bean could not be created
*/
Object getBean(String name, Object... args) throws BeansException;
/**
* Return an instance, which may be shared or independent, of the specified bean.
* @param requiredType type the bean must match; can be an interface or superclass
* @param args arguments to use when creating a bean instance using explicit arguments
* @return an instance of the bean
* @throws NoSuchBeanDefinitionException if no bean of the given type was found
* @throws NoUniqueBeanDefinitionException if more than one bean of the given type was found
* @throws BeansException if the bean could not be created
*/
<T> T getBean(Class<T> requiredType, Object... args) throws BeansException;
/**
* Does this bean factory contain a bean definition or externally registered singleton instance with the given name?
* @param name the name of the bean to query
* @return whether this bean factory contains a bean with the given name
*/
boolean containsBean(String name);
/**
* Is this bean a shared singleton?
* @param name the name of the bean to query
* @return whether this bean corresponds to a singleton instance
* @throws NoSuchBeanDefinitionException if there is no bean with the given name
*/
boolean isSingleton(String name) throws NoSuchBeanDefinitionException;
/**
* Is this bean a prototype (not a singleton)?
* @param name the name of the bean to query
* @return whether this bean will always create independent instances
* @throws NoSuchBeanDefinitionException if there is no bean with the given name
*/
boolean isPrototype(String name) throws NoSuchBeanDefinitionException;
/**
* Check whether the bean with the given name matches the specified type.
* @param name the name of the bean to query
* @param typeToMatch the type to match against (as a ResolvableType)
* @return true if the bean type matches, false if it doesn't or cannot be determined yet
* @throws NoSuchBeanDefinitionException if there is no bean with the given name
*/
boolean isTypeMatch(String name, ResolvableType typeToMatch) throws NoSuchBeanDefinitionException;
/**
* Return a provider for the specified bean, allowing for lazy on-demand retrieval of instances, including availability and uniqueness options.
* @param requiredType type the bean must match; can be an interface or superclass
* @return a corresponding provider handle
*/
<T> ObjectProvider<T> getBeanProvider(Class<T> requiredType);
/**
* Return a provider for the specified bean, allowing for lazy on-demand retrieval of instances, including availability and uniqueness options.
* @param requiredType type the bean must match; can be a generic type declaration
* @return a corresponding provider handle
*/
<T> ObjectProvider<T> getBeanProvider(ResolvableType requiredType);
/**
* Check whether the bean with the given name matches the specified type.
* @param name the name of the bean to query
* @param typeToMatch the type to match against (as a Class)
* @return true if the bean type matches, false if it doesn't or cannot be determined yet
* @throws NoSuchBeanDefinitionException if there is no bean with the given name
*/
boolean isTypeMatch(String name, Class<?> typeToMatch) throws NoSuchBeanDefinitionException;
/**
* Determine the type of the bean with the given name.
* @param name the name of the bean to query
* @return the type of the bean, or null if not determinable
* @throws NoSuchBeanDefinitionException if there is no bean with the given name
*/
Class<?> getType(String name) throws NoSuchBeanDefinitionException;
/**
* Determine the type of the bean with the given name.
* @param name the name of the bean to query
* @param allowFactoryBeanInit whether a FactoryBean type match is allowed to trigger initialization of the FactoryBean
* @return the type of the bean, or null if not determinable
* @throws NoSuchBeanDefinitionException if there is no bean with the given name
*/
Class<?> getType(String name, boolean allowFactoryBeanInit) throws NoSuchBeanDefinitionException;
/**
* Return the aliases for the given bean name, if any.
* @param name the bean name to check for aliases
* @return the aliases, or an empty array if none
*/
String[] getAliases(String name);
}Extended bean factory interface that exposes bean creation, configuration, and autowiring capabilities.
/**
* Extension of the BeanFactory interface to be implemented by bean factories that are capable of autowiring.
*/
interface AutowireCapableBeanFactory extends BeanFactory {
/** Constant that indicates no externally defined autowiring. */
int AUTOWIRE_NO = 0;
/** Constant that indicates autowiring bean properties by name. */
int AUTOWIRE_BY_NAME = 1;
/** Constant that indicates autowiring bean properties by type. */
int AUTOWIRE_BY_TYPE = 2;
/** Constant that indicates autowiring the greediest constructor. */
int AUTOWIRE_CONSTRUCTOR = 3;
/** Constant that indicates determining an appropriate autowire strategy through introspection of the bean class (deprecated). */
int AUTOWIRE_AUTODETECT = 4;
/** Suffix for generated bean names for original instances when a bean is enhanced with CGLIB. */
String ORIGINAL_INSTANCE_SUFFIX = ".ORIGINAL";
/**
* Fully create a new bean instance of the given class.
* @param beanClass the class of the bean to create
* @return the new bean instance
* @throws BeansException if instantiation or wiring failed
*/
<T> T createBean(Class<T> beanClass) throws BeansException;
/**
* Populate the given bean instance through applying after-instantiation callbacks and bean property post-processing.
* @param existingBean the existing bean instance
* @throws BeansException if wiring failed
*/
void autowireBean(Object existingBean) throws BeansException;
/**
* Configure the given raw bean: autowiring bean properties, applying bean property values, applying factory callbacks.
* @param existingBean the existing bean instance
* @param beanName the name of the bean, to be passed to it if necessary
* @return the bean instance to use, either the original or a wrapped one
* @throws BeansException if the initialization failed
*/
Object configureBean(Object existingBean, String beanName) throws BeansException;
/**
* Resolve the bean instance that uniquely matches the given object type, if any, including its bean name.
* @param requiredType type the bean must match; can be an interface or superclass
* @return the bean name plus bean instance
* @throws NoSuchBeanDefinitionException if no matching bean was found
* @throws NoUniqueBeanDefinitionException if more than one matching bean was found
* @throws BeansException if the bean could not be created
*/
<T> NamedBeanHolder<T> resolveNamedBean(Class<T> requiredType) throws BeansException;
/**
* Apply BeanPostProcessors to the given existing bean instance, invoking their postProcessBeforeInitialization methods.
* @param existingBean the existing bean instance
* @param beanName the name of the bean, to be passed to it if necessary
* @return the bean instance to use, either the original or a wrapped one
* @throws BeansException if any post-processing failed
*/
Object applyBeanPostProcessorsBeforeInitialization(Object existingBean, String beanName) throws BeansException;
/**
* Initialize the given raw bean, applying factory callbacks such as setBeanName and setBeanFactory, also applying all bean post-processors (including ones which might wrap the given raw bean).
* @param existingBean the existing bean instance
* @param beanName the name of the bean, to be passed to it if necessary
* @return the bean instance to use, either the original or a wrapped one
* @throws BeansException if the initialization failed
*/
Object initializeBean(Object existingBean, String beanName) throws BeansException;
/**
* Apply BeanPostProcessors to the given existing bean instance, invoking their postProcessBeforeInitialization methods.
* @param existingBean the existing bean instance
* @param beanName the name of the bean, to be passed to it if necessary
* @return the bean instance to use, either the original or a wrapped one
* @throws BeansException if any post-processing failed
* @deprecated as of 6.1, in favor of initializeBean
*/
Object applyBeanPostProcessorsBeforeInitialization(Object existingBean, String beanName) throws BeansException;
/**
* Apply BeanPostProcessors to the given existing bean instance, invoking their postProcessAfterInitialization methods.
* @param existingBean the existing bean instance
* @param beanName the name of the bean, to be passed to it if necessary
* @return the bean instance to use, either the original or a wrapped one
* @throws BeansException if any post-processing failed
* @deprecated as of 6.1, in favor of initializeBean
*/
Object applyBeanPostProcessorsAfterInitialization(Object existingBean, String beanName) throws BeansException;
/**
* Destroy the given bean instance (usually a prototype instance obtained from this factory) according to its bean definition.
* @param existingBean the bean instance to destroy
*/
void destroyBean(Object existingBean);
/**
* Resolve the bean instance that uniquely matches the given object type, if any, including its bean name.
* @param requiredType type the bean must match; can be an interface or superclass
* @return the bean name plus bean instance
* @throws NoSuchBeanDefinitionException if no matching bean was found
* @throws NoUniqueBeanDefinitionException if more than one matching bean was found
* @throws BeansException if the bean could not be created
*/
<T> NamedBeanHolder<T> resolveNamedBean(Class<T> requiredType) throws BeansException;
/**
* Resolve a bean instance for the given bean name, providing a dependency descriptor for exposure to target factory methods.
* @param name the name of the bean to look up
* @param descriptor the dependency descriptor for the requesting injection point
* @return the corresponding bean instance
* @throws NoSuchBeanDefinitionException if there is no bean with the specified name
* @throws BeansException if the bean could not be obtained
*/
Object resolveBeanByName(String name, DependencyDescriptor descriptor) throws BeansException;
/**
* Resolve the specified dependency against the beans defined in this factory.
* @param descriptor the descriptor for the dependency (field/method/constructor)
* @param requestingBeanName the name of the bean which declares the given dependency
* @return the resolved object, or null if not found
* @throws NoSuchBeanDefinitionException if no matching bean was found
* @throws NoUniqueBeanDefinitionException if more than one matching bean was found
* @throws BeansException if dependency resolution failed for any other reason
*/
Object resolveDependency(DependencyDescriptor descriptor, String requestingBeanName) throws BeansException;
/**
* Resolve the specified dependency against the beans defined in this factory.
* @param descriptor the descriptor for the dependency (field/method/constructor)
* @param requestingBeanName the name of the bean which declares the given dependency
* @param autowiredBeanNames a Set that all names of autowired beans (used for resolving the given dependency) are supposed to be added to
* @param typeConverter the TypeConverter to use for populating arrays and collections
* @return the resolved object, or null if not found
* @throws NoSuchBeanDefinitionException if no matching bean was found
* @throws NoUniqueBeanDefinitionException if more than one matching bean was found
* @throws BeansException if dependency resolution failed for any other reason
*/
Object resolveDependency(DependencyDescriptor descriptor, String requestingBeanName, Set<String> autowiredBeanNames, TypeConverter typeConverter) throws BeansException;
}Extension of the BeanFactory interface that allows enumeration of all bean instances, rather than just looking up individual beans by name.
/**
* Extension of the BeanFactory interface to be implemented by bean factories that can enumerate all their bean instances.
*/
interface ListableBeanFactory extends BeanFactory {
/**
* Check if this registry contains a bean definition with the given name.
* @param beanName the name of the bean to look for
* @return if this registry contains a bean definition with the given name
*/
boolean containsBeanDefinition(String beanName);
/**
* Return the number of beans defined in the registry.
* @return the number of beans defined in the registry
*/
int getBeanDefinitionCount();
/**
* Return the names of all beans defined in this registry.
* @return the names of all beans defined in this registry, or an empty array if none defined
*/
String[] getBeanDefinitionNames();
/**
* Return the names of beans matching the given type (including subclasses).
* @param type the class or interface to match, or null for all bean names
* @return the names of beans (or objects created by FactoryBeans) matching the given object type
*/
String[] getBeanNamesForType(ResolvableType type);
/**
* Return the names of beans matching the given type (including subclasses).
* @param type the class or interface to match, or null for all bean names
* @return the names of beans (or objects created by FactoryBeans) matching the given object type
*/
String[] getBeanNamesForType(Class<?> type);
/**
* Return the bean instances that match the given object type (including subclasses).
* @param type the class or interface to match, or null for all concrete beans
* @return a Map with the matching beans, containing the bean names as keys and the corresponding bean instances as values
* @throws BeansException if a bean could not be created
*/
<T> Map<String, T> getBeansOfType(Class<T> type) throws BeansException;
/**
* Find all names of beans which are annotated with the supplied Annotation type.
* @param annotationType the type of annotation to look for
* @return the names of all matching beans
*/
String[] getBeanNamesForAnnotation(Class<? extends Annotation> annotationType);
/**
* Find all beans which are annotated with the supplied Annotation type.
* @param annotationType the type of annotation to look for
* @return a Map with the matching beans, containing the bean names as keys and the corresponding bean instances as values
* @throws BeansException if a bean could not be created
*/
Map<String, Object> getBeansWithAnnotation(Class<? extends Annotation> annotationType) throws BeansException;
/**
* Find an Annotation of annotationType on the specified bean.
* @param beanName the name of the bean to look for annotations on
* @param annotationType the type of annotation to look for
* @return the annotation of the given type if found, or null otherwise
* @throws NoSuchBeanDefinitionException if there is no bean with the given name
*/
<A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType) throws NoSuchBeanDefinitionException;
}The default implementation of ListableBeanFactory and BeanDefinitionRegistry interfaces, providing full bean factory functionality.
/**
* Spring's default implementation of the ConfigurableListableBeanFactory and BeanDefinitionRegistry interfaces.
*/
class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFactory
implements ConfigurableListableBeanFactory, BeanDefinitionRegistry {
/**
* Create a new DefaultListableBeanFactory.
*/
public DefaultListableBeanFactory();
/**
* Create a new DefaultListableBeanFactory with the given parent.
* @param parentBeanFactory the parent BeanFactory
*/
public DefaultListableBeanFactory(BeanFactory parentBeanFactory);
/**
* Set whether it should be allowed to override bean definitions by registering a different definition with the same name.
* @param allowBeanDefinitionOverriding whether to allow bean definition overriding
*/
public void setAllowBeanDefinitionOverriding(boolean allowBeanDefinitionOverriding);
/**
* Return whether it's allowed to override bean definitions by registering a different definition with the same name.
* @return whether bean definition overriding is allowed
*/
public boolean isAllowBeanDefinitionOverriding();
/**
* Set whether the factory is allowed to eagerly load bean classes even for bean definitions that are marked as "lazy-init".
* @param allowEagerClassLoading whether to allow eager class loading
*/
public void setAllowEagerClassLoading(boolean allowEagerClassLoading);
/**
* Return whether the factory is allowed to eagerly load bean classes.
* @return whether eager class loading is allowed
*/
public boolean isAllowEagerClassLoading();
/**
* Set the bootstrap executor to use for bootstrapping the bean factory.
* @param bootstrapExecutor the bootstrap executor, or null for synchronous bootstrapping
*/
public void setBootstrapExecutor(Executor bootstrapExecutor);
/**
* Return the bootstrap executor for this bean factory.
* @return the bootstrap executor, or null if none set
*/
public Executor getBootstrapExecutor();
}Usage Examples:
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RootBeanDefinition;
// Create bean factory
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
// Register bean definition programmatically
RootBeanDefinition beanDef = new RootBeanDefinition(MyService.class);
beanDef.setScope("singleton");
beanDef.setLazyInit(false);
factory.registerBeanDefinition("myService", beanDef);
// Retrieve bean
MyService service = factory.getBean("myService", MyService.class);
// Check bean metadata
boolean isSingleton = factory.isSingleton("myService");
boolean containsBean = factory.containsBean("myService");
// List all beans of a type
Map<String, MyService> services = factory.getBeansOfType(MyService.class);Support for FactoryBean instances that create objects through custom factory logic.
/**
* Interface to be implemented by objects used within a BeanFactory which are themselves factories for individual objects.
*/
interface FactoryBean<T> {
/**
* Return an instance (possibly shared or independent) of the object managed by this factory.
* @return an instance of the bean (can be null)
* @throws Exception in case of creation errors
*/
T getObject() throws Exception;
/**
* Return the type of object that this FactoryBean creates.
* @return the type of object that this FactoryBean creates, or null if not known at the time of the call
*/
Class<?> getObjectType();
/**
* Is the object managed by this factory a singleton?
* @return whether the exposed object is a singleton
*/
default boolean isSingleton() {
return true;
}
}
/**
* Extension of FactoryBean which adds support for returning a prototype object.
*/
interface SmartFactoryBean<T> extends FactoryBean<T> {
/**
* Is the object managed by this factory a prototype?
* @return whether the exposed object is a prototype
*/
default boolean isPrototype() {
return false;
}
/**
* Does this FactoryBean expect eager initialization?
* @return whether eager initialization applies
*/
default boolean isEagerInit() {
return false;
}
}Variant of ObjectFactory designed specifically for injection points, allowing for programmatic optionality and lenient not-unique handling.
/**
* Variant of ObjectFactory designed specifically for injection points.
*/
interface ObjectProvider<T> extends ObjectFactory<T>, Iterable<T> {
/**
* Return an instance (possibly shared or independent) of the object managed by this factory.
* @return an object instance from this factory
* @throws BeansException in case of creation errors
*/
T getObject() throws BeansException;
/**
* Return an instance (possibly shared or independent) of the object managed by this factory.
* @return an object instance from this factory, or null if not available
* @throws BeansException in case of creation errors
*/
T getIfAvailable() throws BeansException;
/**
* Return an instance (possibly shared or independent) of the object managed by this factory.
* @param defaultSupplier a callback for supplying a default object if none present
* @return an object instance from this factory if available, otherwise the supplied default
* @throws BeansException in case of creation errors
*/
T getIfAvailable(Supplier<T> defaultSupplier) throws BeansException;
/**
* Consume an instance (possibly shared or independent) of the object managed by this factory, if available.
* @param dependencyConsumer a callback for processing the target object if available
* @throws BeansException in case of creation errors
*/
void ifAvailable(Consumer<T> dependencyConsumer) throws BeansException;
/**
* Return an instance (possibly shared or independent) of the object managed by this factory.
* @return an object instance from this factory if unique, otherwise throw NoUniqueBeanDefinitionException
* @throws BeansException in case of creation errors
*/
T getIfUnique() throws BeansException;
/**
* Return an instance (possibly shared or independent) of the object managed by this factory.
* @param defaultSupplier a callback for supplying a default object if not unique
* @return an object instance from this factory if unique, otherwise the supplied default
* @throws BeansException in case of creation errors
*/
T getIfUnique(Supplier<T> defaultSupplier) throws BeansException;
/**
* Consume an instance (possibly shared or independent) of the object managed by this factory, if unique.
* @param dependencyConsumer a callback for processing the target object if unique
* @throws BeansException in case of creation errors
*/
void ifUnique(Consumer<T> dependencyConsumer) throws BeansException;
/**
* Return a sequential Stream over all matching object instances, without specific ordering guarantees.
* @return a sequential Stream of matching instances
*/
Stream<T> stream();
/**
* Return a sequential Stream over all matching object instances, pre-ordered according to the factory's common order comparator.
* @return a sequential Stream of matching instances, ordered if possible
*/
Stream<T> orderedStream();
}Extension of BeanFactory that provides configuration facilities for a bean factory on top of the BeanFactory SPI.
/**
* Configuration interface to be implemented by most bean factories.
*/
interface ConfigurableBeanFactory extends HierarchicalBeanFactory, SingletonBeanRegistry {
String SCOPE_SINGLETON = "singleton";
String SCOPE_PROTOTYPE = "prototype";
void setParentBeanFactory(BeanFactory parentBeanFactory) throws IllegalStateException;
void setBeanClassLoader(ClassLoader beanClassLoader);
ClassLoader getBeanClassLoader();
void setTempClassLoader(ClassLoader tempClassLoader);
ClassLoader getTempClassLoader();
void setCacheBeanMetadata(boolean cacheBeanMetadata);
boolean isCacheBeanMetadata();
void setBeanExpressionResolver(BeanExpressionResolver resolver);
BeanExpressionResolver getBeanExpressionResolver();
void setConversionService(ConversionService conversionService);
ConversionService getConversionService();
void addPropertyEditorRegistrar(PropertyEditorRegistrar registrar);
void registerCustomEditor(Class<?> requiredType, Class<? extends PropertyEditor> propertyEditorClass);
void copyRegisteredEditorsTo(PropertyEditorRegistry registry);
void setTypeConverter(TypeConverter typeConverter);
TypeConverter getTypeConverter();
void addEmbeddedValueResolver(StringValueResolver valueResolver);
boolean hasEmbeddedValueResolver();
String resolveEmbeddedValue(String value);
void addBeanPostProcessor(BeanPostProcessor beanPostProcessor);
int getBeanPostProcessorCount();
void registerScope(String scopeName, Scope scope);
String[] getRegisteredScopeNames();
Scope getRegisteredScope(String scopeName);
AccessControlContext getAccessControlContext();
void copyConfigurationFrom(ConfigurableBeanFactory otherFactory);
void registerAlias(String beanName, String alias) throws BeanDefinitionStoreException;
void resolveAliases(StringValueResolver valueResolver);
BeanDefinition getMergedBeanDefinition(String beanName) throws NoSuchBeanDefinitionException;
boolean isFactoryBean(String name) throws NoSuchBeanDefinitionException;
void setCurrentlyInCreation(String beanName, boolean inCreation);
boolean isCurrentlyInCreation(String beanName);
void registerDependentBean(String beanName, String dependentBeanName);
String[] getDependentBeans(String beanName);
String[] getDependenciesForBean(String beanName);
void destroyBean(String beanName, Object beanInstance);
void destroyScopedBean(String beanName);
void destroySingletons();
}
/**
* Configuration interface to be implemented by most listable bean factories.
*/
interface ConfigurableListableBeanFactory extends ListableBeanFactory, AutowireCapableBeanFactory, ConfigurableBeanFactory {
void ignoreDependencyType(Class<?> type);
void ignoreDependencyInterface(Class<?> ifc);
void registerResolvableDependency(Class<?> dependencyType, Object autowiredValue);
boolean isAutowireCandidate(String beanName, DependencyDescriptor descriptor) throws NoSuchBeanDefinitionException;
BeanDefinition getBeanDefinition(String beanName) throws NoSuchBeanDefinitionException;
Iterator<String> getBeanNamesIterator();
void clearMetadataCache();
void freezeConfiguration();
boolean isConfigurationFrozen();
void preInstantiateSingletons() throws BeansException;
}
/**
* Interface that defines a registry for shared bean instances.
*/
interface SingletonBeanRegistry {
void registerSingleton(String beanName, Object singletonObject);
Object getSingleton(String beanName);
boolean containsSingleton(String beanName);
String[] getSingletonNames();
int getSingletonCount();
Object getSingletonMutex();
}
/**
* Sub-interface implemented by bean factories that can be part of a hierarchy.
*/
interface HierarchicalBeanFactory extends BeanFactory {
BeanFactory getParentBeanFactory();
boolean containsLocalBean(String name);
}Support for modifying bean factories after all bean definitions have been loaded but before bean instantiation.
/**
* Factory hook that allows for custom modification of an application context's bean definitions.
*/
interface BeanFactoryPostProcessor {
void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException;
}
/**
* Extension to the standard BeanFactoryPostProcessor SPI.
*/
interface BeanDefinitionRegistryPostProcessor extends BeanFactoryPostProcessor {
void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException;
}
/**
* Interface to be implemented by bean post-processors that apply after bean definition merging.
*/
interface MergedBeanDefinitionPostProcessor extends BeanPostProcessor {
void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class<?> beanType, String beanName);
default void resetBeanDefinition(String beanName) {
// No-op by default
}
}Install with Tessl CLI
npx tessl i tessl/maven-org-springframework--spring-beans