@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2012 the original author or authors .
* Copyright 2002 - 2014 the original author or authors .
*
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
@ -50,19 +50,21 @@ public class DefaultAdvisorChainFactory implements AdvisorChainFactory, Serializ
@@ -50,19 +50,21 @@ public class DefaultAdvisorChainFactory implements AdvisorChainFactory, Serializ
public List < Object > getInterceptorsAndDynamicInterceptionAdvice (
Advised config , Method method , Class < ? > targetClass ) {
// This is somewhat tricky... w e have to process introductions first,
// This is somewhat tricky... W e have to process introductions first,
// but we need to preserve order in the ultimate list.
List < Object > interceptorList = new ArrayList < Object > ( config . getAdvisors ( ) . length ) ;
boolean hasIntroductions = hasMatchingIntroductions ( config , targetClass ) ;
Class < ? > actualClass = ( targetClass ! = null ? targetClass : method . getDeclaringClass ( ) ) ;
boolean hasIntroductions = hasMatchingIntroductions ( config , actualClass ) ;
AdvisorAdapterRegistry registry = GlobalAdvisorAdapterRegistry . getInstance ( ) ;
for ( Advisor advisor : config . getAdvisors ( ) ) {
if ( advisor instanceof PointcutAdvisor ) {
// Add it conditionally.
PointcutAdvisor pointcutAdvisor = ( PointcutAdvisor ) advisor ;
if ( config . isPreFiltered ( ) | | pointcutAdvisor . getPointcut ( ) . getClassFilter ( ) . matches ( target Class) ) {
if ( config . isPreFiltered ( ) | | pointcutAdvisor . getPointcut ( ) . getClassFilter ( ) . matches ( actual Class) ) {
MethodInterceptor [ ] interceptors = registry . getInterceptors ( advisor ) ;
MethodMatcher mm = pointcutAdvisor . getPointcut ( ) . getMethodMatcher ( ) ;
if ( MethodMatchers . matches ( mm , method , target Class, hasIntroductions ) ) {
if ( MethodMatchers . matches ( mm , method , actual Class, hasIntroductions ) ) {
if ( mm . isRuntime ( ) ) {
// Creating a new object instance in the getInterceptors() method
// isn't a problem as we normally cache created chains.
@ -78,7 +80,7 @@ public class DefaultAdvisorChainFactory implements AdvisorChainFactory, Serializ
@@ -78,7 +80,7 @@ public class DefaultAdvisorChainFactory implements AdvisorChainFactory, Serializ
}
else if ( advisor instanceof IntroductionAdvisor ) {
IntroductionAdvisor ia = ( IntroductionAdvisor ) advisor ;
if ( config . isPreFiltered ( ) | | ia . getClassFilter ( ) . matches ( target Class) ) {
if ( config . isPreFiltered ( ) | | ia . getClassFilter ( ) . matches ( actual Class) ) {
Interceptor [ ] interceptors = registry . getInterceptors ( advisor ) ;
interceptorList . addAll ( Arrays . asList ( interceptors ) ) ;
}
@ -88,18 +90,19 @@ public class DefaultAdvisorChainFactory implements AdvisorChainFactory, Serializ
@@ -88,18 +90,19 @@ public class DefaultAdvisorChainFactory implements AdvisorChainFactory, Serializ
interceptorList . addAll ( Arrays . asList ( interceptors ) ) ;
}
}
return interceptorList ;
}
/ * *
* Determine whether the Advisors contain matching introductions .
* /
private static boolean hasMatchingIntroductions ( Advised config , Class < ? > target Class) {
private static boolean hasMatchingIntroductions ( Advised config , Class < ? > actual Class) {
for ( int i = 0 ; i < config . getAdvisors ( ) . length ; i + + ) {
Advisor advisor = config . getAdvisors ( ) [ i ] ;
if ( advisor instanceof IntroductionAdvisor ) {
IntroductionAdvisor ia = ( IntroductionAdvisor ) advisor ;
if ( ia . getClassFilter ( ) . matches ( target Class) ) {
if ( ia . getClassFilter ( ) . matches ( actual Class) ) {
return true ;
}
}