Skip to content
GitLab
Explore
Sign in
Register
Commits on Source (5)
New upstream version 4.3.15
· e9dafb5c
Emmanuel Bourg
authored
Apr 08, 2018
e9dafb5c
New upstream version 4.3.16
· eb01d39c
Emmanuel Bourg
authored
Oct 05, 2018
eb01d39c
New upstream version 4.3.17
· 9a51aaff
Emmanuel Bourg
authored
Oct 05, 2018
9a51aaff
New upstream version 4.3.18
· ef9a891c
Emmanuel Bourg
authored
Oct 05, 2018
ef9a891c
New upstream version 4.3.19
· 28270ba2
Emmanuel Bourg
authored
Oct 05, 2018
28270ba2
Show whitespace changes
Inline
Side-by-side
build.gradle
View file @
28270ba2
...
...
@@ -40,7 +40,7 @@ configure(allprojects) { project ->
ext
.
ejbVersion
=
"3.0"
ext
.
fileuploadVersion
=
"1.3.3"
ext
.
freemarkerVersion
=
"2.3.23"
ext
.
groovyVersion
=
"2.4.1
3
"
ext
.
groovyVersion
=
"2.4.1
5
"
ext
.
gsonVersion
=
"2.8.2"
ext
.
guavaVersion
=
"20.0"
ext
.
hamcrestVersion
=
"1.3"
...
...
@@ -52,7 +52,7 @@ configure(allprojects) { project ->
ext
.
hsqldbVersion
=
"2.3.4"
ext
.
httpasyncVersion
=
"4.1.3"
ext
.
httpclientVersion
=
"4.5.5"
ext
.
jackson2Version
=
"2.8.11"
ext
.
jackson2Version
=
"2.8.11
.2
"
ext
.
jasperreportsVersion
=
"6.2.1"
// our tests fail with JR-internal NPEs against 6.2.2 and higher
ext
.
javamailVersion
=
"1.5.6"
ext
.
jettyVersion
=
"9.3.14.v20161028"
// as of 9.3.15, Jetty has hard Servlet 3.1 requirement
...
...
@@ -62,20 +62,20 @@ configure(allprojects) { project ->
ext
.
jtaVersion
=
"1.2"
ext
.
junitVersion
=
"4.12"
ext
.
log4jVersion
=
"1.2.17"
ext
.
nettyVersion
=
"4.1.2
0
.Final"
ext
.
nettyVersion
=
"4.1.2
9
.Final"
ext
.
okhttpVersion
=
"2.7.5"
ext
.
okhttp3Version
=
"3.8.1"
ext
.
openjpaVersion
=
"2.4.2"
ext
.
poiVersion
=
"3.14"
ext
.
reactorVersion
=
"2.0.8.RELEASE"
ext
.
romeVersion
=
"1.7.4"
ext
.
slf4jVersion
=
"1.7.2
1
"
ext
.
slf4jVersion
=
"1.7.2
5
"
ext
.
snakeyamlVersion
=
"1.17"
ext
.
snifferVersion
=
"1.1
5
"
ext
.
snifferVersion
=
"1.1
6
"
ext
.
testngVersion
=
"6.9.10"
ext
.
tiles2Version
=
"2.2.2"
ext
.
tiles3Version
=
"3.0.7"
ext
.
tomcatVersion
=
"8.5.
27
"
ext
.
tomcatVersion
=
"8.5.
33
"
ext
.
tyrusVersion
=
"1.3.5"
// constrained by WebLogic 12.1.3 support
ext
.
undertowVersion
=
"1.3.33.Final"
ext
.
xmlunitVersion
=
"1.6"
...
...
@@ -316,7 +316,7 @@ project("spring-core") {
}
// Repackage net.sf.cglib => org.springframework.cglib
rule
(
pattern:
"net.sf.cglib.**"
,
result:
"org.springframework.cglib.@1"
)
// As mentioned above, transform cglib
"
s internal asm dependencies from
// As mentioned above, transform cglib
'
s internal asm dependencies from
// org.objectweb.asm => org.springframework.asm. Doing this counts on the
// the fact that Spring and cglib depend on the same version of asm!
rule
(
pattern:
"org.objectweb.asm.**"
,
result:
"org.springframework.asm.@1"
)
...
...
@@ -704,7 +704,7 @@ project("spring-web") {
optional
(
"com.squareup.okhttp:okhttp:${okhttpVersion}"
)
optional
(
"com.squareup.okhttp3:okhttp:${okhttp3Version}"
)
optional
(
"com.fasterxml.jackson.core:jackson-databind:${jackson2Version}"
)
optional
(
"com.fasterxml.jackson.dataformat:jackson-dataformat-xml:
${jackson2Version}
"
)
optional
(
"com.fasterxml.jackson.dataformat:jackson-dataformat-xml:
2.8.11
"
)
optional
(
"com.google.code.gson:gson:${gsonVersion}"
)
optional
(
"com.rometools:rome:${romeVersion}"
)
optional
(
"org.eclipse.jetty:jetty-servlet:${jettyVersion}"
)
{
...
...
@@ -720,12 +720,13 @@ project("spring-web") {
testCompile
(
project
(
":spring-context-support"
))
// for JafMediaTypeFactory
testCompile
(
"xmlunit:xmlunit:${xmlunitVersion}"
)
testCompile
(
"org.slf4j:slf4j-jcl:${slf4jVersion}"
)
testCompile
(
"org.skyscreamer:jsonassert:1.4.0"
)
testCompile
(
"org.apache.taglibs:taglibs-standard-jstlel:1.2.1"
)
{
exclude
group:
"org.apache.taglibs"
,
module:
"taglibs-standard-spec"
}
testCompile
(
"com.fasterxml.jackson.datatype:jackson-datatype-joda:
${jackson2Version}
"
)
testCompile
(
"com.fasterxml.jackson.datatype:jackson-datatype-jdk8:
${jackson2Version}
"
)
testCompile
(
"com.fasterxml.jackson.module:jackson-module-kotlin:
${jackson2Version}
"
)
testCompile
(
"com.fasterxml.jackson.datatype:jackson-datatype-joda:
2.8.11
"
)
testCompile
(
"com.fasterxml.jackson.datatype:jackson-datatype-jdk8:
2.8.11
"
)
testCompile
(
"com.fasterxml.jackson.module:jackson-module-kotlin:
2.8.11.1
"
)
testCompile
(
"com.squareup.okhttp3:mockwebserver:${okhttp3Version}"
)
testRuntime
(
"com.sun.mail:javax.mail:${javamailVersion}"
)
}
...
...
@@ -836,7 +837,7 @@ project("spring-webmvc") {
exclude
group:
"org.springframework"
,
module:
"spring-context"
}
optional
(
"com.fasterxml.jackson.core:jackson-databind:${jackson2Version}"
)
optional
(
"com.fasterxml.jackson.dataformat:jackson-dataformat-xml:
${jackson2Version}
"
)
optional
(
"com.fasterxml.jackson.dataformat:jackson-dataformat-xml:
2.8.11
"
)
optional
(
"com.rometools:rome:${romeVersion}"
)
optional
(
"javax.el:javax.el-api:2.2.5"
)
optional
(
"org.apache.tiles:tiles-api:${tiles3Version}"
)
...
...
gradle.properties
View file @
28270ba2
version
=
4.3.1
4
.RELEASE
version
=
4.3.1
9
.RELEASE
spring-aop/src/main/java/org/springframework/aop/MethodMatcher.java
View file @
28270ba2
/*
* Copyright 2002-201
5
the original author or authors.
* Copyright 2002-201
8
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.
...
...
@@ -48,10 +48,11 @@ import java.lang.reflect.Method;
public
interface
MethodMatcher
{
/**
* Perform static checking whether the given method matches. If this
* returns {@code false} or if the {@link #isRuntime()} method
* returns {@code false}, no runtime check (i.e. no.
* {@link #matches(java.lang.reflect.Method, Class, Object[])} call) will be made.
* Perform static checking whether the given method matches.
* <p>If this returns {@code false} or if the {@link #isRuntime()}
* method returns {@code false}, no runtime check (i.e. no
* {@link #matches(java.lang.reflect.Method, Class, Object[])} call)
* will be made.
* @param method the candidate method
* @param targetClass the target class (may be {@code null}, in which case
* the candidate class must be taken to be the method's declaring class)
...
...
spring-aop/src/main/java/org/springframework/aop/aspectj/AbstractAspectJAdvice.java
View file @
28270ba2
/*
* Copyright 2002-201
7
the original author or authors.
* Copyright 2002-201
8
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.
...
...
@@ -227,7 +227,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
}
/**
* Set
s
the
<b>
declaration order
</b>
of this advice within the aspect
* Set the declaration order of this advice within the aspect
.
*/
public
void
setDeclarationOrder
(
int
order
)
{
this
.
declarationOrder
=
order
;
...
...
@@ -366,7 +366,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
* to which argument name. There are multiple strategies for determining
* this binding, which are arranged in a ChainOfResponsibility.
*/
public
synchronized
final
void
calculateArgumentBindings
()
{
public
final
synchronized
void
calculateArgumentBindings
()
{
// The simple case... nothing to bind.
if
(
this
.
argumentsIntrospected
||
this
.
parameterTypes
.
length
==
0
)
{
return
;
...
...
@@ -374,10 +374,8 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
int
numUnboundArgs
=
this
.
parameterTypes
.
length
;
Class
<?>[]
parameterTypes
=
this
.
aspectJAdviceMethod
.
getParameterTypes
();
if
(
maybeBindJoinPoint
(
parameterTypes
[
0
])
||
maybeBindProceedingJoinPoint
(
parameterTypes
[
0
]))
{
numUnboundArgs
--;
}
else
if
(
maybeBindJoinPointStaticPart
(
parameterTypes
[
0
]))
{
if
(
maybeBindJoinPoint
(
parameterTypes
[
0
])
||
maybeBindProceedingJoinPoint
(
parameterTypes
[
0
])
||
maybeBindJoinPointStaticPart
(
parameterTypes
[
0
]))
{
numUnboundArgs
--;
}
...
...
spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscoverer.java
View file @
28270ba2
...
...
@@ -415,7 +415,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
String
[]
tokens
=
StringUtils
.
tokenizeToStringArray
(
this
.
pointcutExpression
,
" "
);
for
(
int
i
=
0
;
i
<
tokens
.
length
;
i
++)
{
String
toMatch
=
tokens
[
i
];
int
firstParenIndex
=
toMatch
.
indexOf
(
"("
);
int
firstParenIndex
=
toMatch
.
indexOf
(
'('
);
if
(
firstParenIndex
!=
-
1
)
{
toMatch
=
toMatch
.
substring
(
0
,
firstParenIndex
);
}
...
...
@@ -575,7 +575,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
if
(
toMatch
.
startsWith
(
"!"
))
{
toMatch
=
toMatch
.
substring
(
1
);
}
int
firstParenIndex
=
toMatch
.
indexOf
(
"("
);
int
firstParenIndex
=
toMatch
.
indexOf
(
'('
);
if
(
firstParenIndex
!=
-
1
)
{
toMatch
=
toMatch
.
substring
(
0
,
firstParenIndex
);
}
...
...
spring-aop/src/main/java/org/springframework/aop/aspectj/DeclareParentsAdvisor.java
View file @
28270ba2
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
8
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.
...
...
@@ -20,6 +20,7 @@ import org.aopalliance.aop.Advice;
import
org.springframework.aop.ClassFilter
;
import
org.springframework.aop.IntroductionAdvisor
;
import
org.springframework.aop.IntroductionInterceptor
;
import
org.springframework.aop.support.ClassFilters
;
import
org.springframework.aop.support.DelegatePerTargetObjectIntroductionInterceptor
;
import
org.springframework.aop.support.DelegatingIntroductionInterceptor
;
...
...
@@ -34,12 +35,12 @@ import org.springframework.aop.support.DelegatingIntroductionInterceptor;
*/
public
class
DeclareParentsAdvisor
implements
IntroductionAdvisor
{
private
final
Advice
advice
;
private
final
Class
<?>
introducedInterface
;
private
final
ClassFilter
typePatternClassFilter
;
private
final
Advice
advice
;
/**
* Create a new advisor for this DeclareParents field.
...
...
@@ -48,7 +49,7 @@ public class DeclareParentsAdvisor implements IntroductionAdvisor {
* @param defaultImpl the default implementation class
*/
public
DeclareParentsAdvisor
(
Class
<?>
interfaceType
,
String
typePattern
,
Class
<?>
defaultImpl
)
{
this
(
interfaceType
,
typePattern
,
defaultImpl
,
this
(
interfaceType
,
typePattern
,
new
DelegatePerTargetObjectIntroductionInterceptor
(
defaultImpl
,
interfaceType
));
}
...
...
@@ -59,8 +60,7 @@ public class DeclareParentsAdvisor implements IntroductionAdvisor {
* @param delegateRef the delegate implementation object
*/
public
DeclareParentsAdvisor
(
Class
<?>
interfaceType
,
String
typePattern
,
Object
delegateRef
)
{
this
(
interfaceType
,
typePattern
,
delegateRef
.
getClass
(),
new
DelegatingIntroductionInterceptor
(
delegateRef
));
this
(
interfaceType
,
typePattern
,
new
DelegatingIntroductionInterceptor
(
delegateRef
));
}
/**
...
...
@@ -68,23 +68,21 @@ public class DeclareParentsAdvisor implements IntroductionAdvisor {
* (cannot use method such as init() to share common code, due the use of final fields)
* @param interfaceType static field defining the introduction
* @param typePattern type pattern the introduction is restricted to
* @param implementationClass implementation class
* @param advice delegation advice
* @param interceptor the delegation advice as {@link IntroductionInterceptor}
*/
private
DeclareParentsAdvisor
(
Class
<?>
interfaceType
,
String
typePattern
,
Class
<?>
implementationClass
,
Advice
advice
)
{
private
DeclareParentsAdvisor
(
Class
<?>
interfaceType
,
String
typePattern
,
IntroductionInterceptor
interceptor
)
{
this
.
advice
=
interceptor
;
this
.
introducedInterface
=
interfaceType
;
ClassFilter
typePatternFilter
=
new
TypePatternClassFilter
(
typePattern
);
// Excludes methods implemented.
ClassFilter
typePatternFilter
=
new
TypePatternClassFilter
(
typePattern
);
ClassFilter
exclusion
=
new
ClassFilter
()
{
@Override
public
boolean
matches
(
Class
<?>
clazz
)
{
return
!
(
introducedInterface
.
isAssignableFrom
(
clazz
)
)
;
return
!
introducedInterface
.
isAssignableFrom
(
clazz
);
}
};
this
.
typePatternClassFilter
=
ClassFilters
.
intersection
(
typePatternFilter
,
exclusion
);
this
.
advice
=
advice
;
}
...
...
spring-aop/src/main/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPoint.java
View file @
28270ba2
/*
* Copyright 2002-201
5
the original author or authors.
* Copyright 2002-201
8
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.
...
...
@@ -32,17 +32,15 @@ import org.springframework.core.ParameterNameDiscoverer;
import
org.springframework.util.Assert
;
/**
*
I
mplementation of AspectJ ProceedingJoinPoint interface
* wrapping an AOP Alliance MethodInvocation.
*
An i
mplementation of
the
AspectJ
{@link
ProceedingJoinPoint
}
interface
* wrapping an AOP Alliance
{@link org.aopalliance.intercept.
MethodInvocation
}
.
*
* <p><b>Note</b>:
t
he {@code getThis()} method returns the current Spring AOP proxy.
* <p><b>Note</b>:
T
he {@code getThis()} method returns the current Spring AOP proxy.
* The {@code getTarget()} method returns the current Spring AOP target (which may be
* {@code null} if there is no target), and is a plain POJO without any advice.
* <b>If you want to call the object and have the advice take effect, use
* {@code getThis()}.</b> A common example is casting the object to an
* introduced interface in the implementation of an introduction.
*
* <p>Of course there is no such distinction between target and proxy in AspectJ.
* {@code null} if there is no target instance) as a plain POJO without any advice.
* <b>If you want to call the object and have the advice take effect, use {@code getThis()}.</b>
* A common example is casting the object to an introduced interface in the implementation of
* an introduction. There is no such distinction between target and proxy in AspectJ itself.
*
* @author Rod Johnson
* @author Juergen Hoeller
...
...
@@ -56,7 +54,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
private
final
ProxyMethodInvocation
methodInvocation
;
private
Object
[]
defensiveCopyOfA
rgs
;
private
Object
[]
a
rgs
;
/** Lazily initialized signature object */
private
Signature
signature
;
...
...
@@ -75,6 +73,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
this
.
methodInvocation
=
methodInvocation
;
}
@Override
public
void
set$AroundClosure
(
AroundClosure
aroundClosure
)
{
throw
new
UnsupportedOperationException
();
...
...
@@ -115,12 +114,10 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
@Override
public
Object
[]
getArgs
()
{
if
(
this
.
defensiveCopyOfArgs
==
null
)
{
Object
[]
argsSource
=
this
.
methodInvocation
.
getArguments
();
this
.
defensiveCopyOfArgs
=
new
Object
[
argsSource
.
length
];
System
.
arraycopy
(
argsSource
,
0
,
this
.
defensiveCopyOfArgs
,
0
,
argsSource
.
length
);
if
(
this
.
args
==
null
)
{
this
.
args
=
this
.
methodInvocation
.
getArguments
().
clone
();
}
return
this
.
defensiveCopyOfA
rgs
;
return
this
.
a
rgs
;
}
@Override
...
...
@@ -128,7 +125,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
if
(
this
.
signature
==
null
)
{
this
.
signature
=
new
MethodSignatureImpl
();
}
return
signature
;
return
this
.
signature
;
}
@Override
...
...
spring-aop/src/main/java/org/springframework/aop/aspectj/SimpleAspectInstanceFactory.java
View file @
28270ba2
/*
* Copyright 2002-201
6
the original author or authors.
* Copyright 2002-201
8
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.
...
...
@@ -41,6 +41,7 @@ public class SimpleAspectInstanceFactory implements AspectInstanceFactory {
this
.
aspectClass
=
aspectClass
;
}
/**
* Return the specified aspect class (never {@code null}).
*/
...
...
@@ -48,7 +49,6 @@ public class SimpleAspectInstanceFactory implements AspectInstanceFactory {
return
this
.
aspectClass
;
}
@Override
public
final
Object
getAspectInstance
()
{
try
{
...
...
spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java
View file @
28270ba2
/*
* Copyright 2002-201
6
the original author or authors.
* Copyright 2002-201
8
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.
...
...
@@ -59,6 +59,9 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
private
static
final
String
AJC_MAGIC
=
"ajc$"
;
private
static
final
Class
<?>[]
ASPECTJ_ANNOTATION_CLASSES
=
new
Class
<?>[]
{
Pointcut
.
class
,
Around
.
class
,
Before
.
class
,
After
.
class
,
AfterReturning
.
class
,
AfterThrowing
.
class
};
/** Logger available to subclasses */
protected
final
Log
logger
=
LogFactory
.
getLog
(
getClass
());
...
...
@@ -122,14 +125,12 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
/**
* Find and return the first AspectJ annotation on the given method
* (there <i>should</i> only be one anyway...)
* (there <i>should</i> only be one anyway...)
.
*/
@SuppressWarnings
(
"unchecked"
)
protected
static
AspectJAnnotation
<?>
findAspectJAnnotationOnMethod
(
Method
method
)
{
Class
<?>[]
classesToLookFor
=
new
Class
<?>[]
{
Before
.
class
,
Around
.
class
,
After
.
class
,
AfterReturning
.
class
,
AfterThrowing
.
class
,
Pointcut
.
class
};
for
(
Class
<?>
c
:
classesToLookFor
)
{
AspectJAnnotation
<?>
foundAnnotation
=
findAnnotation
(
method
,
(
Class
<
Annotation
>)
c
);
for
(
Class
<?>
clazz
:
ASPECTJ_ANNOTATION_CLASSES
)
{
AspectJAnnotation
<?>
foundAnnotation
=
findAnnotation
(
method
,
(
Class
<
Annotation
>)
clazz
);
if
(
foundAnnotation
!=
null
)
{
return
foundAnnotation
;
}
...
...
@@ -148,14 +149,13 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
}
/**
* Enum for AspectJ annotation types.
* @see AspectJAnnotation#getAnnotationType()
*/
protected
enum
AspectJAnnotationType
{
AtPointcut
,
AtBefore
,
AtAfter
,
AtAfterReturning
,
AtAfterThrowing
,
AtAround
AtPointcut
,
AtAround
,
AtBefore
,
AtAfter
,
AtAfterReturning
,
AtAfterThrowing
}
...
...
@@ -165,18 +165,18 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
*/
protected
static
class
AspectJAnnotation
<
A
extends
Annotation
>
{
private
static
final
String
[]
EXPRESSION_
PROPERTI
ES
=
new
String
[]
{
"
value"
,
"pointcut
"
};
private
static
final
String
[]
EXPRESSION_
ATTRIBUT
ES
=
new
String
[]
{
"
pointcut"
,
"value
"
};
private
static
Map
<
Class
<?>,
AspectJAnnotationType
>
annotationType
s
=
new
HashMap
<
Class
<?>,
AspectJAnnotationType
>();
private
static
Map
<
Class
<?>,
AspectJAnnotationType
>
annotationType
Map
=
new
HashMap
<
Class
<?>,
AspectJAnnotationType
>(
8
);
static
{
annotationType
s
.
put
(
Pointcut
.
class
,
AspectJAnnotationType
.
AtPointcut
);
annotationType
s
.
put
(
A
fter
.
class
,
AspectJAnnotationType
.
AtA
fter
);
annotationType
s
.
put
(
AfterReturning
.
class
,
AspectJAnnotationType
.
At
AfterReturning
);
annotationType
s
.
put
(
After
Throwing
.
class
,
AspectJAnnotationType
.
AtAfter
Throwing
);
annotationType
s
.
put
(
A
round
.
class
,
AspectJAnnotationType
.
AtA
round
);
annotationType
s
.
put
(
Before
.
class
,
AspectJAnnotationType
.
At
Before
);
annotationType
Map
.
put
(
Pointcut
.
class
,
AspectJAnnotationType
.
AtPointcut
);
annotationType
Map
.
put
(
A
round
.
class
,
AspectJAnnotationType
.
AtA
round
);
annotationType
Map
.
put
(
Before
.
class
,
AspectJAnnotationType
.
At
Before
);
annotationType
Map
.
put
(
After
.
class
,
AspectJAnnotationType
.
AtAfter
);
annotationType
Map
.
put
(
A
fterReturning
.
class
,
AspectJAnnotationType
.
AtA
fterReturning
);
annotationType
Map
.
put
(
AfterThrowing
.
class
,
AspectJAnnotationType
.
At
AfterThrowing
);
}
private
final
A
annotation
;
...
...
@@ -190,44 +190,31 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
public
AspectJAnnotation
(
A
annotation
)
{
this
.
annotation
=
annotation
;
this
.
annotationType
=
determineAnnotationType
(
annotation
);
// We know these methods exist with the same name on each object,
// but need to invoke them reflectively as there isn't a common interface.
try
{
this
.
pointcutExpression
=
resolveExpression
(
annotation
);
this
.
argumentNames
=
(
String
)
a
nnotation
.
getClass
().
getMethod
(
"argNames"
).
invoke
(
annotation
);
this
.
argumentNames
=
(
String
)
A
nnotation
Utils
.
getValue
(
annotation
,
"argNames"
);
}
catch
(
Exception
ex
)
{
throw
new
IllegalArgumentException
(
annotation
+
"
can
not
be an
AspectJ annotation"
,
ex
);
throw
new
IllegalArgumentException
(
annotation
+
"
is
not
a valid
AspectJ annotation"
,
ex
);
}
}
private
AspectJAnnotationType
determineAnnotationType
(
A
annotation
)
{
for
(
Class
<?>
type
:
annotationTypes
.
keySet
())
{
if
(
type
.
isInstance
(
annotation
))
{
return
annotationTypes
.
get
(
type
);
}
AspectJAnnotationType
type
=
annotationTypeMap
.
get
(
annotation
.
annotationType
());
if
(
type
!=
null
)
{
return
type
;
}
throw
new
IllegalStateException
(
"Unknown annotation type: "
+
annotation
.
toString
()
);
throw
new
IllegalStateException
(
"Unknown annotation type: "
+
annotation
);
}
private
String
resolveExpression
(
A
annotation
)
throws
Exception
{
String
expression
=
null
;
for
(
String
methodName
:
EXPRESSION_PROPERTIES
)
{
Method
method
;
try
{
method
=
annotation
.
getClass
().
getDeclaredMethod
(
methodName
);
}
catch
(
NoSuchMethodException
ex
)
{
method
=
null
;
}
if
(
method
!=
null
)
{
String
candidate
=
(
String
)
method
.
invoke
(
annotation
);
private
String
resolveExpression
(
A
annotation
)
{
for
(
String
attributeName
:
EXPRESSION_ATTRIBUTES
)
{
String
candidate
=
(
String
)
AnnotationUtils
.
getValue
(
annotation
,
attributeName
);
if
(
StringUtils
.
hasText
(
candidate
))
{
expression
=
candidate
;
}
return
candidate
;
}
}
return
expression
;
throw
new
IllegalStateException
(
"Failed to resolve expression: "
+
annotation
)
;
}
public
AspectJAnnotationType
getAnnotationType
()
{
...
...
@@ -268,11 +255,11 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
if
(
annotation
==
null
)
{
return
null
;
}
StringTokenizer
strTok
=
new
StringTokenizer
(
annotation
.
getArgumentNames
(),
","
);
if
(
strTok
.
countTokens
()
>
0
)
{
String
[]
names
=
new
String
[
strTok
.
countTokens
()];
StringTokenizer
nameTokens
=
new
StringTokenizer
(
annotation
.
getArgumentNames
(),
","
);
if
(
nameTokens
.
countTokens
()
>
0
)
{
String
[]
names
=
new
String
[
nameTokens
.
countTokens
()];
for
(
int
i
=
0
;
i
<
names
.
length
;
i
++)
{
names
[
i
]
=
strTok
.
nextToken
();
names
[
i
]
=
nameTokens
.
nextToken
();
}
return
names
;
}
...
...
spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectJProxyFactory.java
View file @
28270ba2
/*
* Copyright 2002-201
6
the original author or authors.
* Copyright 2002-201
8
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.
...
...
@@ -168,19 +168,19 @@ public class AspectJProxyFactory extends ProxyCreatorSupport {
synchronized
(
aspectCache
)
{
// To be safe, check within full lock now...
instance
=
aspectCache
.
get
(
aspectClass
);
if
(
instance
!=
null
)
{
return
instance
;
}
if
(
instance
==
null
)
{
try
{
instance
=
aspectClass
.
newInstance
();
aspectCache
.
put
(
aspectClass
,
instance
);
return
instance
;
}
catch
(
InstantiationException
ex
)
{
throw
new
AopConfigException
(
"Unable to instantiate aspect class ["
+
aspectClass
.
getName
()
+
"]"
,
ex
);
throw
new
AopConfigException
(
"Unable to instantiate aspect class: "
+
aspectClass
.
getName
(),
ex
);
}
catch
(
IllegalAccessException
ex
)
{
throw
new
AopConfigException
(
"Cannot access aspect class ["
+
aspectClass
.
getName
()
+
"]"
,
ex
);
throw
new
AopConfigException
(
"Could not access aspect constructor: "
+
aspectClass
.
getName
(),
ex
);
}
}
}
}
...
...
spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectMetadata.java
View file @
28270ba2
...
...
@@ -127,7 +127,7 @@ public class AspectMetadata implements Serializable {
*/
private
String
findPerClause
(
Class
<?>
aspectClass
)
{
String
str
=
aspectClass
.
getAnnotation
(
Aspect
.
class
).
value
();
str
=
str
.
substring
(
str
.
indexOf
(
"("
)
+
1
);
str
=
str
.
substring
(
str
.
indexOf
(
'('
)
+
1
);
str
=
str
.
substring
(
0
,
str
.
length
()
-
1
);
return
str
;
}
...
...
spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/InstantiationModelAwarePointcutAdvisorImpl.java
View file @
28270ba2
/*
* Copyright 2002-201
5
the original author or authors.
* Copyright 2002-201
8
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.
...
...
@@ -109,29 +109,22 @@ class InstantiationModelAwarePointcutAdvisorImpl
/**
* The pointcut for Spring AOP to use.
Actual behaviour of the pointcut will change
* depending on the state of the advice.
* The pointcut for Spring AOP to use.
*
Actual behaviour of the pointcut will change
depending on the state of the advice.
*/
@Override
public
Pointcut
getPointcut
()
{
return
this
.
pointcut
;
}
/**
* This is only of interest for Spring AOP: AspectJ instantiation semantics
* are much richer. In AspectJ terminology, all a return of {@code true}
* means here is that the aspect is not a SINGLETON.
*/
@Override
public
boolean
is
PerInstance
()
{
return
(
getAspectMetadata
().
getAjType
().
getPerClause
().
getKind
()
!=
PerClauseKind
.
SINGLETON
)
;
public
boolean
is
Lazy
()
{
return
this
.
lazy
;
}
/**
* Return the AspectJ AspectMetadata for this advisor.
*/
public
AspectMetadata
getAspectMetadata
()
{
return
this
.
aspectInstanceFactory
.
getAspectMetadata
();
@Override
public
synchronized
boolean
isAdviceInstantiated
()
{
return
(
this
.
instantiatedAdvice
!=
null
);
}
/**
...
...
@@ -145,20 +138,26 @@ class InstantiationModelAwarePointcutAdvisorImpl
return
this
.
instantiatedAdvice
;
}
@Override
public
boolean
isLazy
()
{
return
this
.
lazy
;
private
Advice
instantiateAdvice
(
AspectJExpressionPointcut
pcut
)
{
return
this
.
aspectJAdvisorFactory
.
getAdvice
(
this
.
aspectJAdviceMethod
,
pcut
,
this
.
aspectInstanceFactory
,
this
.
declarationOrder
,
this
.
aspectName
)
;
}
/**
* This is only of interest for Spring AOP: AspectJ instantiation semantics
* are much richer. In AspectJ terminology, all a return of {@code true}
* means here is that the aspect is not a SINGLETON.
*/
@Override
public
synchronized
boolean
isAdviceInstantiated
()
{
return
(
this
.
instantiatedAdvice
!=
null
);
public
boolean
isPerInstance
()
{
return
(
getAspectMetadata
().
getAjType
().
getPerClause
().
getKind
()
!=
PerClauseKind
.
SINGLETON
);
}
private
Advice
instantiateAdvice
(
AspectJExpressionPointcut
pcut
)
{
return
this
.
aspectJAdvisorFactory
.
getAdvice
(
this
.
aspectJAdviceMethod
,
pcut
,
this
.
aspectInstanceFactory
,
this
.
declarationOrder
,
this
.
aspectName
);
/**
* Return the AspectJ AspectMetadata for this advisor.
*/
public
AspectMetadata
getAspectMetadata
()
{
return
this
.
aspectInstanceFactory
.
getAspectMetadata
();
}
public
MetadataAwareAspectInstanceFactory
getAspectInstanceFactory
()
{
...
...
@@ -213,33 +212,26 @@ class InstantiationModelAwarePointcutAdvisorImpl
}
else
{
switch
(
aspectJAnnotation
.
getAnnotationType
())
{
case
AtAfter:
case
AtAfterReturning:
case
AtAfterThrowing:
this
.
isAfterAdvice
=
true
;
this
.
isBeforeAdvice
=
false
;
break
;
case
AtAround:
case
AtPointcut:
this
.
isAfterAdvice
=
false
;
case
AtAround:
this
.
isBeforeAdvice
=
false
;
this
.
isAfterAdvice
=
false
;
break
;
case
AtBefore:
this
.
isAfterAdvice
=
false
;
this
.
isBeforeAdvice
=
true
;
this
.
isAfterAdvice
=
false
;
break
;
case
AtAfter:
case
AtAfterReturning:
case
AtAfterThrowing:
this
.
isBeforeAdvice
=
false
;
this
.
isAfterAdvice
=
true
;
break
;
}
}
}
@Override
public
String
toString
()
{
return
"InstantiationModelAwarePointcutAdvisor: expression ["
+
getDeclaredPointcut
().
getExpression
()
+
"]; advice method ["
+
this
.
aspectJAdviceMethod
+
"]; perClauseKind="
+
this
.
aspectInstanceFactory
.
getAspectMetadata
().
getAjType
().
getPerClause
().
getKind
();
}
private
void
readObject
(
ObjectInputStream
inputStream
)
throws
IOException
,
ClassNotFoundException
{
inputStream
.
defaultReadObject
();
try
{
...
...
@@ -250,11 +242,18 @@ class InstantiationModelAwarePointcutAdvisorImpl
}
}
@Override
public
String
toString
()
{
return
"InstantiationModelAwarePointcutAdvisor: expression ["
+
getDeclaredPointcut
().
getExpression
()
+
"]; advice method ["
+
this
.
aspectJAdviceMethod
+
"]; perClauseKind="
+
this
.
aspectInstanceFactory
.
getAspectMetadata
().
getAjType
().
getPerClause
().
getKind
();
}
/**
* Pointcut implementation that changes its behaviour when the advice is instantiated.
* Note that this is a <i>dynamic</i> pointcut
. O
therwise it might
*
be optimized out
if it does not at first match statically.
* Note that this is a <i>dynamic</i> pointcut
; o
therwise it might
be optimized out
* if it does not at first match statically.
*/
private
class
PerTargetInstantiationModelPointcut
extends
DynamicMethodMatcherPointcut
{
...
...
@@ -264,8 +263,9 @@ class InstantiationModelAwarePointcutAdvisorImpl
private
LazySingletonAspectInstanceFactoryDecorator
aspectInstanceFactory
;
p
rivate
PerTargetInstantiationModelPointcut
(
AspectJExpressionPointcut
declaredPointcut
,
p
ublic
PerTargetInstantiationModelPointcut
(
AspectJExpressionPointcut
declaredPointcut
,
Pointcut
preInstantiationPointcut
,
MetadataAwareAspectInstanceFactory
aspectInstanceFactory
)
{
this
.
declaredPointcut
=
declaredPointcut
;
this
.
preInstantiationPointcut
=
preInstantiationPointcut
;
if
(
aspectInstanceFactory
instanceof
LazySingletonAspectInstanceFactoryDecorator
)
{
...
...
@@ -275,7 +275,8 @@ class InstantiationModelAwarePointcutAdvisorImpl
@Override
public
boolean
matches
(
Method
method
,
Class
<?>
targetClass
)
{
// We're either instantiated and matching on declared pointcut, or uninstantiated matching on either pointcut
// We're either instantiated and matching on declared pointcut,
// or uninstantiated matching on either pointcut...
return
(
isAspectMaterialized
()
&&
this
.
declaredPointcut
.
matches
(
method
,
targetClass
))
||
this
.
preInstantiationPointcut
.
getMethodMatcher
().
matches
(
method
,
targetClass
);
}
...
...
spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactory.java
View file @
28270ba2
/*
* Copyright 2002-201
6
the original author or authors.
* Copyright 2002-201
8
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.
...
...
@@ -20,9 +20,9 @@ import java.io.Serializable;
import
java.lang.annotation.Annotation
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Method
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.LinkedList
;
import
java.util.List
;
import
org.aopalliance.aop.Advice
;
...
...
@@ -131,7 +131,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
MetadataAwareAspectInstanceFactory
lazySingletonAspectInstanceFactory
=
new
LazySingletonAspectInstanceFactoryDecorator
(
aspectInstanceFactory
);
List
<
Advisor
>
advisors
=
new
Linked
List
<
Advisor
>();
List
<
Advisor
>
advisors
=
new
Array
List
<
Advisor
>();
for
(
Method
method
:
getAdvisorMethods
(
aspectClass
))
{
Advisor
advisor
=
getAdvisor
(
method
,
lazySingletonAspectInstanceFactory
,
advisors
.
size
(),
aspectName
);
if
(
advisor
!=
null
)
{
...
...
@@ -157,7 +157,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
}
private
List
<
Method
>
getAdvisorMethods
(
Class
<?>
aspectClass
)
{
final
List
<
Method
>
methods
=
new
Linked
List
<
Method
>();
final
List
<
Method
>
methods
=
new
Array
List
<
Method
>();
ReflectionUtils
.
doWithMethods
(
aspectClass
,
new
ReflectionUtils
.
MethodCallback
()
{
@Override
public
void
doWith
(
Method
method
)
throws
IllegalArgumentException
{
...
...
@@ -176,7 +176,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
* for the given introduction field.
* <p>Resulting Advisors will need to be evaluated for targets.
* @param introductionField the field to introspect
* @return {@code null} if not an Advisor
* @return
the Advisor instance, or
{@code null} if not an Advisor
*/
private
Advisor
getDeclareParentsAdvisor
(
Field
introductionField
)
{
DeclareParents
declareParents
=
introductionField
.
getAnnotation
(
DeclareParents
.
class
);
...
...
@@ -253,6 +253,15 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
AbstractAspectJAdvice
springAdvice
;
switch
(
aspectJAnnotation
.
getAnnotationType
())
{
case
AtPointcut:
if
(
logger
.
isDebugEnabled
())
{
logger
.
debug
(
"Processing pointcut '"
+
candidateAdviceMethod
.
getName
()
+
"'"
);
}
return
null
;
case
AtAround:
springAdvice
=
new
AspectJAroundAdvice
(
candidateAdviceMethod
,
expressionPointcut
,
aspectInstanceFactory
);
break
;
case
AtBefore:
springAdvice
=
new
AspectJMethodBeforeAdvice
(
candidateAdviceMethod
,
expressionPointcut
,
aspectInstanceFactory
);
...
...
@@ -277,15 +286,6 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
springAdvice
.
setThrowingName
(
afterThrowingAnnotation
.
throwing
());
}
break
;
case
AtAround:
springAdvice
=
new
AspectJAroundAdvice
(
candidateAdviceMethod
,
expressionPointcut
,
aspectInstanceFactory
);
break
;
case
AtPointcut:
if
(
logger
.
isDebugEnabled
())
{
logger
.
debug
(
"Processing pointcut '"
+
candidateAdviceMethod
.
getName
()
+
"'"
);
}
return
null
;
default
:
throw
new
UnsupportedOperationException
(
"Unsupported advice type on method: "
+
candidateAdviceMethod
);
...
...
@@ -299,6 +299,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
springAdvice
.
setArgumentNamesFromStringArray
(
argNames
);
}
springAdvice
.
calculateArgumentBindings
();
return
springAdvice
;
}
...
...
spring-aop/src/main/java/org/springframework/aop/config/AopConfigUtils.java
View file @
28270ba2
/*
* Copyright 2002-201
6
the original author or authors.
* Copyright 2002-201
8
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.
...
...
@@ -31,11 +31,10 @@ import org.springframework.util.Assert;
/**
* Utility class for handling registration of AOP auto-proxy creators.
*
* <p>Only a single auto-proxy creator can be registered yet multiple concrete
* implementations are available. Therefore this class wraps a simple escalation
* protocol, allowing classes to request a particular auto-proxy creator and know
* that class, {@code or a subclass thereof}, will eventually be resident
* in the application context.
* <p>Only a single auto-proxy creator should be registered yet multiple concrete
* implementations are available. This class provides a simple escalation protocol,
* allowing a caller to request a particular auto-proxy creator and know that creator,
* <i>or a more capable variant thereof</i>, will be registered as a post-processor.
*
* @author Rob Harrop
* @author Juergen Hoeller
...
...
@@ -54,12 +53,10 @@ public abstract class AopConfigUtils {
/**
* Stores the auto proxy creator classes in escalation order.
*/
private
static
final
List
<
Class
<?>>
APC_PRIORITY_LIST
=
new
ArrayList
<
Class
<?>>();
private
static
final
List
<
Class
<?>>
APC_PRIORITY_LIST
=
new
ArrayList
<
Class
<?>>(
3
);
/**
* Setup the escalation list.
*/
static
{
// Set up the escalation list...
APC_PRIORITY_LIST
.
add
(
InfrastructureAdvisorAutoProxyCreator
.
class
);
APC_PRIORITY_LIST
.
add
(
AspectJAwareAdvisorAutoProxyCreator
.
class
);
APC_PRIORITY_LIST
.
add
(
AnnotationAwareAspectJAutoProxyCreator
.
class
);
...
...
@@ -107,6 +104,7 @@ public abstract class AopConfigUtils {
private
static
BeanDefinition
registerOrEscalateApcAsRequired
(
Class
<?>
cls
,
BeanDefinitionRegistry
registry
,
Object
source
)
{
Assert
.
notNull
(
registry
,
"BeanDefinitionRegistry must not be null"
);
if
(
registry
.
containsBeanDefinition
(
AUTO_PROXY_CREATOR_BEAN_NAME
))
{
BeanDefinition
apcDefinition
=
registry
.
getBeanDefinition
(
AUTO_PROXY_CREATOR_BEAN_NAME
);
if
(!
cls
.
getName
().
equals
(
apcDefinition
.
getBeanClassName
()))
{
...
...
@@ -118,6 +116,7 @@ public abstract class AopConfigUtils {
}
return
null
;
}
RootBeanDefinition
beanDefinition
=
new
RootBeanDefinition
(
cls
);
beanDefinition
.
setSource
(
source
);
beanDefinition
.
getPropertyValues
().
add
(
"order"
,
Ordered
.
HIGHEST_PRECEDENCE
);
...
...
spring-aop/src/main/java/org/springframework/aop/config/AopNamespaceUtils.java
View file @
28270ba2
/*
* Copyright 2002-201
3
the original author or authors.
* Copyright 2002-201
8
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.
...
...
@@ -27,11 +27,11 @@ import org.springframework.beans.factory.xml.ParserContext;
* Utility class for handling registration of auto-proxy creators used internally
* by the '{@code aop}' namespace tags.
*
* <p>Only a single auto-proxy creator
can
be registered and multiple
tags may wish
* to register different concrete implementations. As such this class
delegates to
* {@link AopConfigUtils} which
wrap
s a simple escalation protocol.
Therefore classes
* may request a particular auto-proxy creator and know that c
lass, <i>or a subclass
*
thereof</i>, will eventually be resident in the application context
.
* <p>Only a single auto-proxy creator
should
be registered and multiple
configuration
*
elements may wish
to register different concrete implementations. As such this class
*
delegates to
{@link AopConfigUtils} which
provide
s a simple escalation protocol.
*
Callers
may request a particular auto-proxy creator and know that c
reator,
*
<i>or a more capable variant thereof</i>, will be registered as a post-processor
.
*
* @author Rob Harrop
* @author Juergen Hoeller
...
...
@@ -81,11 +81,11 @@ public abstract class AopNamespaceUtils {
private
static
void
useClassProxyingIfNecessary
(
BeanDefinitionRegistry
registry
,
Element
sourceElement
)
{
if
(
sourceElement
!=
null
)
{
boolean
proxyTargetClass
=
Boolean
.
valueOf
(
sourceElement
.
getAttribute
(
PROXY_TARGET_CLASS_ATTRIBUTE
));
boolean
proxyTargetClass
=
Boolean
.
parseBoolean
(
sourceElement
.
getAttribute
(
PROXY_TARGET_CLASS_ATTRIBUTE
));
if
(
proxyTargetClass
)
{
AopConfigUtils
.
forceAutoProxyCreatorToUseClassProxying
(
registry
);
}
boolean
exposeProxy
=
Boolean
.
valueOf
(
sourceElement
.
getAttribute
(
EXPOSE_PROXY_ATTRIBUTE
));
boolean
exposeProxy
=
Boolean
.
parseBoolean
(
sourceElement
.
getAttribute
(
EXPOSE_PROXY_ATTRIBUTE
));
if
(
exposeProxy
)
{
AopConfigUtils
.
forceAutoProxyCreatorToExposeProxy
(
registry
);
}
...
...
@@ -94,9 +94,8 @@ public abstract class AopNamespaceUtils {
private
static
void
registerComponentIfNecessary
(
BeanDefinition
beanDefinition
,
ParserContext
parserContext
)
{
if
(
beanDefinition
!=
null
)
{
BeanComponentDefinition
componentDefinition
=
new
BeanComponentDefinition
(
beanDefinition
,
AopConfigUtils
.
AUTO_PROXY_CREATOR_BEAN_NAME
);
parserContext
.
registerComponent
(
componentDefinition
);
parserContext
.
registerComponent
(
new
BeanComponentDefinition
(
beanDefinition
,
AopConfigUtils
.
AUTO_PROXY_CREATOR_BEAN_NAME
));
}
}
...
...
spring-aop/src/main/java/org/springframework/aop/framework/AbstractAdvisingBeanPostProcessor.java
View file @
28270ba2
/*
* Copyright 2002-201
5
the original author or authors.
* Copyright 2002-201
8
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.
...
...
@@ -90,7 +90,7 @@ public abstract class AbstractAdvisingBeanPostProcessor extends ProxyProcessorSu
return
proxyFactory
.
getProxy
(
getProxyClassLoader
());
}
// No
async
proxy needed.
// No proxy needed.
return
bean
;
}
...
...
@@ -155,7 +155,7 @@ public abstract class AbstractAdvisingBeanPostProcessor extends ProxyProcessorSu
* Subclasses may choose to implement this: for example,
* to change the interfaces exposed.
* <p>The default implementation is empty.
* @param proxyFactory ProxyFactory that is already configured with
* @param proxyFactory
the
ProxyFactory that is already configured with
* target, advisor and interfaces and will be used to create the proxy
* immediately after this method returns
* @since 4.2.3
...
...
spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java
View file @
28270ba2
/*
* Copyright 2002-201
6
the original author or authors.
* Copyright 2002-201
8
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.
...
...
@@ -22,7 +22,6 @@ import java.lang.reflect.Method;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
...
...
@@ -93,7 +92,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
* List of Advisors. If an Advice is added, it will be wrapped
* in an Advisor before being added to this List.
*/
private
List
<
Advisor
>
advisors
=
new
Linked
List
<
Advisor
>();
private
List
<
Advisor
>
advisors
=
new
Array
List
<
Advisor
>();
/**
* Array updated on changes to the advisors list, which is easier
...
...
@@ -234,7 +233,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
@Override
public
Class
<?>[]
getProxiedInterfaces
()
{
return
this
.
interfaces
.
toArray
(
new
Class
<?>[
this
.
interfaces
.
size
()]
);
return
ClassUtils
.
toClassArray
(
this
.
interfaces
);
}
@Override
...
...
@@ -480,7 +479,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
* for the given method, based on this configuration.
* @param method the proxied method
* @param targetClass the target class
* @return List of MethodInterceptors (may also include InterceptorAndDynamicMethodMatchers)
* @return
a
List of MethodInterceptors (may also include InterceptorAndDynamicMethodMatchers)
*/
public
List
<
Object
>
getInterceptorsAndDynamicInterceptionAdvice
(
Method
method
,
Class
<?>
targetClass
)
{
MethodCacheKey
cacheKey
=
new
MethodCacheKey
(
method
);
...
...
@@ -534,7 +533,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
/**
* Build a configuration-only copy of this AdvisedSupport,
* replacing the TargetSource
* replacing the TargetSource
.
*/
AdvisedSupport
getConfigurationOnlyCopy
()
{
AdvisedSupport
copy
=
new
AdvisedSupport
();
...
...
spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java
View file @
28270ba2
/*
* Copyright 2002-201
7
the original author or authors.
* Copyright 2002-201
8
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.
...
...
@@ -201,15 +201,13 @@ class CglibAopProxy implements AopProxy, Serializable {
return
createProxyClassAndInstance
(
enhancer
,
callbacks
);
}
catch
(
CodeGenerationException
ex
)
{
throw
new
AopConfigException
(
"Could not generate CGLIB subclass of class ["
+
this
.
advised
.
getTargetClass
()
+
"]: "
+
"Common causes of this problem include using a final class or a non-visible class"
,
throw
new
AopConfigException
(
"Could not generate CGLIB subclass of "
+
this
.
advised
.
getTargetClass
()
+
": Common causes of this problem include using a final class or a non-visible class"
,
ex
);
}
catch
(
IllegalArgumentException
ex
)
{
throw
new
AopConfigException
(
"Could not generate CGLIB subclass of class ["
+
this
.
advised
.
getTargetClass
()
+
"]: "
+
"Common causes of this problem include using a final class or a non-visible class"
,
throw
new
AopConfigException
(
"Could not generate CGLIB subclass of "
+
this
.
advised
.
getTargetClass
()
+
": Common causes of this problem include using a final class or a non-visible class"
,
ex
);
}
catch
(
Throwable
ex
)
{
...
...
@@ -259,7 +257,7 @@ class CglibAopProxy implements AopProxy, Serializable {
Method
[]
methods
=
proxySuperClass
.
getDeclaredMethods
();
for
(
Method
method
:
methods
)
{
int
mod
=
method
.
getModifiers
();
if
(!
Modifier
.
isStatic
(
mod
))
{
if
(!
Modifier
.
isStatic
(
mod
)
&&
!
Modifier
.
isPrivate
(
mod
)
)
{
if
(
Modifier
.
isFinal
(
mod
))
{
if
(
implementsInterface
(
method
,
ifcs
))
{
logger
.
warn
(
"Unable to proxy interface-implementing method ["
+
method
+
"] because "
+
...
...
@@ -269,7 +267,7 @@ class CglibAopProxy implements AopProxy, Serializable {
"Calls to this method will NOT be routed to the target instance and "
+
"might lead to NPEs against uninitialized fields in the proxy instance."
);
}
else
if
(!
Modifier
.
isPublic
(
mod
)
&&
!
Modifier
.
isProtected
(
mod
)
&&
!
Modifier
.
isPrivate
(
mod
)
&&
else
if
(!
Modifier
.
isPublic
(
mod
)
&&
!
Modifier
.
isProtected
(
mod
)
&&
proxyClassLoader
!=
null
&&
proxySuperClass
.
getClassLoader
()
!=
proxyClassLoader
)
{
logger
.
info
(
"Method ["
+
method
+
"] is package-visible across different ClassLoaders "
+
"and cannot get proxied via CGLIB: Declare this method as public or protected "
+
...
...
@@ -294,20 +292,20 @@ class CglibAopProxy implements AopProxy, Serializable {
// unadvised but can return this). May be required to expose the proxy.
Callback
targetInterceptor
;
if
(
exposeProxy
)
{
targetInterceptor
=
isStatic
?
targetInterceptor
=
(
isStatic
?
new
StaticUnadvisedExposedInterceptor
(
this
.
advised
.
getTargetSource
().
getTarget
())
:
new
DynamicUnadvisedExposedInterceptor
(
this
.
advised
.
getTargetSource
());
new
DynamicUnadvisedExposedInterceptor
(
this
.
advised
.
getTargetSource
())
)
;
}
else
{
targetInterceptor
=
isStatic
?
targetInterceptor
=
(
isStatic
?
new
StaticUnadvisedInterceptor
(
this
.
advised
.
getTargetSource
().
getTarget
())
:
new
DynamicUnadvisedInterceptor
(
this
.
advised
.
getTargetSource
());
new
DynamicUnadvisedInterceptor
(
this
.
advised
.
getTargetSource
())
)
;
}
// Choose a "direct to target" dispatcher (used for
// unadvised calls to static targets that cannot return this).
Callback
targetDispatcher
=
isStatic
?
new
StaticDispatcher
(
this
.
advised
.
getTargetSource
().
getTarget
())
:
new
SerializableNoOp
();
Callback
targetDispatcher
=
(
isStatic
?
new
StaticDispatcher
(
this
.
advised
.
getTargetSource
().
getTarget
())
:
new
SerializableNoOp
()
)
;
Callback
[]
mainCallbacks
=
new
Callback
[]
{
aopInterceptor
,
// for normal advice
...
...
@@ -812,12 +810,16 @@ class CglibAopProxy implements AopProxy, Serializable {
}
// We must always proxy equals, to direct calls to this.
if
(
AopUtils
.
isEqualsMethod
(
method
))
{
if
(
logger
.
isDebugEnabled
())
{
logger
.
debug
(
"Found 'equals' method: "
+
method
);
}
return
INVOKE_EQUALS
;
}
// We must always calculate hashCode based on the proxy.
if
(
AopUtils
.
isHashCodeMethod
(
method
))
{
if
(
logger
.
isDebugEnabled
())
{
logger
.
debug
(
"Found 'hashCode' method: "
+
method
);
}
return
INVOKE_HASHCODE
;
}
Class
<?>
targetClass
=
this
.
advised
.
getTargetClass
();
...
...
spring-aop/src/main/java/org/springframework/aop/framework/DefaultAdvisorChainFactory.java
View file @
28270ba2
/*
* Copyright 2002-201
4
the original author or authors.
* Copyright 2002-201
8
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.
...
...
@@ -62,9 +62,9 @@ public class DefaultAdvisorChainFactory implements AdvisorChainFactory, Serializ
// Add it conditionally.
PointcutAdvisor
pointcutAdvisor
=
(
PointcutAdvisor
)
advisor
;
if
(
config
.
isPreFiltered
()
||
pointcutAdvisor
.
getPointcut
().
getClassFilter
().
matches
(
actualClass
))
{
MethodInterceptor
[]
interceptors
=
registry
.
getInterceptors
(
advisor
);
MethodMatcher
mm
=
pointcutAdvisor
.
getPointcut
().
getMethodMatcher
();
if
(
MethodMatchers
.
matches
(
mm
,
method
,
actualClass
,
hasIntroductions
))
{
MethodInterceptor
[]
interceptors
=
registry
.
getInterceptors
(
advisor
);
if
(
mm
.
isRuntime
())
{
// Creating a new object instance in the getInterceptors() method
// isn't a problem as we normally cache created chains.
...
...
@@ -98,8 +98,7 @@ public class DefaultAdvisorChainFactory implements AdvisorChainFactory, Serializ
* Determine whether the Advisors contain matching introductions.
*/
private
static
boolean
hasMatchingIntroductions
(
Advised
config
,
Class
<?>
actualClass
)
{
for
(
int
i
=
0
;
i
<
config
.
getAdvisors
().
length
;
i
++)
{
Advisor
advisor
=
config
.
getAdvisors
()[
i
];
for
(
Advisor
advisor
:
config
.
getAdvisors
())
{
if
(
advisor
instanceof
IntroductionAdvisor
)
{
IntroductionAdvisor
ia
=
(
IntroductionAdvisor
)
advisor
;
if
(
ia
.
getClassFilter
().
matches
(
actualClass
))
{
...
...
spring-aop/src/main/java/org/springframework/aop/framework/ProxyCreatorSupport.java
View file @
28270ba2
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
8
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.
...
...
@@ -34,7 +34,7 @@ public class ProxyCreatorSupport extends AdvisedSupport {
private
AopProxyFactory
aopProxyFactory
;
private
List
<
AdvisedSupportListener
>
listeners
=
new
LinkedList
<
AdvisedSupportListener
>();
private
final
List
<
AdvisedSupportListener
>
listeners
=
new
LinkedList
<
AdvisedSupportListener
>();
/** Set to true when the first AOP proxy has been created */
private
boolean
active
=
false
;
...
...
Prev
1
2
3
4
5
…
40
Next