- Initialization phase
    - ApplicationContext creation phase:  Begins with the creation of ApplicationContext
    - BeanFactory Initialization phase : 
        1. Init Bean Definition phase : Load bean definitions and metadata
            - Bean definitions are loaded from all sources (Java configuration, xml configuration, component scanning and auto configuration)
            - Id is used to create index for the factory. Everything else is referenced as type or name
            - BeanFactory only contains reference and metadata. Nothing is yet instantiated. (No object created)
            - example : `ApplicationConfig` class is read by the system to know the registered beans
        2. Init post- Bean Definition phase: Modify beans
            - Perform work on entire BeanFactory
            - Can transform any bean or modify bean behavior in the BeanFactory before object creation
            - `Interface BeanFactoryPostProcessor` is used for this purpose. Bean definitions that use this must be `static` to make sure they act like singletons (to avoid risk side-effects of dynamic behavior)
            - helps to write custom component to impact the BeanFactory
            - Bean and system configuration is completed
            - example: loading information from `application.properties` file
        3. Bean Instantiation phase: Instantiate objects by constructor injection
            - Beans are instantiated in the factory using constructors
            - So, objects are constructed. But they are not available for use yet.
            - Done in correct order to ensure that the dependencies are created first
            - Singleton beans remains in the factory as they are created (eager instantiation) and their handle remains in BeanFactory unless IoC container is closed (to make sure the beans are available across the whole application)
            - Beans that are not singletons are not created unless they are needed (lazy instantiation) and mostly their handle is released by IoC container (So that they are easily disposed off by garbage collector once they are no longer needed)
        4. Post instantiation dependency injection phase: optional dependency by setter injection
            - Setters are called
            - `Autiwired` on non-constructors are called (fields and setters)
            - All dependencies are injected
            - Beans are yet not ready to use
        5. Post-processing of Bean before serving the object to the runtime:
            - Final point of configuration manipulation
            - Additional behaviors added to the beans 
            - `Interface BeanPostProcessor` is used to inject common behavior to a class of beans
            - Beans are finally ready to use
            - 3 sub-phases:
                1. Before initializer : proxies are built
                2. Initializer : `@PostConstruct` methods called here
                3. After initializer 
- Use phase:
    - ApplicationContext serves proxies to the original class
    - ApplicationContext maintains handle of all singleton Beans (they are not garbage collected)
    - `Interface ApplicationContextAware` can be used to give the beans insight about application (gives that class a handle to the ApplicationContext)
- Destruction phase
    - Begins when close is called on ApplicationContext
    - Any `@PreDestroy` is called and then the beans are marked as available for garbage collection
    - Once closed, context cannot be re-used again (even if the garbage collector hasn't taken the beans yet)
- Difference among Java, xml and auto configuration:
    - Java Configuration:
        - instantiation of all beans along with constructor and setter injection together
        - `@Bean` annotated methods are executed in proper order. 
    - XML injection
        - instantiation of all beans and constructor injection simultaneously
        - setter, property injection
    - Auto configuration:
        - instantiation of all beans through scanning
        - `@Autowired` on constructors injection (if there is only one constructor, then it will be the default autowired)
        - `@Autowired` on setter and field injection
- Method during object instantiation :
    - You want to perform some task before behaviors are applied in runtime
    - `@PostConstruction` annotation is used
    - must be a void method with no parameters. eg: `public void init(){}`
    - example use case : pull some data in database before anything begins
- Method after object destruction has started :
    -  You want to perform some task before spring goes out of scope
    - `@PreDestroy` annotation is used
    - must be a void method with no parameters. eg: `public void destroy(){}`
    - called after property settings
    - example use case : backup data before application shuts down

Java相关代码片段

how to read all line from file java

Java int length

intent example in android

how to doubling size of an arrays in java

how to find my jdk path

how to handle multiple throws exception in java

spring boot jdbc for postgrest

factorial of a number

types of typecasting in java

types of assignment statement in java

Thread mutex

env files in spring boot

java over loading

logging in spring boot

how to split a list in multiple lists java

can two servlet have same urlpattern

spring debug

jsp spring

hanoi tower recursion java

java equals

age difference java

sed cheat sheet

java compare method

how to make a activity default in manifest

java max memory size

yum uninstall java

timestamp to long java

how to set background image in android studio

simple calculator in android

When to use HashMap vs Map

spring boot jpa

spring data jpa

spring jdbc

jpa vs hibernate

java with checking the password matching

profile in spring boot

string templates java

spring rest controller

java arraylist get item

com.oracle.jdbc

check if map is not empty java

how to install java 8 on debian 12

regex caractères spéciaux java

java 11 yum install

manage session in redis spring boot

java: error: release version 19 not supported

bean scope in spring

xml configuration in spring

spring cdi annotations

postconstruct and predestroy in spring

java decode_message

spring lazy initialization

java decorator design pattern

dependency injection in spring

check back pressed in fragment andorid

send email to any domain using java

record java

vs code setup for input/output in java

substring java

receive second word in string java

loose coupling in java

default value of char in java

spring boot repository pattern

spring boot h2 database

add security to spring admin

java islessthan method

Java implementation of recursive Binary Search

java round double

java downcasting

range of fibonacci series in java using recursion

java by anyone

solid java

equals() and hashcode() methods in java

android java map to bundle

android start activity with data

medium java 17

java import util list

bean life cycle in spring

spring boot aop

spring aspect