Monitoring services and request handlers
Aspects has some trade-offs when used to intercept DAO transactions. Most often we use aspects to monitor services and @Controller transactions. This recipe will show us the easiest way to monitor service and request transactions using transaction management.
Getting started
Open ch05 and add an @Aspect that will monitor EmployeeController's deleteRecord() request handler and EmployeeServiceImpl's readEmployee() using a custom annotation.
How to do it...
After the DAO layer, let us monitor all service and @Controller request transactions by following these steps:
- This is the first recipe that will showcase the use of custom transaction management annotations in formulating Pointcuts for advices. Using Reflection APIs, create the following method-level annotation inside the
org.packt.aop.transaction.annotationpackage:
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface MonitorService { } - To make
@MonitorTransactiontransaction...