I am using Spring AOP and have below aspect:
@Aspect
public class LoggingAspect {
@Before(\"execution(* com.mkyong.customer.bo.CustomerBo.addCustomer(..
you can get method parameter and its value and if annotated with a annotation with following code:
Map
....
private Map getAnnotatedParameterValue(Method method, Object[] args) {
Map annotatedParameters = new HashMap<>();
Annotation[][] parameterAnnotations = method.getParameterAnnotations();
Parameter[] parameters = method.getParameters();
int i = 0;
for (Annotation[] annotations : parameterAnnotations) {
Object arg = args[i];
String name = parameters[i++].getDeclaringExecutable().getName();
for (Annotation annotation : annotations) {
if (annotation instanceof AuditExpose) {
annotatedParameters.put(name, arg);
}
}
}
return annotatedParameters;
}