Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Building Microservices with Spring

You're reading from   Building Microservices with Spring Master design patterns of the Spring framework to build smart, efficient microservices

Arrow left icon
Product type Course
Published in Dec 2018
Publisher Packt
ISBN-13 9781789955644
Length 502 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Rajesh R V Rajesh R V
Author Profile Icon Rajesh R V
Rajesh R V
Dinesh Rajput Dinesh Rajput
Author Profile Icon Dinesh Rajput
Dinesh Rajput
Arrow right icon
View More author details
Toc

Table of Contents (22) Chapters Close

Title Page
Copyright
About Packt
Contributors
Preface
1. Getting Started with Spring Framework 5.0 and Design Patterns FREE CHAPTER 2. Overview of GOF Design Patterns - Core Design Patterns 3. Wiring Beans using the Dependency Injection Pattern 4. Spring Aspect Oriented Programming with Proxy and Decorator pattern 5. Accessing a Database with Spring and JDBC Template Patterns 6. Improving Application Performance Using Caching Patterns 7. Implementing Reactive Design Patterns 8. Implementing Concurrency Patterns 9. Demystifying Microservices 10. Related Architecture Styles and Use Cases 11. Building Microservices with Spring Boot 12. Scale Microservices with Spring Cloud Components 13. Logging and Monitoring Microservices 14. Containerizing Microservices with Docker 15. Scaling Dockerized Microservices with Mesos and Marathon 1. Other Books You May Enjoy Index

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...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime