Announcement Announcement Module
No announcement yet.
Trouble with @annotation :0 formal unbound in pointcut Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Trouble with @annotation :0 formal unbound in pointcut

    Im trying to introduce pre validation inside my service classes with aspects.
    For this i have created an annotation for validation
    public @interface Validatable {
    	public String key();
    	public Class[] validators();
    The idea was to intercept all methods inside the service layer if they have been marked with a validatable annotation.
    I have a system architecture aspect which looks like this
    public class SystemArchitectureAspect {
    	public void inServicesLayer(){}
    	public void inDaoLayer(){}
    	public void inRulesLayer(){}
    	@Pointcut("execution(* com.example.*.services.*.*(..))")
    	public void subServiceLayer(){}
    Aspect for validation as
    public class ServiceValidationAspect {
    	@Pointcut("com.example.aspects.SystemArchitectureAspect.inServicesLayer() " +
    			"&& com.example.aspects.SystemArchitectureAspect.subServiceLayer()")	
              public void doServicePrevalidation(){}
    	@Around("com.example.aspects.ServiceValidationAspect.doServicePrevalidation() "+
    	" && @annotation( ")
    	public void validate(ProceedingJoinPoint pjp,AliseServicePrevalidate va){
    The idea was to inspect the annotation at runtime to find the validator classes. But I am not able to get the around aspect going . It always throws me an illegal argument exception with 0 formals bound.

    Im using spring-aop 2.5.3 and aspectj version 1.5.3 vers. By spring documentation this is possible
    @Before(" && " + 
    public void audit(Auditable auditable) {
      AuditCode code = auditable.value();
      // ...
    Can anyone tell me where im going wrong? or did i get the concept all together wrong?

  • #2
    public void validate(ProceedingJoinPoint pjp,AliseServicePrevalidate va)

    What is va?

    In your advice declaration you don't appear to be binding the parameter 'va' - the pointcut must bind it to state where the value for it comes from when the advice is invoked.

    Andy Clement
    AspectJ Project Lead


    • #3
      thanks Andy for the quick reply..It works perfectly
      Apologies for the haste of the posting (late hours i guess)

      Do you think it is a good idea to keep validation as an aspect?