Class BeanCreator
java.lang.Object
com.bobocode.bring.core.context.impl.BeanCreator
Responsible for creating beans and injecting dependencies into these beans based on provided definitions.
- Since:
- 1.0
- Author:
- Blyzhnytsia Team
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AnnotationBringBeanRegistry
private final ConstructorBeanInjection
private final FieldBeanInjection
private final SetterBeanInjection
-
Constructor Summary
ConstructorsConstructorDescriptionBeanCreator
(AnnotationBringBeanRegistry beanRegistry, ClassPathScannerFactory classPathScannerFactory) Constructs a BeanCreator. -
Method Summary
Modifier and TypeMethodDescriptioncreate
(Class<?> clazz, String beanName, BeanDefinition beanDefinition) Creates a bean of the specified class and injects dependencies into it.private void
injectDependencies
(Class<?> clazz, Object bean) Injects dependencies into the passed bean based on its class.registerConfigurationBean
(String beanName, BeanDefinition beanDefinition) Registers a configuration bean in the context based on the provided bean name and definition.
-
Field Details
-
beanRegistry
-
createBeanUsingConstructor
-
fieldBeanInjection
-
setterBeanInjection
-
-
Constructor Details
-
BeanCreator
public BeanCreator(AnnotationBringBeanRegistry beanRegistry, ClassPathScannerFactory classPathScannerFactory) Constructs a BeanCreator.- Parameters:
beanRegistry
- The registry storing beans and their definitions.classPathScannerFactory
- The factory for creating class path scanners.
-
-
Method Details
-
create
Creates a bean of the specified class and injects dependencies into it.- Parameters:
clazz
- The class of the bean to be created.beanName
- The name of the bean being created.beanDefinition
- The definition of the bean being created.- Returns:
- The created bean object.
-
registerConfigurationBean
Registers a configuration bean in the context based on the provided bean name and definition. Resolves dependencies and instantiates the configuration bean within the context.- Parameters:
beanName
- The name of the configuration bean to be registered.beanDefinition
- The definition of the configuration bean.- Returns:
- The registered configuration bean.
-
injectDependencies
Injects dependencies into the passed bean based on its class.- Parameters:
clazz
- The class of the bean.bean
- The bean.
-