Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
4a57e26d
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,发现更多精彩内容 >>
提交
4a57e26d
编写于
1月 07, 2018
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polishing
上级
b6191f60
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
124 addition
and
57 deletion
+124
-57
spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java
...tory/annotation/AutowiredAnnotationBeanPostProcessor.java
+2
-2
spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java
...annotation/AutowiredAnnotationBeanPostProcessorTests.java
+43
-5
spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReaderTests.java
...ework/beans/factory/xml/XmlBeanDefinitionReaderTests.java
+5
-6
spring-expression/src/main/java/org/springframework/expression/spel/ast/ConstructorReference.java
...ngframework/expression/spel/ast/ConstructorReference.java
+3
-3
spring-expression/src/main/java/org/springframework/expression/spel/ast/SpelNodeImpl.java
...org/springframework/expression/spel/ast/SpelNodeImpl.java
+6
-5
spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationCoverageTests.java
...amework/expression/spel/SpelCompilationCoverageTests.java
+4
-3
spring-jms/src/test/java/org/springframework/jms/annotation/JmsListenerAnnotationBeanPostProcessorTests.java
...notation/JmsListenerAnnotationBeanPostProcessorTests.java
+47
-9
spring-test/src/main/java/org/springframework/test/web/reactive/server/HeaderAssertions.java
...gframework/test/web/reactive/server/HeaderAssertions.java
+4
-7
spring-web/src/main/java/org/springframework/web/server/ServerWebExchange.java
...ava/org/springframework/web/server/ServerWebExchange.java
+2
-2
spring-web/src/main/java/org/springframework/web/server/adapter/DefaultServerWebExchange.java
...ramework/web/server/adapter/DefaultServerWebExchange.java
+2
-2
src/docs/asciidoc/testing.adoc
src/docs/asciidoc/testing.adoc
+6
-13
未找到文件。
spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java
浏览文件 @
4a57e26d
/*
* 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.
...
...
@@ -280,7 +280,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
"Resolution of declared constructors on bean Class ["
+
beanClass
.
getName
()
+
"] from ClassLoader ["
+
beanClass
.
getClassLoader
()
+
"] failed"
,
ex
);
}
List
<
Constructor
<?>>
candidates
=
new
ArrayList
<
Constructor
<?>
>(
rawCandidates
.
length
);
List
<
Constructor
<?>>
candidates
=
new
ArrayList
<>(
rawCandidates
.
length
);
Constructor
<?>
requiredConstructor
=
null
;
Constructor
<?>
defaultConstructor
=
null
;
Constructor
<?>
primaryConstructor
=
BeanUtils
.
findPrimaryConstructor
(
beanClass
);
...
...
spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java
浏览文件 @
4a57e26d
/*
* 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.
...
...
@@ -43,6 +43,7 @@ import org.mockito.Mockito;
import
org.springframework.beans.factory.BeanCreationException
;
import
org.springframework.beans.factory.BeanFactory
;
import
org.springframework.beans.factory.BeanNameAware
;
import
org.springframework.beans.factory.DisposableBean
;
import
org.springframework.beans.factory.FactoryBean
;
import
org.springframework.beans.factory.NoSuchBeanDefinitionException
;
import
org.springframework.beans.factory.NoUniqueBeanDefinitionException
;
...
...
@@ -152,6 +153,35 @@ public class AutowiredAnnotationBeanPostProcessorTests {
assertEquals
(
"nestedTestBean"
,
depBeans
[
1
]);
}
@Test
public
void
testExtendedResourceInjectionWithDestruction
()
{
DefaultListableBeanFactory
bf
=
new
DefaultListableBeanFactory
();
bf
.
registerResolvableDependency
(
BeanFactory
.
class
,
bf
);
AutowiredAnnotationBeanPostProcessor
bpp
=
new
AutowiredAnnotationBeanPostProcessor
();
bpp
.
setBeanFactory
(
bf
);
bf
.
addBeanPostProcessor
(
bpp
);
bf
.
registerBeanDefinition
(
"annotatedBean"
,
new
RootBeanDefinition
(
TypedExtendedResourceInjectionBean
.
class
));
bf
.
registerBeanDefinition
(
"testBean"
,
new
RootBeanDefinition
(
TestBean
.
class
));
NestedTestBean
ntb
=
new
NestedTestBean
();
bf
.
registerSingleton
(
"nestedTestBean"
,
ntb
);
TestBean
tb
=
bf
.
getBean
(
"testBean"
,
TestBean
.
class
);
TypedExtendedResourceInjectionBean
bean
=
(
TypedExtendedResourceInjectionBean
)
bf
.
getBean
(
"annotatedBean"
);
assertSame
(
tb
,
bean
.
getTestBean
());
assertSame
(
tb
,
bean
.
getTestBean2
());
assertSame
(
tb
,
bean
.
getTestBean3
());
assertSame
(
tb
,
bean
.
getTestBean4
());
assertSame
(
ntb
,
bean
.
getNestedTestBean
());
assertSame
(
bf
,
bean
.
getBeanFactory
());
assertArrayEquals
(
new
String
[]
{
"testBean"
,
"nestedTestBean"
},
bf
.
getDependenciesForBean
(
"annotatedBean"
));
bf
.
destroySingleton
(
"testBean"
);
assertFalse
(
bf
.
containsSingleton
(
"testBean"
));
assertFalse
(
bf
.
containsSingleton
(
"annotatedBean"
));
assertTrue
(
bean
.
destroyed
);
assertSame
(
0
,
bf
.
getDependenciesForBean
(
"annotatedBean"
).
length
);
}
@Test
public
void
testExtendedResourceInjectionWithOverriding
()
{
DefaultListableBeanFactory
bf
=
new
DefaultListableBeanFactory
();
...
...
@@ -1286,9 +1316,6 @@ public class AutowiredAnnotationBeanPostProcessorTests {
bf
.
destroySingletons
();
}
@Qualifier
(
"testBean"
)
private
void
testBeanQualifierProvider
()
{}
@Test
public
void
testObjectFactorySerialization
()
throws
Exception
{
DefaultListableBeanFactory
bf
=
new
DefaultListableBeanFactory
();
...
...
@@ -2494,6 +2521,9 @@ public class AutowiredAnnotationBeanPostProcessorTests {
}
@Qualifier
(
"testBean"
)
private
void
testBeanQualifierProvider
()
{}
@Qualifier
(
"integerRepo"
)
private
Repository
<?>
integerRepositoryQualifierProvider
;
...
...
@@ -2579,7 +2609,15 @@ public class AutowiredAnnotationBeanPostProcessorTests {
}
public
static
class
TypedExtendedResourceInjectionBean
extends
NonPublicResourceInjectionBean
<
NestedTestBean
>
{
public
static
class
TypedExtendedResourceInjectionBean
extends
NonPublicResourceInjectionBean
<
NestedTestBean
>
implements
DisposableBean
{
public
boolean
destroyed
=
false
;
@Override
public
void
destroy
()
{
this
.
destroyed
=
true
;
}
}
...
...
spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReaderTests.java
浏览文件 @
4a57e26d
/*
* 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.
...
...
@@ -49,8 +49,7 @@ public class XmlBeanDefinitionReaderTests {
@Test
(
expected
=
BeanDefinitionStoreException
.
class
)
public
void
withOpenInputStream
()
{
SimpleBeanDefinitionRegistry
registry
=
new
SimpleBeanDefinitionRegistry
();
Resource
resource
=
new
InputStreamResource
(
getClass
().
getResourceAsStream
(
"test.xml"
));
Resource
resource
=
new
InputStreamResource
(
getClass
().
getResourceAsStream
(
"test.xml"
));
new
XmlBeanDefinitionReader
(
registry
).
loadBeanDefinitions
(
resource
);
}
...
...
@@ -122,16 +121,16 @@ public class XmlBeanDefinitionReaderTests {
}
@Test
public
void
dtdValidationAutodetect
()
throws
Exception
{
public
void
dtdValidationAutodetect
()
{
doTestValidation
(
"validateWithDtd.xml"
);
}
@Test
public
void
xsdValidationAutodetect
()
throws
Exception
{
public
void
xsdValidationAutodetect
()
{
doTestValidation
(
"validateWithXsd.xml"
);
}
private
void
doTestValidation
(
String
resourceName
)
throws
Exception
{
private
void
doTestValidation
(
String
resourceName
)
{
DefaultListableBeanFactory
factory
=
new
DefaultListableBeanFactory
();
Resource
resource
=
new
ClassPathResource
(
resourceName
,
getClass
());
new
XmlBeanDefinitionReader
(
factory
).
loadBeanDefinitions
(
resource
);
...
...
spring-expression/src/main/java/org/springframework/expression/spel/ast/ConstructorReference.java
浏览文件 @
4a57e26d
/*
* 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.
...
...
@@ -458,8 +458,8 @@ public class ConstructorReference extends SpelNodeImpl {
mv
.
visitInsn
(
DUP
);
// children[0] is the type of the constructor, don't want to include that in argument processing
SpelNodeImpl
[]
arguments
=
new
SpelNodeImpl
[
children
.
length
-
1
];
System
.
arraycopy
(
children
,
1
,
arguments
,
0
,
children
.
length
-
1
);
SpelNodeImpl
[]
arguments
=
new
SpelNodeImpl
[
this
.
children
.
length
-
1
];
System
.
arraycopy
(
this
.
children
,
1
,
arguments
,
0
,
this
.
children
.
length
-
1
);
generateCodeForArguments
(
mv
,
cf
,
constructor
,
arguments
);
mv
.
visitMethodInsn
(
INVOKESPECIAL
,
classDesc
,
"<init>"
,
CodeFlow
.
createSignatureDescriptor
(
constructor
),
false
);
cf
.
pushDescriptor
(
this
.
exitTypeDescriptor
);
...
...
spring-expression/src/main/java/org/springframework/expression/spel/ast/SpelNodeImpl.java
浏览文件 @
4a57e26d
/*
* 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.
...
...
@@ -39,6 +39,7 @@ import org.springframework.util.ObjectUtils;
* format expression.
*
* @author Andy Clement
* @author Juergen Hoeller
* @since 3.0
*/
public
abstract
class
SpelNodeImpl
implements
SpelNode
,
Opcodes
{
...
...
@@ -46,7 +47,7 @@ public abstract class SpelNodeImpl implements SpelNode, Opcodes {
private
static
SpelNodeImpl
[]
NO_CHILDREN
=
new
SpelNodeImpl
[
0
];
protected
int
pos
;
// start = top 16bits, end = bottom 16bits
protected
int
pos
;
// start = top 16bits, end = bottom 16bits
protected
SpelNodeImpl
[]
children
=
SpelNodeImpl
.
NO_CHILDREN
;
...
...
@@ -81,7 +82,7 @@ public abstract class SpelNodeImpl implements SpelNode, Opcodes {
/**
*
@return true if the next child is one of the specified classes
*
Return {@code true} if the next child is one of the specified classes.
*/
protected
boolean
nextChildIs
(
Class
<?>...
clazzes
)
{
if
(
this
.
parent
!=
null
)
{
...
...
@@ -123,8 +124,7 @@ public abstract class SpelNodeImpl implements SpelNode, Opcodes {
@Override
public
void
setValue
(
ExpressionState
expressionState
,
@Nullable
Object
newValue
)
throws
EvaluationException
{
throw
new
SpelEvaluationException
(
getStartPosition
(),
SpelMessage
.
SETVALUE_NOT_SUPPORTED
,
getClass
());
throw
new
SpelEvaluationException
(
getStartPosition
(),
SpelMessage
.
SETVALUE_NOT_SUPPORTED
,
getClass
());
}
@Override
...
...
@@ -281,4 +281,5 @@ public abstract class SpelNodeImpl implements SpelNode, Opcodes {
}
cf
.
exitCompilationScope
();
}
}
spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationCoverageTests.java
浏览文件 @
4a57e26d
/*
* 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.
...
...
@@ -4988,7 +4988,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
}
@Override
public
void
generateCode
(
String
propertyName
,
MethodVisitor
mv
,
CodeFlow
cf
)
{
public
void
generateCode
(
String
propertyName
,
MethodVisitor
mv
,
CodeFlow
cf
)
{
if
(
method
==
null
)
{
try
{
method
=
Payload2
.
class
.
getDeclaredMethod
(
"getField"
,
String
.
class
);
...
...
@@ -5005,7 +5005,8 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
mv
.
visitTypeInsn
(
CHECKCAST
,
memberDeclaringClassSlashedDescriptor
);
}
mv
.
visitLdcInsn
(
propertyName
);
mv
.
visitMethodInsn
(
INVOKEVIRTUAL
,
memberDeclaringClassSlashedDescriptor
,
method
.
getName
(),
CodeFlow
.
createSignatureDescriptor
(
method
),
false
);
mv
.
visitMethodInsn
(
INVOKEVIRTUAL
,
memberDeclaringClassSlashedDescriptor
,
method
.
getName
(),
CodeFlow
.
createSignatureDescriptor
(
method
),
false
);
}
}
...
...
spring-jms/src/test/java/org/springframework/jms/annotation/JmsListenerAnnotationBeanPostProcessorTests.java
浏览文件 @
4a57e26d
/*
* 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.
...
...
@@ -39,6 +39,7 @@ import org.springframework.jms.config.JmsListenerEndpointRegistry;
import
org.springframework.jms.config.MessageListenerTestContainer
;
import
org.springframework.jms.config.MethodJmsListenerEndpoint
;
import
org.springframework.jms.listener.SimpleMessageListenerContainer
;
import
org.springframework.messaging.handler.annotation.Header
;
import
org.springframework.messaging.handler.annotation.SendTo
;
import
org.springframework.stereotype.Component
;
import
org.springframework.transaction.PlatformTransactionManager
;
...
...
@@ -108,9 +109,9 @@ public class JmsListenerAnnotationBeanPostProcessorTests {
}
@Test
public
void
sendToAnnotationFoundOnProxy
()
throws
Exception
{
public
void
sendToAnnotationFoundOn
Interface
Proxy
()
throws
Exception
{
ConfigurableApplicationContext
context
=
new
AnnotationConfigApplicationContext
(
Config
.
class
,
ProxyConfig
.
class
,
ProxyTestBean
.
class
);
Config
.
class
,
ProxyConfig
.
class
,
Interface
ProxyTestBean
.
class
);
try
{
JmsListenerContainerTestFactory
factory
=
context
.
getBean
(
JmsListenerContainerTestFactory
.
class
);
assertEquals
(
"one container should have been registered"
,
1
,
factory
.
getListenerContainers
().
size
());
...
...
@@ -120,8 +121,34 @@ public class JmsListenerAnnotationBeanPostProcessorTests {
MethodJmsListenerEndpoint
methodEndpoint
=
(
MethodJmsListenerEndpoint
)
endpoint
;
assertTrue
(
AopUtils
.
isJdkDynamicProxy
(
methodEndpoint
.
getBean
()));
assertTrue
(
methodEndpoint
.
getBean
()
instanceof
SimpleService
);
assertEquals
(
SimpleService
.
class
.
getMethod
(
"handleIt"
,
String
.
class
),
methodEndpoint
.
getMethod
());
assertEquals
(
ProxyTestBean
.
class
.
getMethod
(
"handleIt"
,
String
.
class
),
methodEndpoint
.
getMostSpecificMethod
());
assertEquals
(
SimpleService
.
class
.
getMethod
(
"handleIt"
,
String
.
class
,
String
.
class
),
methodEndpoint
.
getMethod
());
assertEquals
(
InterfaceProxyTestBean
.
class
.
getMethod
(
"handleIt"
,
String
.
class
,
String
.
class
),
methodEndpoint
.
getMostSpecificMethod
());
Method
m
=
ReflectionUtils
.
findMethod
(
endpoint
.
getClass
(),
"getDefaultResponseDestination"
);
ReflectionUtils
.
makeAccessible
(
m
);
Object
destination
=
ReflectionUtils
.
invokeMethod
(
m
,
endpoint
);
assertEquals
(
"SendTo annotation not found on proxy"
,
"foobar"
,
destination
);
}
finally
{
context
.
close
();
}
}
@Test
public
void
sendToAnnotationFoundOnCglibProxy
()
throws
Exception
{
ConfigurableApplicationContext
context
=
new
AnnotationConfigApplicationContext
(
Config
.
class
,
ProxyConfig
.
class
,
ClassProxyTestBean
.
class
);
try
{
JmsListenerContainerTestFactory
factory
=
context
.
getBean
(
JmsListenerContainerTestFactory
.
class
);
assertEquals
(
"one container should have been registered"
,
1
,
factory
.
getListenerContainers
().
size
());
JmsListenerEndpoint
endpoint
=
factory
.
getListenerContainers
().
get
(
0
).
getEndpoint
();
assertEquals
(
"Wrong endpoint type"
,
MethodJmsListenerEndpoint
.
class
,
endpoint
.
getClass
());
MethodJmsListenerEndpoint
methodEndpoint
=
(
MethodJmsListenerEndpoint
)
endpoint
;
assertTrue
(
AopUtils
.
isCglibProxy
(
methodEndpoint
.
getBean
()));
assertTrue
(
methodEndpoint
.
getBean
()
instanceof
ClassProxyTestBean
);
assertEquals
(
ClassProxyTestBean
.
class
.
getMethod
(
"handleIt"
,
String
.
class
,
String
.
class
),
methodEndpoint
.
getMethod
());
assertEquals
(
ClassProxyTestBean
.
class
.
getMethod
(
"handleIt"
,
String
.
class
,
String
.
class
),
methodEndpoint
.
getMostSpecificMethod
());
Method
m
=
ReflectionUtils
.
findMethod
(
endpoint
.
getClass
(),
"getDefaultResponseDestination"
);
ReflectionUtils
.
makeAccessible
(
m
);
...
...
@@ -204,18 +231,29 @@ public class JmsListenerAnnotationBeanPostProcessorTests {
interface
SimpleService
{
void
handleIt
(
String
body
);
void
handleIt
(
String
value
,
String
body
);
}
@Component
static
class
ProxyTestBean
implements
SimpleService
{
static
class
Interface
ProxyTestBean
implements
SimpleService
{
@Override
@Transactional
@JmsListener
(
destination
=
"testQueue"
)
@SendTo
(
"foobar"
)
public
void
handleIt
(
String
body
)
{
public
void
handleIt
(
@Header
String
value
,
String
body
)
{
}
}
@Component
static
class
ClassProxyTestBean
{
@Transactional
@JmsListener
(
destination
=
"testQueue"
)
@SendTo
(
"foobar"
)
public
void
handleIt
(
@Header
String
value
,
String
body
)
{
}
}
...
...
@@ -224,7 +262,7 @@ public class JmsListenerAnnotationBeanPostProcessorTests {
static
class
InvalidProxyTestBean
implements
SimpleService
{
@Override
public
void
handleIt
(
String
body
)
{
public
void
handleIt
(
String
value
,
String
body
)
{
}
@Transactional
...
...
spring-test/src/main/java/org/springframework/test/web/reactive/server/HeaderAssertions.java
浏览文件 @
4a57e26d
/*
* 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.
...
...
@@ -25,9 +25,7 @@ import org.springframework.http.HttpHeaders;
import
org.springframework.http.MediaType
;
import
org.springframework.lang.Nullable
;
import
static
org
.
springframework
.
test
.
util
.
AssertionErrors
.
assertEquals
;
import
static
org
.
springframework
.
test
.
util
.
AssertionErrors
.
assertTrue
;
import
static
org
.
springframework
.
test
.
util
.
AssertionErrors
.
fail
;
import
static
org
.
springframework
.
test
.
util
.
AssertionErrors
.*;
/**
* Assertions on headers of the response.
...
...
@@ -125,10 +123,9 @@ public class HeaderAssertions {
*/
public
WebTestClient
.
ResponseSpec
contentTypeCompatibleWith
(
MediaType
mediaType
)
{
MediaType
actual
=
getHeaders
().
getContentType
();
String
message
=
getMessage
(
"Content-Type"
)
+
"=["
+
actual
.
toString
()
+
"]"
+
" is not compatible with ["
+
mediaType
.
toString
()
+
"]"
;
String
message
=
getMessage
(
"Content-Type"
)
+
"=["
+
actual
+
"] is not compatible with ["
+
mediaType
+
"]"
;
this
.
exchangeResult
.
assertWithDiagnostics
(()
->
assertTrue
(
message
,
actual
.
isCompatibleWith
(
mediaType
)));
assertTrue
(
message
,
(
actual
!=
null
&&
actual
.
isCompatibleWith
(
mediaType
)
)));
return
this
.
responseSpec
;
}
...
...
spring-web/src/main/java/org/springframework/web/server/ServerWebExchange.java
浏览文件 @
4a57e26d
/*
* 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.
...
...
@@ -142,8 +142,8 @@ public interface ServerWebExchange {
* if it was initialized with one via
* {@link org.springframework.web.server.adapter.WebHttpHandlerBuilder#applicationContext
* WebHttpHandlerBuilder#applicationContext}.
* @see org.springframework.web.server.adapter.WebHttpHandlerBuilder#applicationContext(ApplicationContext)
* @since 5.0.3
* @see org.springframework.web.server.adapter.WebHttpHandlerBuilder#applicationContext(ApplicationContext)
*/
@Nullable
ApplicationContext
getApplicationContext
();
...
...
spring-web/src/main/java/org/springframework/web/server/adapter/DefaultServerWebExchange.java
浏览文件 @
4a57e26d
/*
* 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.
...
...
@@ -219,6 +219,7 @@ public class DefaultServerWebExchange implements ServerWebExchange {
}
@Override
@Nullable
public
ApplicationContext
getApplicationContext
()
{
return
this
.
applicationContext
;
}
...
...
@@ -354,5 +355,4 @@ public class DefaultServerWebExchange implements ServerWebExchange {
this
.
urlTransformer
=
this
.
urlTransformer
.
andThen
(
transformer
);
}
}
src/docs/asciidoc/testing.adoc
浏览文件 @
4a57e26d
...
...
@@ -3142,15 +3142,14 @@ framework.
----
<beans>
<bean id="userService"
class="com.example.SimpleUserService"
c:loginAction-ref="loginAction" />
<bean id="userService" class="com.example.SimpleUserService"
c:loginAction-ref="loginAction"/>
<bean id="loginAction" class="com.example.LoginAction"
c:username="#{request.getParameter('
user
')}"
c:password="#{request.getParameter('
pswd
')}"
scope="request">
<aop:scoped-proxy
/>
<aop:scoped-proxy/>
</bean>
</beans>
...
...
@@ -3179,12 +3178,10 @@ inputs for the username and password.
@Test
public void requestScope() {
request.setParameter("user", "enigma");
request.setParameter("pswd", "$pr!ng");
LoginResults results = userService.loginUser();
// assert results
}
}
...
...
@@ -3203,15 +3200,13 @@ framework.
----
<beans>
<bean id="userService"
class="com.example.SimpleUserService"
<bean id="userService" class="com.example.SimpleUserService"
c:userPreferences-ref="userPreferences" />
<bean id="userPreferences"
class="com.example.UserPreferences"
<bean id="userPreferences" class="com.example.UserPreferences"
c:theme="#{session.getAttribute('
theme
')}"
scope="session">
<aop:scoped-proxy
/>
<aop:scoped-proxy/>
</bean>
</beans>
...
...
@@ -3239,11 +3234,9 @@ configured theme.
@Test
public void sessionScope() throws Exception {
session.setAttribute("theme", "blue");
Results results = userService.processUserPreferences();
// assert results
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录