AOP method profiling
Applications can have many business methods. Due to some implementation issues, some methods take time and we want to measure how much time is taken by those methods and we may want to analyze method arguments, as well. Spring AOP provides a way to perform method profiling without touching business methods. Let's see how.
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...