PerformanceMonitorInterceptor 

Let's see how to perform profiling or monitoring on our method execution. This is done with the help of a simple option provided by Spring AOP using the PerformanceMonitorInterceptor class.

As we have learned, Spring AOP allows the defining of crosscutting concerns in applications by intercepting the execution of one or more methods to add extra functionality without touching the core business classes.

The PerformanceMonitorInterceptor class from Spring AOP is an interceptor that can be tied to any custom method to be executed at the same time. This class uses a StopWatch instance to log the beginning and ending time of the method execution.

Let's monitor the transfer method of TransferService. The following ...

Get Hands-On High Performance with Spring 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.