1 22 package org.jboss.aop.util; 23 24 import java.lang.reflect.Field ; 25 import java.lang.reflect.Method ; 26 27 import javassist.CtField; 28 import javassist.CtMethod; 29 import javassist.Modifier; 30 31 import org.jboss.aop.ClassAdvisor; 32 33 38 public class Advisable 39 { 40 43 public static boolean isAdvisable(CtMethod method) 44 { 45 return isAdvisableMethod(method.getModifiers(), method.getName()); 46 } 47 48 public static boolean isAdvisable(Method method) 49 { 50 return isAdvisableMethod(method.getModifiers(), method.getName()); 51 } 52 53 public static boolean isAdvisableMethod(int modifiers, String name) 54 { 55 return 56 (modifiers & Modifier.ABSTRACT) == 0 && 57 (modifiers & Modifier.NATIVE) == 0 && 58 !name.endsWith(ClassAdvisor.NOT_TRANSFORMABLE_SUFFIX) && 59 !name.equals("_getAdvisor") && 60 !name.equals("_getClassAdvisor") && 61 !name.equals("_getInstanceAdvisor") && 62 !name.equals("_setInstanceAdvisor") && 63 !name.equals("class$") && 64 !name.equals(""); 65 } 66 69 public static boolean isAdvisable(CtField field) 70 { 71 return isAdvisableField(field.getModifiers(), field.getName()); 72 } 73 74 public static boolean isAdvisable(Field field) 75 { 76 return isAdvisableField(field.getModifiers(), field.getName()); 77 } 78 79 public static boolean isAdvisableField(int modifiers, String name) 80 { 81 return (modifiers & Modifier.FINAL) == 0 && 82 (!name.endsWith(ClassAdvisor.NOT_TRANSFORMABLE_SUFFIX)) && 83 !name.equals("_instanceAdvisor") && 84 !name.endsWith("$aop$mixin") && 85 (name.indexOf('$') == -1); 86 } 87 } 88 | Popular Tags |