lundi 2 février 2015

Get method parameters with specific annotation in aspect in scala using java reflection

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.deleteEmployee(..))")
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.






Aucun commentaire:

Enregistrer un commentaire