IoC in general
IoC - Inversion of Control
IoC inverts the flow of control as compared to traditional control flow. In IoC, custom-written portions of a computer program receive the flow of control from a generic framework
we call library call
framework calls our code
console app vs window or web app (browser or windows calls our code)
DI as a form of IoC in Spring in general?
DI (Dependency injection) implementation in spring which moves object dependency management from object itself to container. The container is responsible for instantiating, managing lifecycle, and injection dependencies directly to beans that require it.
What are the advantages of using DI in spring?
What is the BeanFactory interface?
The root interface for accessing a Spring bean container.
This interface is implemented by objects that hold a number of bean definitions, each uniquely identified by a String name. Depending on the bean definition, the factory will return either an independent instance of a contained object (the Prototype design pattern), or a single shared instance (a superior alternative to the Singleton design pattern, in which the instance is a singleton in the scope of the factory). Which type of instance will be returned depends on the bean factory configuration: the API is the same.
What is ApplicationContext and how it differs from BeanFactory?
Application Context extends BeanFactory interface providing features
What is a Spring bean?
In Spring, the objects that form the backbone of your application and that are managed by the Spring IoC container are called beans.
What ApplicationContext implementation do you know?
What is Configuration Metadata?
The Spring IoC container consumes a form of configuration metadata. This configuration metadata represents how you, as an application developer, tell the Spring container to instantiate, configure, and assemble the objects in your application.
Meta data contains bean definitions that can be loaded into Spring IoC container.
How we can split bean definitions over multiple files in xml?
with the help of import tag

What are BeanDefinitionReaders?
Configuration metadata can be loaded separately and loaded to ApplicationContext separately.
The most flexible variant is GenericApplicationContext in combination with reader delegates — for example, with XmlBeanDefinitionReader for XML files, as the following example shows:

How pull beans from ApplicationContext?
With the help of getBean() method
T getBean(String name, Class requiredType)
How bean information is stored internally?
Within the container itself, these bean definitions are represented as BeanDefinition objects, which contain (among other information) the following metadata
How we can add manually beans to IoC?
BeanFactory must implement BeanDefinitionRegistry interface in order to be able
registerBeanDefinition()
Singleton doesn’t require BeanDefinition because they accept object

How many names can have bean?
Every bean has one or more identifiers. These identifiers must be unique within the container that hosts the bean. A bean usually has only one identifier. However, if it requires more than one, the extra ones can be considered aliases.
PS. In XML name is supplied with id attribute, additional names can be added to name attribute separated by “,” , “;” or space.
In JavaConfig it is not possible only via @Bean annotation
What if the id is not set?
If name/id not set it will be generated:
com.apress.prospring5.ch2.gmsalex.BeanFour#0
Can we get beans by class if we have defined two beans?
If two beans with the same class can get by bean class will have an exception. NoUniqueBeanDefinitionException
This can be resolved using primary.