I am trying to @Before in AOP. I have a dto where I implemented an interface and in the controller method the dto is one of the parameter and since it implemented the interface I want to identify the parameter with the implemented interface in the point cut.I have tried the following
Employee .java
package com.example.demo;
public class Employee implements UserData {
private String name;
private String id;
private String clazz;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getClazz() {
return clazz;
}
public void setClazz(String clazz) {
this.clazz = clazz;
}
@Override
public String getData() {
String data=name+"_"+id;
return data;
}
}
Controller
@RestController
public class HelloController {
@RequestMapping("/")
public String getEmployees(Employee emp) {
return "emp";
}
interface
public interface Tenant {
String getData();
}
Aspect
@Before("pointcut(tenant)")
public void before(Tenant tenant){
}
@Pointcut("execution(* com.example.demo.*.*(UserData))"+" &&
args(UserData))")
public void pointcut(UserData UserData) {
System.out.println("In aspect********************"+UserData.getData());
}
}
here in the above aspect UserData is nt identified as instance of Employee..How to achieve that? I can put (..) in the point cut but I want it tobe specific to UserData.