1 16 17 package org.springframework.aop.aspectj; 18 19 import org.aopalliance.aop.Advice; 20 21 import org.springframework.aop.Advisor; 22 import org.springframework.aop.AfterAdvice; 23 import org.springframework.aop.BeforeAdvice; 24 25 32 public abstract class AspectJAopUtils { 33 34 37 public static boolean isBeforeAdvice(Advisor anAdvisor) { 38 AspectJPrecedenceInformation precedenceInfo = getAspectJPrecedenceInformationFor(anAdvisor); 39 if (precedenceInfo != null) { 40 return precedenceInfo.isBeforeAdvice(); 41 } 42 return (anAdvisor.getAdvice() instanceof BeforeAdvice); 43 } 44 45 48 public static boolean isAfterAdvice(Advisor anAdvisor) { 49 AspectJPrecedenceInformation precedenceInfo = getAspectJPrecedenceInformationFor(anAdvisor); 50 if (precedenceInfo != null) { 51 return precedenceInfo.isAfterAdvice(); 52 } 53 return (anAdvisor.getAdvice() instanceof AfterAdvice); 54 } 55 56 61 public static AspectJPrecedenceInformation getAspectJPrecedenceInformationFor(Advisor anAdvisor) { 62 if (anAdvisor instanceof AspectJPrecedenceInformation) { 63 return (AspectJPrecedenceInformation) anAdvisor; 64 } 65 Advice advice = anAdvisor.getAdvice(); 66 if (advice instanceof AspectJPrecedenceInformation) { 67 return (AspectJPrecedenceInformation) advice; 68 } 69 return null; 70 } 71 72 } 73 | Popular Tags |