How to intercept all the repository classes which has @Repository annotation using spring AOP

Javad :

I am trying to intercept all the returning List from my BaseRepostitary files. So that i can find the names inside that lists which has to be decrypted using this decrypt method. Following is my Aspect Class

@Aspect
@Service
public class DecryptionAspect {

 @AfterReturning(value = "execution(java.util.List *(..)) "
        + "&& target(org.springframework.stereotype.Repository)) ", returning = "list")
    public void decrypt(List list) throws Exception
    {
        //Do decryption here for the names inside the list
    }

}

But the problem is this decrypt method is not triggering at the time of my Repository classes gets hit. So something is wrong in my expression. I know i can target the Repository class by the package name. But i have many Repository classes and i have given the @Repository annotation for that classes. So i want this AOP expression to identify which are all the classes have @Repository annotation present and intercept all the List items inside the Repository classes. So how to rewrite my expression. Thanks in advance!

Javad :

Finally i got it!

@AfterReturning(value="execution(* *..*Repository.*(..))",returning="list")
  public void decrypt(List list) throws Exception
    {
        //Do decryption here for the names inside the list
    }

}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=83925&siteId=1