Spring 5.x

After returning advice in Spring AOP – @AfterReturning

1. Introduction: After returning advice gets invoked after a matched method finishes its execution and returns a value. You already know, the name for such a matched method is Joinpoint. You can declare an After returning advice using the @AfterReturning annotation. You already know about the 5 types of advice from the previous article as listed below. Before advice – @Before [...]

By |2024-04-02T13:14:51+00:00April 28th, 2020|Categories: Spring Framework|Tags: , |

Combine and Reuse pointcut expressions in Spring AOP

In this tutorial, you will learn to combine and reuse multiple Pointcut expressions in Spring AOP. We have only discussed a glimpse of it in the previous article. Combining means making use of two or more expressions separated by Logical operator - &&, || and !. I have included high level sample as well as a complete example to give [...]

By |2024-04-02T13:05:26+00:00April 28th, 2020|Categories: Spring Framework|Tags: , |

Pointcut expressions in Spring AOP

Introduction In this article, you will learn about the Pointcut expressions used to match advice with the target Joinpoints. Spring AOP uses AspectJ pointcut expressions. In the tutorial home page, you read the Pointcut definition. Spring AOP only supports method execution join points, so you can think of a pointcut as matching the execution of methods on Spring beans. Pointcut: [...]

By |2024-04-02T12:58:57+00:00April 28th, 2020|Categories: Spring Framework|Tags: , |

The @Before advice in Spring AOP

In this tutorial, you will learn about the @Before advice in Spring AOP. Before proceeding with this tutorial, make sure you have a good understanding of the AOP terminologies. You already know about the 5 types of advice from the previous article as listed below. Before advice – @Before Around advice – @Around After returning – @AfterReturning After throwing – @AfterThrowing After (finally) advice [...]

By |2024-04-02T12:55:45+00:00April 28th, 2020|Categories: Spring Framework|Tags: , |

Custom Events and Generic Events in Spring

Introduction: In this article, you will learn about Custom Events in Spring. Like many capabilities provided by the Spring framework, events are one of the most useful features provided by ApplicationContext in Spring. Spring allows you to publish/subscribe events synchronously as well as asynchronously. There are several standard Events in Spring as ContextRefreshedEvent, ContextStartedEvent, ContextStoppedEvent, ContextClosedEvent, RequestHandledEvent and ServletRequestHandledEvent. Spring [...]

By |2024-04-02T09:33:25+00:00April 11th, 2020|Categories: Spring Framework|Tags: , |

Spring Profiles to register beans conditionally, efficiently

In Spring Framework, profiles are logical groups of bean definitions that are registered only if the given profile is active. It is possible to assign a bean with multiple Profiles, separated with logical operations like not (!), and (&) and or (|) etc. Profiles in Spring are specified with the @Profile annotation in Spring. It is possible to use and [...]

By |2024-04-02T10:07:54+00:00April 7th, 2020|Categories: Spring Framework|Tags: , |

Read property files in using @PropertySource in Spring

Introduction: The @PropertySource annotation in Spring provides a convenient and declarative mechanism for reading properties files. Properties files contain key-value pairs, e.g. app.log.level = DEBUG. In this article, you will learn to read a value from the property file using @PropertySource and access the specific values using @Value annotation and Environment field. If you are new to Spring, make sure [...]

By |2024-04-02T10:26:39+00:00April 6th, 2020|Categories: Spring Framework|Tags: , , |

IoC Containers in Spring Bean Factory vs Application Context

In this article, you will learn the differences between IoC Containers in Spring, namely Application Context and the Bean Factory in Spring Framework. The Spring IoC container is the core of the Spring Framework. It creates the class instances, wires them together, configures them, and manages their complete life cycle from creation till destruction. The Spring container uses dependency injection [...]

By |2024-04-02T11:05:21+00:00April 5th, 2020|Categories: Spring Framework|Tags: , |

Manage beans using @Component, @Repository, @Service in Spring

Introduction: In this tutorial, you will learn the different Spring stereotype annotations (@Component, @Repository and @Service) to declare any class as a Spring-managed Bean. Spring MVC also has several other annotations like @Controller and @RestController. The classes that are managed as beans in Spring are known as Managed Components. There are basically few stereotype annotations in spring that declare classes [...]

By |2024-04-02T10:49:42+00:00April 3rd, 2020|Categories: Spring Framework|Tags: |

Spring bean Lifecycle Callbacks

In this article, you will learn the Spring bean lifecycle and different ways to run bean initialization callbacks and bean destruction callbacks. Bean lifecycle simply means you want to execute callbacks before the spring bean is available to use and similarly execute callbacks before the bean is destroyed. There are several ways to configure the Spring bean lifecycle callbacks as [...]

By |2024-04-02T11:20:54+00:00January 17th, 2020|Categories: Spring Framework|Tags: , , |
Go to Top