Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Pointcut definitonn to capture annotations on parameters

I have been trying to define a pointcut to capture annotations on parameters in methods and I’m wondering if it is possible  i.e. one that could capture the following based on the presence of the SimpleAnnotation

 

public void setValue(int example, @SimpleAnnotation(type= "Method Parameter") String value)

{

      this.value = value;

}

 

It seems that the following definition will only capture annotations on parameters if the parameter type contains the annotation

 

pointcut executionSimplyAnnotatedParameter() : execution(* *.*(@SimpleAnnotation *)) ;

 

capturing

 

public void setAnnotatedType(AnnotatedType t){}

 

@SimpleAnnotation(type = "Annotated")

private class AnnotatedType{}

 

 

Can parameter level annotations be the subjects of pointcuts?

If so is it also possible to capture such joinpoints if the annotation has a marker annotation introduced into the annotation?

 

That is, given SimpleAnnotation is in the simple.annotation pkg

 

declare @type : simple.annotation..*Annotation : @SimpleMarker;

 

annotates SimpleAnnotation with the SimpleMarker annotation.

 

Would it be possible to capture the above setValue Method based on defining pointcuts with something along the lines of @(@SimpleMarker)

 

Any light anyone can shed on this would be excellent.

 

Thanks in advance,

 

ste


Back to the top