Book Image

Building Microservices with Spring

By : Dinesh Rajput, Rajesh R V
Book Image

Building Microservices with Spring

By: Dinesh Rajput, Rajesh R V

Overview of this book

Getting Started with Spring Microservices begins with an overview of the Spring Framework 5.0, its design patterns, and its guidelines that enable you to implement responsive microservices at scale. You will learn how to use GoF patterns in application design. You will understand the dependency injection pattern, which is the main principle behind the decoupling process of the Spring Framework and makes it easier to manage your code. Then, you will learn how 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. After understanding the basics, you will move on to more advanced topics, such as reactive streams and concurrency. Written to the latest specifications of Spring that focuses on Reactive Programming, the Learning Path teaches you how to build modern, internet-scale Java applications in no time. Next, you will understand how Spring Boot is used to deploying serverless autonomous services by removing the need to have a heavyweight application server. You’ll also explore ways to deploy your microservices to Docker and managing them with Mesos. By the end of this Learning Path, you will have the clarity and confidence for implementing microservices using Spring Framework. This Learning Path includes content from the following Packt products: • Spring 5 Microservices by Rajesh R V • Spring 5 Design Patterns by Dinesh Rajput
Table of Contents (22 chapters)
Title Page
About Packt

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...