Spring Framework

Home/Spring Framework

After Throwing advice in Spring AOP – @AfterThrowing

1. Introduction: After Throwing advice gets invoked after a matched method finishes/aborts its execution by throwing an Exception. You already know, the name for such a matched method is Joinpoint. You can declare an After throwing advice using the @AfterThrowing annotation. You already know about the 5 types of advice from the previous article as listed below. Before advice – @BeforeAfter [...]

By |2020-04-28T14:49:00+00:00April 28th, 2020|Categories: Spring Framework|Tags: , |

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 – @BeforeAfter [...]

By |2020-04-28T14:44:22+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 |2020-04-28T14:38:31+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 |2020-04-28T14:29: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 – @BeforeAround advice – @AroundAfter returning – @AfterReturningAfter throwing – @AfterThrowingAfter (finally) advice – @After Execution of @Before [...]

By |2020-04-28T14:56:26+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 |2020-04-11T15:34:40+00:00April 11th, 2020|Categories: Spring Framework|Tags: , |

Profiles in Spring to register beans conditionally

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 |2020-04-08T13:08:01+00:00April 7th, 2020|Categories: Spring Framework|Tags: , |

Spring @PropertySource to read property files

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 |2020-04-08T13:07:48+00:00April 6th, 2020|Categories: Spring Framework|Tags: , , |

IoC Container, Bean Factory vs Application Context in Spring

In this article, you will learn the differences between IoC Container, 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 (DI) to manage [...]

By |2020-04-08T13:07:34+00:00April 5th, 2020|Categories: Spring Framework|Tags: , |

Classpath Scanning using @ComponentScan and Filters

Introduction: A Classpath scanning basically means, detecting the classes that need to be managed by the Spring under a specified package. You need to make use of the spring @ComponentScan annotation with the @Configuration for classpath scanning. This annotation allows you to specify a base package and also a filter if needed to fine control the package scanning. We will [...]

By |2020-04-08T13:07:26+00:00April 4th, 2020|Categories: Spring Framework|Tags: |