1 16 17 package org.springframework.aop.framework; 18 19 import java.lang.reflect.Method ; 20 21 import org.springframework.aop.MethodMatcher; 22 23 32 public abstract class MethodMatchers { 33 34 public static MethodMatcher union(MethodMatcher a, MethodMatcher b) { 35 return new UnionMethodMatcher(a, b); 36 } 37 public static MethodMatcher intersection(MethodMatcher a, MethodMatcher b) { 38 return new IntersectionMethodMatcher(a, b); 39 } 40 41 42 private static class UnionMethodMatcher implements MethodMatcher { 43 44 private MethodMatcher a; 45 private MethodMatcher b; 46 47 public UnionMethodMatcher(MethodMatcher a, MethodMatcher b) { 48 this.a = a; 49 this.b = b; 50 } 51 52 public boolean matches(Method m, Class targetClass) { 53 return a.matches(m, targetClass) || b.matches(m, targetClass); 54 } 55 56 public boolean isRuntime() { 57 return a.isRuntime() || b.isRuntime(); 58 } 59 60 public boolean matches(Method m, Class targetClass, Object [] args) { 61 return a.matches(m, targetClass, args) || b.matches(m, targetClass, args); 62 } 63 64 } 65 66 private static class IntersectionMethodMatcher implements MethodMatcher { 67 68 private MethodMatcher a; 69 private MethodMatcher b; 70 71 public IntersectionMethodMatcher(MethodMatcher a, MethodMatcher b) { 72 this.a = a; 73 this.b = b; 74 } 75 76 77 public boolean matches(Method m, Class targetClass) { 78 return a.matches(m, targetClass) && b.matches(m, targetClass); 79 } 80 81 public boolean isRuntime() { 82 return a.isRuntime() || b.isRuntime(); 83 } 84 85 public boolean matches(Method m, Class targetClass, Object [] args) { 86 return a.matches(m, targetClass, args) && b.matches(m, targetClass, args); 87 } 88 89 } 90 91 } 92 | Popular Tags |