I am using spring aop to create an annotation for some crosscut purpose. Below is the sample:
@Aspect
@Component
@Slf4j
public class MyAspect {
@Autowired
private MyService myService
@Before("@annotation(MyAnnotationCheck)")
@SneakyThrows
public void check(JoinPoint joinPoint) {
// This is the object that I am going to reload in the
// function that being marked by the annotation I created.
// Anyway I can pass this into the annotated method instead
// of load from db again?
EntityA myObj = myService.loadFromDB();
// ...
}
}
Following is the method being annotated, which is in different class
@MyAnnotationCheck(checkType = "abc")
public void myMethod(MyRequest request) {
EntityA objA = myService.loadFromDB(); // Reload the object from DB
}
What should I do with it? Anyway I can pass the object from the Aspect function to the method annotated?