I am using aop in scala
using aspectj
. I have a method
def delete(@Id id:Long, name:String)
How can I get the value of id
in my aspect file.
@Around("execution (* com.myapp.Employee.delete(..))")
def message(joinPoint: ProceedingJoinPoint): Object = {
val methodSignature =joinPoint.getSignature.asInstanceOf[MethodSignature]
//get the value of the field id
joinPoint.proceed
}
I am not able to get the values.
If I try
val res = methodSignature.getMethod.getParameterAnnotations
res.map(annotations => println("size = "+annotations.length))
It is always printing the size as 0.
EDIT:
Now I am getting the size correctly. The method was in object
. But I think there are some problems with java reflection to read object
. I changed to class
and now able to get the annotations. But how can I get the parameter which is annotated with that annotation?