Skip to main content

Posts

Bean Scopes in Spring

Recent posts

Bean Lifecycle in Spring Framework

Bean Lifecycle in Spring Framework: Complete Deep Dive The Bean Lifecycle is arguably the most important architectural topic in Spring Core. It explains precisely how a bean is created, initialized, utilized, and eventually destroyed inside the Inversion of Control (IOC) Container. Most developers can recite a basic summary: Instantiate Bean → Inject Dependencies → @PostConstruct → Bean Ready → @PreDestroy 1. What is the Bean Lifecycle? Standard Definition The Bean Lifecycle is the complete chronological journey of a Spring Bean from its metadata parsing to its destruction inside the Spring IOC Container. High-Level Initialization Flow SpringApplication.run() | V Create ApplicationContext | V Component Scan | V Create BeanDefinition | V Instantiate Bean | V Inject Dependencies | V Initialize Bean | V Store ...

Dependency Injection & Bean Creation Deep Dive

Dependency Injection & Bean Creation Deep Dive To truly master the Spring Framework and Spring Boot, you must understand exactly how it manages objects, resolves dependencies, and orchestrates its internal startup flow. Let's break down the core architectural concepts of Dependency Injection and Bean Creation. 1. What is a Bean? Standard Definition A Bean is an object that is created, managed, configured, and destroyed by the Spring IOC Container. Consider a standard Java object: public class EmployeeService { } // Normal Java Object (NOT a Spring Bean) EmployeeService service = new EmployeeService (); However, when Spring creates it, it becomes a Spring Bean: @Service public class EmployeeService { } What does "Managed by Spring" mean? When an object is managed by Spring, the framework automatically handles: Object Creation Dependency Injection Initialization Configura...

Spring Boot Auto Configuration: Deep Internal Working

What is Auto Configuration? Auto Configuration is a Spring Boot feature that automatically configures Spring Beans based on the libraries available in the classpath, existing beans, and application properties. Auto-configuration is the core mechanism responsible for Spring Boot's rapid industry adoption. It shifts the burden of infrastructure bootstrapping away from manual declaration to automated, runtime classpath sensing. 1. The Problem Space: Traditional Spring Framework Limitations To confidently explain Auto-Configuration, you must contextually articulate why traditional Spring configuration became a bottleneck. Historically, bootstrapping enterprise Java contexts required massive, repetitive metadata overhead. Traditional Spring Setup (The Boilerplate) Configuring a simple relational database required explicitly declaring infrastructure beans manually, risking context validation failures: @Configuration public class DatabaseConfig ...

HashMap in Java

HashMap HashMap is one of the most optimized, heavily tested, and important data structures in the entire Java ecosystem. On the surface, it provides a simple interface to store data in a Key $\rightarrow$ Value format. But under the hood, its backend architecture is a masterpiece of algorithmic efficiency and bitwise optimization. HashMap <Integer, String> map = new HashMap <>(); map. put (101, "Madhusudan" ); map. put (102, "Rahul" ); 1. What Exactly is HashMap? As a core component of the Java Collections Framework, HashMap is the standard implementation of the Map interface. It relies entirely on the concept of hashing to achieve blazing-fast insertion and retrieval speeds. Feature HashMap Behavior Ordering No guarantee of order Thread Safe No (Use ConcurrentHashMap for threads...

Set summary

Java Set Deep Dive - Official Documentation ☰ Menu - Java Set Deep Dive Java Collections 1. Set Architecture 2. HashSet Internals 3. LinkedHashSet 4. Sorted & NavigableSet 5. TreeSet & Red-Black Tree 6. Performance & Interviews The Set Architecture Official Definition: "A collection that contains no duplicate elements. More formally, sets contain no pair of elements e1 and e2 such that e1.equals(e2)." — java.util.Set 1. The Complete Hierarchy Before understanding the backend, you must understand the architectural flow. The Set interface inherits directly from Collection . Iterable ⬇ Collection ⬇ Set HashSet ⬇ LinkedHashSet SortedSet ⬇ NavigableSet ...