EatMethodMatcher.java 711 B

12345678910111213141516171819202122232425262728293031
  1. package com.sf.aop.advisor;
  2. import org.springframework.aop.MethodMatcher;
  3. import java.lang.reflect.Method;
  4. // 类过滤之后 还要进行方法的匹配
  5. // aop的接口 MethodMatcher
  6. public class EatMethodMatcher implements MethodMatcher {
  7. // 实现方法的匹配逻辑
  8. @Override
  9. public boolean matches(Method method, Class<?> targetClass) {
  10. if(method.getName().equals("eat")){
  11. // 对方法的匹配验证
  12. return true;
  13. }
  14. return false;
  15. }
  16. @Override
  17. public boolean isRuntime() {
  18. return false;
  19. }
  20. @Override
  21. public boolean matches(Method method, Class<?> targetClass, Object... args) {
  22. return false;
  23. }
  24. }