Book Image

Spring 5 Design Patterns

By : Dinesh Rajput
Book Image

Spring 5 Design Patterns

By: Dinesh Rajput

Overview of this book

Design patterns help speed up the development process by offering well tested and proven solutions to common problems. These patterns coupled with the Spring framework offer tremendous improvements in the development process. The book begins with an overview of Spring Framework 5.0 and design patterns. You will understand the Dependency Injection pattern, which is the main principle behind the decoupling process that Spring performs, thus making it easier to manage your code. You will learn how GoF patterns can be used in Application Design. You will then learn to use Proxy patterns in Aspect Oriented Programming and remoting. Moving on, you will understand the JDBC template patterns and their use in abstracting database access. Then, you will be introduced to MVC patterns to build Reactive web applications. Finally, you will move on to more advanced topics such as Reactive streams and Concurrency. At the end of this book, you will be well equipped to develop efficient enterprise applications using Spring 5 with common design patterns
Table of Contents (20 chapters)
Title Page
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Dedication
Preface

Creating aspects


As I said earlier, aspects is one of the most important terms in the AOP. Aspect merges the pointcuts and advices in the application. Let's see how to define aspect in the application.

You've already defined the TransferService interface as the subject of your aspect's pointcuts. Now let's use AspectJ annotations to create an aspect.

Define aspects using Annotation

Suppose in your bank application, you want to generate log for a money transfer service for auditing and tracking to understand customers' behaviors. A business never succeeds without understanding its customers. Whenever you will think about it from the perspective of a business, an auditing is required but isn't central to the function of the business itself; it's a separate concern. Therefore, it makes sense to define the auditing as an aspect that's applied to a transfer service. Let's see the following code which shows the Auditing class that defines the aspects for this concern:

    package com.packt.patterninspring...