Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
d1a34b9a
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
d1a34b9a
编写于
9月 25, 2019
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polishing
上级
ace2e623
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
74 addition
and
62 deletion
+74
-62
spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java
...java/org/springframework/aop/framework/CglibAopProxy.java
+7
-6
spring-aop/src/main/java/org/springframework/aop/framework/ReflectiveMethodInvocation.java
...ngframework/aop/framework/ReflectiveMethodInvocation.java
+2
-2
spring-aop/src/main/java/org/springframework/aop/support/ComposablePointcut.java
...a/org/springframework/aop/support/ComposablePointcut.java
+10
-7
spring-aop/src/main/java/org/springframework/aop/support/DefaultIntroductionAdvisor.java
...ringframework/aop/support/DefaultIntroductionAdvisor.java
+13
-13
spring-aop/src/main/java/org/springframework/aop/support/NameMatchMethodPointcut.java
.../springframework/aop/support/NameMatchMethodPointcut.java
+4
-3
spring-aop/src/main/java/org/springframework/aop/support/Pointcuts.java
.../main/java/org/springframework/aop/support/Pointcuts.java
+3
-2
spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationMatchingPointcut.java
...rk/aop/support/annotation/AnnotationMatchingPointcut.java
+3
-3
spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java
...tory/annotation/AutowiredAnnotationBeanPostProcessor.java
+8
-6
spring-beans/src/main/java/org/springframework/beans/factory/support/CglibSubclassingInstantiationStrategy.java
...actory/support/CglibSubclassingInstantiationStrategy.java
+2
-2
spring-beans/src/main/java/org/springframework/beans/factory/support/MethodOverrides.java
...pringframework/beans/factory/support/MethodOverrides.java
+1
-2
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/SseEmitter.java
...amework/web/servlet/mvc/method/annotation/SseEmitter.java
+21
-16
未找到文件。
spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java
浏览文件 @
d1a34b9a
/*
* Copyright 2002-201
8
the original author or authors.
* Copyright 2002-201
9
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.
...
...
@@ -328,10 +328,11 @@ class CglibAopProxy implements AopProxy, Serializable {
// TODO: small memory optimization here (can skip creation for methods with no advice)
for
(
int
x
=
0
;
x
<
methods
.
length
;
x
++)
{
List
<
Object
>
chain
=
this
.
advised
.
getInterceptorsAndDynamicInterceptionAdvice
(
methods
[
x
],
rootClass
);
Method
method
=
methods
[
x
];
List
<
Object
>
chain
=
this
.
advised
.
getInterceptorsAndDynamicInterceptionAdvice
(
method
,
rootClass
);
fixedCallbacks
[
x
]
=
new
FixedChainStaticTargetInterceptor
(
chain
,
this
.
advised
.
getTargetSource
().
getTarget
(),
this
.
advised
.
getTargetClass
());
this
.
fixedInterceptorMap
.
put
(
methods
[
x
]
.
toString
(),
x
);
this
.
fixedInterceptorMap
.
put
(
methods
.
toString
(),
x
);
}
// Now copy both the callbacks from mainCallbacks
...
...
@@ -614,8 +615,8 @@ class CglibAopProxy implements AopProxy, Serializable {
@Override
public
Object
intercept
(
Object
proxy
,
Method
method
,
Object
[]
args
,
MethodProxy
methodProxy
)
throws
Throwable
{
MethodInvocation
invocation
=
new
CglibMethodInvocation
(
proxy
,
this
.
target
,
method
,
args
,
this
.
targetClass
,
this
.
adviceChain
,
methodProxy
);
MethodInvocation
invocation
=
new
CglibMethodInvocation
(
proxy
,
this
.
target
,
method
,
args
,
this
.
targetClass
,
this
.
adviceChain
,
methodProxy
);
// If we get here, we need to create a MethodInvocation.
Object
retVal
=
invocation
.
proceed
();
retVal
=
processReturnType
(
proxy
,
this
.
target
,
method
,
retVal
);
...
...
@@ -783,7 +784,7 @@ class CglibAopProxy implements AopProxy, Serializable {
* <dt>For advised methods:</dt>
* <dd>If the target is static and the advice chain is frozen then a
* FixedChainStaticTargetInterceptor specific to the method is used to
* invoke the advice chain. Otherwise a Dy
an
micAdvisedInterceptor is
* invoke the advice chain. Otherwise a Dy
na
micAdvisedInterceptor is
* used.</dd>
* <dt>For non-advised methods:</dt>
* <dd>Where it can be determined that the method will not return {@code this}
...
...
spring-aop/src/main/java/org/springframework/aop/framework/ReflectiveMethodInvocation.java
浏览文件 @
d1a34b9a
/*
* Copyright 2002-201
5
the original author or authors.
* Copyright 2002-201
9
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.
...
...
@@ -152,7 +152,7 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
@Override
public
Object
proceed
()
throws
Throwable
{
//
We start with an index of -1 and increment early.
//
We start with an index of -1 and increment early.
if
(
this
.
currentInterceptorIndex
==
this
.
interceptorsAndDynamicMethodMatchers
.
size
()
-
1
)
{
return
invokeJoinpoint
();
}
...
...
spring-aop/src/main/java/org/springframework/aop/support/ComposablePointcut.java
浏览文件 @
d1a34b9a
/*
* Copyright 2002-201
7
the original author or authors.
* Copyright 2002-201
9
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.
...
...
@@ -24,12 +24,15 @@ import org.springframework.aop.Pointcut;
import
org.springframework.util.Assert
;
/**
* Convenient class for building up pointcuts. All methods return
* ComposablePointcut, so we can use a concise idiom like:
* Convenient class for building up pointcuts.
*
* {@code
* Pointcut pc = new ComposablePointcut().union(classFilter).intersection(methodMatcher).intersection(pointcut);
* }
* <p>All methods return {@code ComposablePointcut}, so we can use concise idioms
* like in the following example.
*
* <pre class="code">Pointcut pc = new ComposablePointcut()
* .union(classFilter)
* .intersection(methodMatcher)
* .intersection(pointcut);</pre>
*
* @author Rod Johnson
* @author Juergen Hoeller
...
...
@@ -199,7 +202,7 @@ public class ComposablePointcut implements Pointcut, Serializable {
@Override
public
String
toString
()
{
return
"ComposablePointcut: "
+
this
.
classFilter
+
", "
+
this
.
methodMatcher
;
return
"ComposablePointcut: "
+
this
.
classFilter
+
", "
+
this
.
methodMatcher
;
}
}
spring-aop/src/main/java/org/springframework/aop/support/DefaultIntroductionAdvisor.java
浏览文件 @
d1a34b9a
/*
* Copyright 2002-201
8
the original author or authors.
* Copyright 2002-201
9
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.
...
...
@@ -38,7 +38,7 @@ import org.springframework.util.ClassUtils;
* @author Juergen Hoeller
* @since 11.11.2003
*/
@SuppressWarnings
(
{
"serial"
}
)
@SuppressWarnings
(
"serial"
)
public
class
DefaultIntroductionAdvisor
implements
IntroductionAdvisor
,
ClassFilter
,
Ordered
,
Serializable
{
private
final
Advice
advice
;
...
...
@@ -81,25 +81,25 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil
/**
* Create a DefaultIntroductionAdvisor for the given advice.
* @param advice the Advice to apply
* @param i
ntf
the interface to introduce
* @param i
fc
the interface to introduce
*/
public
DefaultIntroductionAdvisor
(
DynamicIntroductionAdvice
advice
,
Class
<?>
i
ntf
)
{
public
DefaultIntroductionAdvisor
(
DynamicIntroductionAdvice
advice
,
Class
<?>
i
fc
)
{
Assert
.
notNull
(
advice
,
"Advice must not be null"
);
this
.
advice
=
advice
;
addInterface
(
i
ntf
);
addInterface
(
i
fc
);
}
/**
* Add the specified interface to the list of interfaces to introduce.
* @param i
ntf
the interface to introduce
* @param i
fc
the interface to introduce
*/
public
void
addInterface
(
Class
<?>
i
ntf
)
{
Assert
.
notNull
(
i
ntf
,
"Interface must not be null"
);
if
(!
i
ntf
.
isInterface
())
{
throw
new
IllegalArgumentException
(
"Specified class ["
+
i
ntf
.
getName
()
+
"] must be an interface"
);
public
void
addInterface
(
Class
<?>
i
fc
)
{
Assert
.
notNull
(
i
fc
,
"Interface must not be null"
);
if
(!
i
fc
.
isInterface
())
{
throw
new
IllegalArgumentException
(
"Specified class ["
+
i
fc
.
getName
()
+
"] must be an interface"
);
}
this
.
interfaces
.
add
(
i
ntf
);
this
.
interfaces
.
add
(
i
fc
);
}
@Override
...
...
@@ -112,8 +112,8 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil
for
(
Class
<?>
ifc
:
this
.
interfaces
)
{
if
(
this
.
advice
instanceof
DynamicIntroductionAdvice
&&
!((
DynamicIntroductionAdvice
)
this
.
advice
).
implementsInterface
(
ifc
))
{
throw
new
IllegalArgumentException
(
"DynamicIntroductionAdvice ["
+
this
.
advice
+
"] "
+
"does not implement interface ["
+
ifc
.
getName
()
+
"] specified for introduction"
);
throw
new
IllegalArgumentException
(
"DynamicIntroductionAdvice ["
+
this
.
advice
+
"] "
+
"does not implement interface ["
+
ifc
.
getName
()
+
"] specified for introduction"
);
}
}
}
...
...
spring-aop/src/main/java/org/springframework/aop/support/NameMatchMethodPointcut.java
浏览文件 @
d1a34b9a
/*
* Copyright 2002-201
7
the original author or authors.
* Copyright 2002-201
9
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.
...
...
@@ -26,8 +26,9 @@ import org.springframework.util.ObjectUtils;
import
org.springframework.util.PatternMatchUtils
;
/**
* Pointcut bean for simple method name matches, as alternative to regexp patterns.
* Does not handle overloaded methods: all methods with a given name will be eligible.
* Pointcut bean for simple method name matches, as an alternative to regexp patterns.
*
* <p>Does not handle overloaded methods: all methods with a given name will be eligible.
*
* @author Juergen Hoeller
* @author Rod Johnson
...
...
spring-aop/src/main/java/org/springframework/aop/support/Pointcuts.java
浏览文件 @
d1a34b9a
/*
* Copyright 2002-201
5
the original author or authors.
* Copyright 2002-201
9
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.
...
...
@@ -26,7 +26,8 @@ import org.springframework.util.Assert;
/**
* Pointcut constants for matching getters and setters,
* and static methods useful for manipulating and evaluating pointcuts.
* These methods are particularly useful for composing pointcuts
*
* <p>These methods are particularly useful for composing pointcuts
* using the union and intersection methods.
*
* @author Rod Johnson
...
...
spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationMatchingPointcut.java
浏览文件 @
d1a34b9a
/*
* Copyright 2002-201
7
the original author or authors.
* Copyright 2002-201
9
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.
...
...
@@ -61,7 +61,7 @@ public class AnnotationMatchingPointcut implements Pointcut {
}
/**
* Create a new AnnotationMatchingPointcut for the given annotation type.
* Create a new AnnotationMatchingPointcut for the given annotation type
s
.
* @param classAnnotationType the annotation type to look for at the class level
* (can be {@code null})
* @param methodAnnotationType the annotation type to look for at the method level
...
...
@@ -119,7 +119,7 @@ public class AnnotationMatchingPointcut implements Pointcut {
@Override
public
String
toString
()
{
return
"AnnotationMatchingPointcut: "
+
this
.
classFilter
+
", "
+
this
.
methodMatcher
;
return
"AnnotationMatchingPointcut: "
+
this
.
classFilter
+
", "
+
this
.
methodMatcher
;
}
...
...
spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java
浏览文件 @
d1a34b9a
/*
* Copyright 2002-201
8
the original author or authors.
* Copyright 2002-201
9
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.
...
...
@@ -141,9 +141,10 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
/**
* Create a new AutowiredAnnotationBeanPostProcessor
* for Spring's standard {@link Autowired} annotation.
* <p>Also supports JSR-330's {@link javax.inject.Inject} annotation, if available.
* Create a new {@code AutowiredAnnotationBeanPostProcessor} for Spring's
* standard {@link Autowired @Autowired} annotation.
* <p>Also supports JSR-330's {@link javax.inject.Inject @Inject} annotation,
* if available.
*/
@SuppressWarnings
(
"unchecked"
)
public
AutowiredAnnotationBeanPostProcessor
()
{
...
...
@@ -239,7 +240,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
public
Constructor
<?>[]
determineCandidateConstructors
(
Class
<?>
beanClass
,
final
String
beanName
)
throws
BeanCreationException
{
// Let's check for lookup methods here..
// Let's check for lookup methods here..
.
if
(!
this
.
lookupMethodsChecked
.
contains
(
beanName
))
{
try
{
ReflectionUtils
.
doWithMethods
(
beanClass
,
new
ReflectionUtils
.
MethodCallback
()
{
...
...
@@ -249,7 +250,8 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
if
(
lookup
!=
null
)
{
LookupOverride
override
=
new
LookupOverride
(
method
,
lookup
.
value
());
try
{
RootBeanDefinition
mbd
=
(
RootBeanDefinition
)
beanFactory
.
getMergedBeanDefinition
(
beanName
);
RootBeanDefinition
mbd
=
(
RootBeanDefinition
)
beanFactory
.
getMergedBeanDefinition
(
beanName
);
mbd
.
getMethodOverrides
().
addOverride
(
override
);
}
catch
(
NoSuchBeanDefinitionException
ex
)
{
...
...
spring-beans/src/main/java/org/springframework/beans/factory/support/CglibSubclassingInstantiationStrategy.java
浏览文件 @
d1a34b9a
/*
* Copyright 2002-201
6
the original author or authors.
* Copyright 2002-201
9
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.
...
...
@@ -246,7 +246,7 @@ public class CglibSubclassingInstantiationStrategy extends SimpleInstantiationSt
public
int
accept
(
Method
method
)
{
MethodOverride
methodOverride
=
getBeanDefinition
().
getMethodOverrides
().
getOverride
(
method
);
if
(
logger
.
isTraceEnabled
())
{
logger
.
trace
(
"
Override for '"
+
method
.
getName
()
+
"' is ["
+
methodOverride
+
"]"
);
logger
.
trace
(
"
MethodOverride for "
+
method
+
": "
+
methodOverride
);
}
if
(
methodOverride
==
null
)
{
return
PASSTHROUGH
;
...
...
spring-beans/src/main/java/org/springframework/beans/factory/support/MethodOverrides.java
浏览文件 @
d1a34b9a
/*
* Copyright 2002-201
6
the original author or authors.
* Copyright 2002-201
9
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.
...
...
@@ -121,7 +121,6 @@ public class MethodOverrides {
}
MethodOverrides
that
=
(
MethodOverrides
)
other
;
return
this
.
overrides
.
equals
(
that
.
overrides
);
}
@Override
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/SseEmitter.java
浏览文件 @
d1a34b9a
/*
* Copyright 2002-201
7
the original author or authors.
* Copyright 2002-201
9
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.
...
...
@@ -25,6 +25,7 @@ import java.util.Set;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.server.ServerHttpResponse
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
/**
...
...
@@ -39,7 +40,7 @@ public class SseEmitter extends ResponseBodyEmitter {
static
final
MediaType
TEXT_PLAIN
=
new
MediaType
(
"text"
,
"plain"
,
Charset
.
forName
(
"UTF-8"
));
static
final
MediaType
UTF8_
TEXT_EVENTSTREAM
=
new
MediaType
(
"text"
,
"event-stream"
,
Charset
.
forName
(
"UTF-8"
));
static
final
MediaType
TEXT_EVENTSTREAM
=
new
MediaType
(
"text"
,
"event-stream"
,
Charset
.
forName
(
"UTF-8"
));
/**
...
...
@@ -68,7 +69,7 @@ public class SseEmitter extends ResponseBodyEmitter {
HttpHeaders
headers
=
outputMessage
.
getHeaders
();
if
(
headers
.
getContentType
()
==
null
)
{
headers
.
setContentType
(
UTF8_
TEXT_EVENTSTREAM
);
headers
.
setContentType
(
TEXT_EVENTSTREAM
);
}
}
...
...
@@ -112,7 +113,6 @@ public class SseEmitter extends ResponseBodyEmitter {
* Send an SSE event prepared with the given builder. For example:
* <pre>
* // static import of SseEmitter
*
* SseEmitter emitter = new SseEmitter();
* emitter.send(event().name("update").id("1").data(myObject));
* </pre>
...
...
@@ -128,6 +128,11 @@ public class SseEmitter extends ResponseBodyEmitter {
}
}
@Override
public
String
toString
()
{
return
"SseEmitter@"
+
ObjectUtils
.
getIdentityHexString
(
this
);
}
public
static
SseEventBuilder
event
()
{
return
new
SseEventBuilderImpl
();
...
...
@@ -140,9 +145,9 @@ public class SseEmitter extends ResponseBodyEmitter {
public
interface
SseEventBuilder
{
/**
* Add an SSE "
comment
" line.
* Add an SSE "
id
" line.
*/
SseEventBuilder
comment
(
String
comment
);
SseEventBuilder
id
(
String
id
);
/**
* Add an SSE "event" line.
...
...
@@ -150,14 +155,14 @@ public class SseEmitter extends ResponseBodyEmitter {
SseEventBuilder
name
(
String
eventName
);
/**
* Add an SSE "
id
" line.
* Add an SSE "
retry
" line.
*/
SseEventBuilder
id
(
String
id
);
SseEventBuilder
reconnectTime
(
long
reconnectTimeMillis
);
/**
* Add an SSE "
ev
ent" line.
* Add an SSE "
comm
ent" line.
*/
SseEventBuilder
reconnectTime
(
long
reconnectTimeMillis
);
SseEventBuilder
comment
(
String
comment
);
/**
* Add an SSE "data" line.
...
...
@@ -188,8 +193,8 @@ public class SseEmitter extends ResponseBodyEmitter {
private
StringBuilder
sb
;
@Override
public
SseEventBuilder
comment
(
String
comment
)
{
append
(
"
:"
).
append
(
comment
!=
null
?
comment
:
""
).
append
(
"\n"
);
public
SseEventBuilder
id
(
String
id
)
{
append
(
"
id:"
).
append
(
id
!=
null
?
id
:
""
).
append
(
"\n"
);
return
this
;
}
...
...
@@ -200,14 +205,14 @@ public class SseEmitter extends ResponseBodyEmitter {
}
@Override
public
SseEventBuilder
id
(
String
id
)
{
append
(
"
id:"
).
append
(
id
!=
null
?
id
:
""
).
append
(
"\n"
);
public
SseEventBuilder
reconnectTime
(
long
reconnectTimeMillis
)
{
append
(
"
retry:"
).
append
(
String
.
valueOf
(
reconnectTimeMillis
)
).
append
(
"\n"
);
return
this
;
}
@Override
public
SseEventBuilder
reconnectTime
(
long
reconnectTimeMillis
)
{
append
(
"
retry:"
).
append
(
String
.
valueOf
(
reconnectTimeMillis
)
).
append
(
"\n"
);
public
SseEventBuilder
comment
(
String
comment
)
{
append
(
"
:"
).
append
(
comment
!=
null
?
comment
:
""
).
append
(
"\n"
);
return
this
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录