1 22 package org.jboss.aop.pointcut; 23 24 import java.lang.reflect.Method ; 25 import java.util.ArrayList ; 26 import java.util.Iterator ; 27 28 import org.jboss.aop.Advisor; 29 import org.jboss.aop.introduction.InterfaceIntroduction; 30 import org.jboss.aop.pointcut.ast.ClassExpression; 31 32 42 public class ProxyMatcherStrategy extends MatcherStrategy 43 { 44 public ProxyMatcherStrategy() 45 { 46 } 47 48 protected boolean checkIntroductions(Class clazz, ClassExpression instanceOf, Advisor advisor) 49 { 50 try 51 { 52 if (advisor != null) 53 { 54 ArrayList intros = advisor.getInterfaceIntroductions(); 55 if (intros.size() > 0) 56 { 57 for (Iterator itIntro = intros.iterator() ; itIntro.hasNext() ; ) 58 { 59 InterfaceIntroduction intro = (InterfaceIntroduction)itIntro.next(); 60 String [] introductions = intro.getInterfaces(); 61 if (introductions != null) 62 { 63 for (int i = 0 ; i < introductions.length ; i++) 64 { 65 Class iface = Thread.currentThread().getContextClassLoader().loadClass(introductions[i]); 66 if (subtypeOf(iface, instanceOf, advisor)) return true; 67 } 68 } 69 ArrayList mixins = intro.getMixins(); 70 if (mixins.size() > 0) 71 { 72 for (Iterator itMixin = mixins.iterator() ; itMixin.hasNext() ; ) 73 { 74 InterfaceIntroduction.Mixin mixin = (InterfaceIntroduction.Mixin)itMixin.next(); 75 String [] mixinInterfaces = mixin.getInterfaces(); 76 if (mixinInterfaces != null) 77 { 78 for (int i = 0 ; i < mixinInterfaces.length ; i++) 79 { 80 Class iface = Thread.currentThread().getContextClassLoader().loadClass(mixinInterfaces[i]); 81 if (subtypeOf(iface, instanceOf, advisor)) return true; 82 } 83 } 84 } 85 } 86 } 87 } 88 } 89 } 90 catch (ClassNotFoundException e) 91 { 92 throw new RuntimeException (e); 93 } 94 95 return false; 96 } 97 98 102 public Class getDeclaringClass(Advisor advisor, Method m) 103 { 104 final Class methodClass = m.getDeclaringClass(); 105 final Class advisorClass = advisor.getClazz(); 106 107 if (advisorClass != null && methodClass.isInterface()) 108 { 109 return advisorClass; 110 } 111 return methodClass; 112 } 113 114 115 } 116 | Popular Tags |