To use AOP in Spring, include the AspectJ weaver dependency in your project: <dependencies> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>1.9.4</version> </dependency> </dependencies> Method 1:...
Today, I want to discuss the @Transactional(readOnly = true) annotation provided by Spring. I'm bringing this up because there are many instances of @Transactional(readOnly = true) in my company's project code, and colleagues who have used it say that @Transactional(readOnly = true) improves perform...
Understanding the Bean Container Concept A Spring Bean container is responsible for managing the configuration and lifecycle of application objects. It allows you to define how each bean is created—whether as a singleton instance or a new instance per request—and how beans relate to and interact wit...
Default singleton scope for controllers Switching controllers to prototype scope How HTTP requests hit controllers: paralel vs. serial execution Building a singleton and stress-testing it for thread safety Appendix: Spring bean scopes Default behavior: controller are singletons In Spring MVC, class...
Spring MVC binds incoming HTTP data to controller method parameters with @RequestParam, @RequestBody, and @ModelAttribute, when each is appropriate, and how they differ in behavior and data sources. @RequestParam Purpose Read simple request parameters encoded as application/x-www-form-urlencoded Wor...
1. Thread-bound transaction context Spring coordinates transactional work by binding state to the current thread. The central utility is TransactionSynchronizationManager, which maintains per-thread structures such as: Resources: key/value map for things like DataSource → ConnectionHolder Registered...
Event-driven design lets components react to facts instead of polling or tightly coupling modules. After some action completes, you publish an event; interested listeners consume it and run their own logic. In classic patterns, this aligns with publish–subscribe and the observer pattern. Core pieces...