Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
e6f86c5c
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 搜索 >>
提交
e6f86c5c
编写于
7月 31, 2019
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Nullability refinements and related polishing
上级
cca32a56
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
144 addition
and
146 deletion
+144
-146
spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java
...s/factory/support/AbstractAutowireCapableBeanFactory.java
+2
-5
spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java
...gframework/beans/factory/support/AbstractBeanFactory.java
+13
-13
spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java
...ork/beans/factory/support/DefaultListableBeanFactory.java
+2
-2
spring-core/src/main/java/org/springframework/util/StringUtils.java
...e/src/main/java/org/springframework/util/StringUtils.java
+1
-1
spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/reactive/MessageMappingMessageHandler.java
...ler/annotation/reactive/MessageMappingMessageHandler.java
+20
-9
spring-messaging/src/main/java/org/springframework/messaging/rsocket/DefaultRSocketStrategies.java
...framework/messaging/rsocket/DefaultRSocketStrategies.java
+31
-35
spring-messaging/src/main/java/org/springframework/messaging/rsocket/RSocketStrategies.java
.../springframework/messaging/rsocket/RSocketStrategies.java
+15
-15
spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/support/MessagingRSocket.java
...essaging/rsocket/annotation/support/MessagingRSocket.java
+6
-6
spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/support/RSocketMessageHandler.java
...ing/rsocket/annotation/support/RSocketMessageHandler.java
+46
-54
spring-test/src/main/java/org/springframework/test/context/jdbc/SqlScriptsTestExecutionListener.java
...rk/test/context/jdbc/SqlScriptsTestExecutionListener.java
+1
-0
spring-test/src/main/java/org/springframework/test/context/support/TestPropertySourceAttributes.java
...rk/test/context/support/TestPropertySourceAttributes.java
+6
-3
spring-test/src/main/java/org/springframework/test/context/support/TestPropertySourceUtils.java
...amework/test/context/support/TestPropertySourceUtils.java
+1
-3
未找到文件。
spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java
浏览文件 @
e6f86c5c
...
...
@@ -888,7 +888,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
}
// No type found for shortcut FactoryBean instance:
// fall back to full creation of the FactoryBean instance.
return
super
.
getTypeForFactoryBean
(
beanName
,
mbd
,
allowInit
);
return
super
.
getTypeForFactoryBean
(
beanName
,
mbd
,
true
);
}
}
...
...
@@ -1990,6 +1990,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
}
}
/**
* {@link MethodCallback} used to find {@link FactoryBean} type information.
*/
...
...
@@ -1999,12 +2000,10 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
private
ResolvableType
result
=
ResolvableType
.
NONE
;
FactoryBeanMethodTypeFinder
(
String
factoryMethodName
)
{
this
.
factoryMethodName
=
factoryMethodName
;
}
@Override
public
void
doWith
(
Method
method
)
throws
IllegalArgumentException
,
IllegalAccessException
{
if
(
isFactoryBeanMethod
(
method
))
{
...
...
@@ -2028,13 +2027,11 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
FactoryBean
.
class
.
isAssignableFrom
(
method
.
getReturnType
());
}
ResolvableType
getResult
()
{
Class
<?>
resolved
=
this
.
result
.
resolve
();
boolean
foundResult
=
resolved
!=
null
&&
resolved
!=
Object
.
class
;
return
(
foundResult
?
this
.
result
:
ResolvableType
.
NONE
);
}
}
}
spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java
浏览文件 @
e6f86c5c
...
...
@@ -612,7 +612,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
if
(
FactoryBean
.
class
.
isAssignableFrom
(
predictedType
))
{
if
(
beanInstance
==
null
&&
!
isFactoryDereference
)
{
beanType
=
getTypeForFactoryBean
(
beanName
,
mbd
,
allowFactoryBeanInit
);
predictedType
=
(
beanType
!=
null
)
?
beanType
.
resolve
()
:
null
;
predictedType
=
beanType
.
resolve
()
;
if
(
predictedType
==
null
)
{
return
false
;
}
...
...
@@ -1377,17 +1377,19 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
}
}
private
void
copyRelevantMergedBeanDefinitionCaches
(
RootBeanDefinition
previous
,
RootBeanDefinition
mbd
)
{
private
void
copyRelevantMergedBeanDefinitionCaches
(
RootBeanDefinition
previous
,
RootBeanDefinition
mbd
)
{
if
(
ObjectUtils
.
nullSafeEquals
(
mbd
.
getBeanClassName
(),
previous
.
getBeanClassName
())
&&
ObjectUtils
.
nullSafeEquals
(
mbd
.
getFactoryBeanName
(),
previous
.
getFactoryBeanName
())
&&
ObjectUtils
.
nullSafeEquals
(
mbd
.
getFactoryMethodName
(),
previous
.
getFactoryMethodName
())
&&
(
mbd
.
targetType
==
null
||
mbd
.
targetType
.
equals
(
previous
.
targetType
)))
{
mbd
.
targetType
=
previous
.
targetType
;
mbd
.
isFactoryBean
=
previous
.
isFactoryBean
;
mbd
.
resolvedTargetType
=
previous
.
resolvedTargetType
;
mbd
.
factoryMethodReturnType
=
previous
.
factoryMethodReturnType
;
mbd
.
factoryMethodToIntrospect
=
previous
.
factoryMethodToIntrospect
;
ObjectUtils
.
nullSafeEquals
(
mbd
.
getFactoryMethodName
(),
previous
.
getFactoryMethodName
()))
{
ResolvableType
targetType
=
mbd
.
targetType
;
ResolvableType
previousTargetType
=
previous
.
targetType
;
if
(
targetType
==
null
||
targetType
.
equals
(
previousTargetType
))
{
mbd
.
targetType
=
previousTargetType
;
mbd
.
isFactoryBean
=
previous
.
isFactoryBean
;
mbd
.
resolvedTargetType
=
previous
.
resolvedTargetType
;
mbd
.
factoryMethodReturnType
=
previous
.
factoryMethodReturnType
;
mbd
.
factoryMethodToIntrospect
=
previous
.
factoryMethodToIntrospect
;
}
}
}
...
...
@@ -1625,9 +1627,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
* @see org.springframework.beans.factory.FactoryBean#getObjectType()
* @see #getBean(String)
*/
protected
ResolvableType
getTypeForFactoryBean
(
String
beanName
,
RootBeanDefinition
mbd
,
boolean
allowInit
)
{
protected
ResolvableType
getTypeForFactoryBean
(
String
beanName
,
RootBeanDefinition
mbd
,
boolean
allowInit
)
{
ResolvableType
result
=
getTypeForFactoryBeanFromAttributes
(
mbd
);
if
(
result
!=
ResolvableType
.
NONE
)
{
return
result
;
...
...
spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java
浏览文件 @
e6f86c5c
...
...
@@ -583,8 +583,8 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
return
StringUtils
.
toStringArray
(
result
);
}
private
boolean
isSingleton
(
String
beanName
,
RootBeanDefinition
mbd
,
BeanDefinitionHolder
dbd
)
{
return
(
dbd
!=
null
)
?
mbd
.
isSingleton
()
:
isSingleton
(
beanName
);
private
boolean
isSingleton
(
String
beanName
,
RootBeanDefinition
mbd
,
@Nullable
BeanDefinitionHolder
dbd
)
{
return
(
dbd
!=
null
?
mbd
.
isSingleton
()
:
isSingleton
(
beanName
)
);
}
/**
...
...
spring-core/src/main/java/org/springframework/util/StringUtils.java
浏览文件 @
e6f86c5c
...
...
@@ -900,7 +900,7 @@ public abstract class StringUtils {
* @return the resulting {@code String} array
*/
public
static
String
[]
toStringArray
(
@Nullable
Collection
<
String
>
collection
)
{
return
(
collection
!=
null
||
collection
.
isEmpty
(
)
?
collection
.
toArray
(
EMPTY_STRING_ARRAY
)
:
EMPTY_STRING_ARRAY
);
return
(
!
CollectionUtils
.
isEmpty
(
collection
)
?
collection
.
toArray
(
EMPTY_STRING_ARRAY
)
:
EMPTY_STRING_ARRAY
);
}
/**
...
...
spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/reactive/MessageMappingMessageHandler.java
浏览文件 @
e6f86c5c
...
...
@@ -142,20 +142,31 @@ public class MessageMappingMessageHandler extends AbstractMethodMessageHandler<C
* efficiency consider using the {@code PathPatternRouteMatcher} from
* {@code spring-web} instead.
*/
public
void
setRouteMatcher
(
RouteMatcher
routeMatcher
)
{
Assert
.
notNull
(
routeMatcher
,
"RouteMatcher must not be null"
);
public
void
setRouteMatcher
(
@Nullable
RouteMatcher
routeMatcher
)
{
this
.
routeMatcher
=
routeMatcher
;
}
/**
* Return the {@code RouteMatcher} used to map messages to handlers.
* May be {@code null} before component is initialized.
* May be {@code null} before
the
component is initialized.
*/
@Nullable
public
RouteMatcher
getRouteMatcher
()
{
return
this
.
routeMatcher
;
}
/**
* Obtain the {@code RouteMatcher} for actual use.
* @return the RouteMatcher (never {@code null})
* @throws IllegalStateException in case of no RouteMatcher set
* @since 5.0
*/
protected
RouteMatcher
obtainRouteMatcher
()
{
RouteMatcher
routeMatcher
=
getRouteMatcher
();
Assert
.
state
(
routeMatcher
!=
null
,
"No RouteMatcher set"
);
return
routeMatcher
;
}
/**
* Configure a {@link ConversionService} to use for type conversion of
* String based values, e.g. in destination variables or headers.
...
...
@@ -245,13 +256,13 @@ public class MessageMappingMessageHandler extends AbstractMethodMessageHandler<C
*/
@Nullable
protected
CompositeMessageCondition
getCondition
(
AnnotatedElement
element
)
{
MessageMapping
ann
ot
=
AnnotatedElementUtils
.
findMergedAnnotation
(
element
,
MessageMapping
.
class
);
if
(
ann
ot
==
null
||
annot
.
value
().
length
==
0
)
{
MessageMapping
ann
=
AnnotatedElementUtils
.
findMergedAnnotation
(
element
,
MessageMapping
.
class
);
if
(
ann
==
null
||
ann
.
value
().
length
==
0
)
{
return
null
;
}
String
[]
patterns
=
processDestinations
(
ann
ot
.
value
());
String
[]
patterns
=
processDestinations
(
ann
.
value
());
return
new
CompositeMessageCondition
(
new
DestinationPatternsMessageCondition
(
patterns
,
this
.
routeMatcher
));
new
DestinationPatternsMessageCondition
(
patterns
,
obtainRouteMatcher
()
));
}
/**
...
...
@@ -272,7 +283,7 @@ public class MessageMappingMessageHandler extends AbstractMethodMessageHandler<C
protected
Set
<
String
>
getDirectLookupMappings
(
CompositeMessageCondition
mapping
)
{
Set
<
String
>
result
=
new
LinkedHashSet
<>();
for
(
String
pattern
:
mapping
.
getCondition
(
DestinationPatternsMessageCondition
.
class
).
getPatterns
())
{
if
(!
this
.
routeMatcher
.
isPattern
(
pattern
))
{
if
(!
obtainRouteMatcher
()
.
isPattern
(
pattern
))
{
result
.
add
(
pattern
);
}
}
...
...
@@ -309,7 +320,7 @@ public class MessageMappingMessageHandler extends AbstractMethodMessageHandler<C
String
pattern
=
patterns
.
iterator
().
next
();
RouteMatcher
.
Route
destination
=
getDestination
(
message
);
Assert
.
state
(
destination
!=
null
,
"Missing destination header"
);
Map
<
String
,
String
>
vars
=
get
RouteMatcher
().
matchAndExtract
(
pattern
,
destination
);
Map
<
String
,
String
>
vars
=
obtain
RouteMatcher
().
matchAndExtract
(
pattern
,
destination
);
if
(!
CollectionUtils
.
isEmpty
(
vars
))
{
MessageHeaderAccessor
mha
=
MessageHeaderAccessor
.
getAccessor
(
message
,
MessageHeaderAccessor
.
class
);
Assert
.
state
(
mha
!=
null
&&
mha
.
isMutable
(),
"Mutable MessageHeaderAccessor required"
);
...
...
spring-messaging/src/main/java/org/springframework/messaging/rsocket/DefaultRSocketStrategies.java
浏览文件 @
e6f86c5c
...
...
@@ -56,23 +56,23 @@ final class DefaultRSocketStrategies implements RSocketStrategies {
private
final
RouteMatcher
routeMatcher
;
private
final
MetadataExtractor
metadataExtractor
;
private
final
ReactiveAdapterRegistry
adapterRegistry
;
private
final
DataBufferFactory
bufferFactory
;
private
final
ReactiveAdapterRegistry
adapterRegistry
;
private
final
MetadataExtractor
metadataExtractor
;
private
DefaultRSocketStrategies
(
List
<
Encoder
<?>>
encoders
,
List
<
Decoder
<?>>
decoders
,
RouteMatcher
routeMatcher
,
MetadataExtractor
metadataExtractor
,
DataBufferFactory
bufferFactory
,
ReactiveAdapterRegistry
adapterRegistry
)
{
RouteMatcher
routeMatcher
,
ReactiveAdapterRegistry
adapterRegistry
,
DataBufferFactory
bufferFactory
,
MetadataExtractor
metadataExtractor
)
{
this
.
encoders
=
Collections
.
unmodifiableList
(
encoders
);
this
.
decoders
=
Collections
.
unmodifiableList
(
decoders
);
this
.
routeMatcher
=
routeMatcher
;
this
.
metadataExtractor
=
metadataExtractor
;
this
.
bufferFactory
=
bufferFactory
;
this
.
adapterRegistry
=
adapterRegistry
;
this
.
bufferFactory
=
bufferFactory
;
this
.
metadataExtractor
=
metadataExtractor
;
}
...
...
@@ -92,8 +92,8 @@ final class DefaultRSocketStrategies implements RSocketStrategies {
}
@Override
public
MetadataExtractor
metadataExtractor
()
{
return
this
.
metadataExtractor
;
public
ReactiveAdapterRegistry
reactiveAdapterRegistry
()
{
return
this
.
adapterRegistry
;
}
@Override
...
...
@@ -102,8 +102,8 @@ final class DefaultRSocketStrategies implements RSocketStrategies {
}
@Override
public
ReactiveAdapterRegistry
reactiveAdapterRegistry
()
{
return
this
.
adapterRegistry
;
public
MetadataExtractor
metadataExtractor
()
{
return
this
.
metadataExtractor
;
}
...
...
@@ -119,39 +119,36 @@ final class DefaultRSocketStrategies implements RSocketStrategies {
@Nullable
private
RouteMatcher
routeMatcher
;
@Nullable
private
MetadataExtractor
metadataExtractor
;
@Nullable
private
ReactiveAdapterRegistry
adapterRegistry
=
ReactiveAdapterRegistry
.
getSharedInstance
();
@Nullable
private
DataBufferFactory
bufferFactory
;
@Nullable
private
MetadataExtractor
metadataExtractor
;
DefaultRSocketStrategiesBuilder
()
{
this
.
encoders
.
add
(
CharSequenceEncoder
.
allMimeTypes
());
this
.
encoders
.
add
(
new
ByteBufferEncoder
());
this
.
encoders
.
add
(
new
ByteArrayEncoder
());
this
.
encoders
.
add
(
new
DataBufferEncoder
());
// Order of decoders may be significant for default data MimeType
// selection in RSocketRequester.Builder
this
.
decoders
.
add
(
StringDecoder
.
allMimeTypes
());
this
.
decoders
.
add
(
new
ByteBufferDecoder
());
this
.
decoders
.
add
(
new
ByteArrayDecoder
());
this
.
decoders
.
add
(
new
DataBufferDecoder
());
this
.
encoders
.
add
(
CharSequenceEncoder
.
allMimeTypes
());
this
.
encoders
.
add
(
new
ByteBufferEncoder
());
this
.
encoders
.
add
(
new
ByteArrayEncoder
());
this
.
encoders
.
add
(
new
DataBufferEncoder
());
}
DefaultRSocketStrategiesBuilder
(
RSocketStrategies
other
)
{
this
.
encoders
.
addAll
(
other
.
encoders
());
this
.
decoders
.
addAll
(
other
.
decoders
());
this
.
routeMatcher
=
other
.
routeMatcher
();
this
.
metadataExtractor
=
other
.
metadataExtractor
();
this
.
adapterRegistry
=
other
.
reactiveAdapterRegistry
();
this
.
bufferFactory
=
other
.
dataBufferFactory
();
this
.
metadataExtractor
=
other
.
metadataExtractor
();
}
...
...
@@ -185,12 +182,6 @@ final class DefaultRSocketStrategies implements RSocketStrategies {
return
this
;
}
@Override
public
Builder
metadataExtractor
(
@Nullable
MetadataExtractor
metadataExtractor
)
{
this
.
metadataExtractor
=
metadataExtractor
;
return
this
;
}
@Override
public
Builder
reactiveAdapterStrategy
(
@Nullable
ReactiveAdapterRegistry
registry
)
{
this
.
adapterRegistry
=
registry
;
...
...
@@ -204,21 +195,26 @@ final class DefaultRSocketStrategies implements RSocketStrategies {
}
@Override
public
RSocketStrategies
build
()
{
public
Builder
metadataExtractor
(
@Nullable
MetadataExtractor
metadataExtractor
)
{
this
.
metadataExtractor
=
metadataExtractor
;
return
this
;
}
RouteMatcher
matcher
=
this
.
routeMatcher
!=
null
?
this
.
routeMatcher
:
initRouteMatcher
();
@Override
public
RSocketStrategies
build
()
{
RouteMatcher
matcher
=
(
this
.
routeMatcher
!=
null
?
this
.
routeMatcher
:
initRouteMatcher
());
MetadataExtractor
extractor
=
this
.
metadataExtractor
!=
null
?
this
.
metadataExtractor
:
new
DefaultMetadataExtractor
(
this
.
decoders
);
ReactiveAdapterRegistry
registry
=
(
this
.
adapterRegistry
!=
null
?
this
.
adapterRegistry
:
ReactiveAdapterRegistry
.
getSharedInstance
()
);
DataBufferFactory
factory
=
this
.
bufferFactory
!=
null
?
this
.
bufferFactory
:
new
NettyDataBufferFactory
(
PooledByteBufAllocator
.
DEFAULT
);
DataBufferFactory
factory
=
(
this
.
bufferFactory
!=
null
?
this
.
bufferFactory
:
new
NettyDataBufferFactory
(
PooledByteBufAllocator
.
DEFAULT
)
)
;
ReactiveAdapterRegistry
registry
=
this
.
adapterRegistry
!=
null
?
this
.
adapterRegistry
:
ReactiveAdapterRegistry
.
getSharedInstance
(
);
MetadataExtractor
extractor
=
(
this
.
metadataExtractor
!=
null
?
this
.
metadataExtractor
:
new
DefaultMetadataExtractor
(
this
.
decoders
)
);
return
new
DefaultRSocketStrategies
(
this
.
encoders
,
this
.
decoders
,
matcher
,
extractor
,
factory
,
registry
);
this
.
encoders
,
this
.
decoders
,
matcher
,
registry
,
factory
,
extractor
);
}
private
RouteMatcher
initRouteMatcher
()
{
...
...
spring-messaging/src/main/java/org/springframework/messaging/rsocket/RSocketStrategies.java
浏览文件 @
e6f86c5c
...
...
@@ -98,9 +98,10 @@ public interface RSocketStrategies {
RouteMatcher
routeMatcher
();
/**
* Return the configured {@link Builder#metadataExtractor(MetadataExtractor)}.
* Return the configured
* {@link Builder#reactiveAdapterStrategy(ReactiveAdapterRegistry) reactiveAdapterRegistry}.
*/
MetadataExtractor
metadataExtractor
();
ReactiveAdapterRegistry
reactiveAdapterRegistry
();
/**
* Return the configured
...
...
@@ -109,10 +110,9 @@ public interface RSocketStrategies {
DataBufferFactory
dataBufferFactory
();
/**
* Return the configured
* {@link Builder#reactiveAdapterStrategy(ReactiveAdapterRegistry) reactiveAdapterRegistry}.
* Return the configured {@link Builder#metadataExtractor(MetadataExtractor)}.
*/
ReactiveAdapterRegistry
reactiveAdapterRegistry
();
MetadataExtractor
metadataExtractor
();
/**
* Return a builder to create a new {@link RSocketStrategies} instance
...
...
@@ -184,16 +184,6 @@ public interface RSocketStrategies {
*/
Builder
routeMatcher
(
@Nullable
RouteMatcher
routeMatcher
);
/**
* Configure a {@link MetadataExtractor} to extract the route along with
* other metadata. This option is applicable to client or server
* responders.
* <p>By default this is {@link DefaultMetadataExtractor} created with
* the {@link #decoder(Decoder[]) configured} decoders and extracting a
* route from {@code "message/x.rsocket.routing.v0"} metadata.
*/
Builder
metadataExtractor
(
@Nullable
MetadataExtractor
metadataExtractor
);
/**
* Configure the registry for reactive type support. This can be used to
* to adapt to, and/or determine the semantics of a given
...
...
@@ -219,6 +209,16 @@ public interface RSocketStrategies {
*/
Builder
dataBufferFactory
(
@Nullable
DataBufferFactory
bufferFactory
);
/**
* Configure a {@link MetadataExtractor} to extract the route along with
* other metadata. This option is applicable to client or server
* responders.
* <p>By default this is {@link DefaultMetadataExtractor} created with
* the {@link #decoder(Decoder[]) configured} decoders and extracting a
* route from {@code "message/x.rsocket.routing.v0"} metadata.
*/
Builder
metadataExtractor
(
@Nullable
MetadataExtractor
metadataExtractor
);
/**
* Build the {@code RSocketStrategies} instance.
*/
...
...
spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/support/MessagingRSocket.java
浏览文件 @
e6f86c5c
...
...
@@ -77,15 +77,15 @@ class MessagingRSocket extends AbstractRSocket {
MessagingRSocket
(
MimeType
dataMimeType
,
MimeType
metadataMimeType
,
MetadataExtractor
metadataExtractor
,
RSocketRequester
requester
,
ReactiveMessageHandler
messageHandler
,
R
outeMatcher
routeMatcher
,
R
SocketStrategies
strategies
)
{
RSocketRequester
requester
,
ReactiveMessageHandler
messageHandler
,
RouteMatcher
routeMatcher
,
RSocketStrategies
strategies
)
{
Assert
.
notNull
(
dataMimeType
,
"'dataMimeType' is required"
);
Assert
.
notNull
(
metadataMimeType
,
"'metadataMimeType' is required"
);
Assert
.
notNull
(
metadataExtractor
,
"
'metadataExtractor'
is required"
);
Assert
.
notNull
(
requester
,
"
'requester'
is required"
);
Assert
.
notNull
(
messageHandler
,
"
'messageHandler'
is required"
);
Assert
.
notNull
(
routeMatcher
,
"
'routeMatcher'
is required"
);
Assert
.
notNull
(
metadataExtractor
,
"
MetadataExtractor
is required"
);
Assert
.
notNull
(
requester
,
"
RSocketRequester
is required"
);
Assert
.
notNull
(
messageHandler
,
"
ReactiveMessageHandler
is required"
);
Assert
.
notNull
(
routeMatcher
,
"
RouteMatcher
is required"
);
Assert
.
notNull
(
strategies
,
"RSocketStrategies is required"
);
this
.
dataMimeType
=
dataMimeType
;
...
...
spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/support/RSocketMessageHandler.java
浏览文件 @
e6f86c5c
...
...
@@ -73,9 +73,7 @@ public class RSocketMessageHandler extends MessageMappingMessageHandler {
private
final
List
<
Encoder
<?>>
encoders
=
new
ArrayList
<>();
private
MetadataExtractor
metadataExtractor
;
private
RSocketStrategies
strategies
;
private
RSocketStrategies
strategies
=
RSocketStrategies
.
create
();
@Nullable
private
MimeType
defaultDataMimeType
;
...
...
@@ -84,29 +82,9 @@ public class RSocketMessageHandler extends MessageMappingMessageHandler {
public
RSocketMessageHandler
()
{
setRSocketStrategies
(
RSocketStrategies
.
create
()
);
setRSocketStrategies
(
this
.
strategies
);
}
/**
* {@inheritDoc}
* <p>When {@link #setRSocketStrategies(RSocketStrategies) rsocketStrategies}
* is set, this property is re-initialized with the decoders in it, and
* likewise when this property is set the {@code RSocketStrategies} are
* mutated to change the decoders in them.
* <p>By default this is set to the
* {@link RSocketStrategies.Builder#decoder(Decoder[]) defaults} from
* {@code RSocketStrategies}.
*/
@Override
public
void
setDecoders
(
List
<?
extends
Decoder
<?>>
decoders
)
{
super
.
setDecoders
(
decoders
);
this
.
strategies
=
this
.
strategies
.
mutate
()
.
decoders
(
list
->
{
list
.
clear
();
list
.
addAll
(
decoders
);
})
.
build
();
}
/**
* Configure the encoders to use for encoding handler method return values.
...
...
@@ -136,6 +114,27 @@ public class RSocketMessageHandler extends MessageMappingMessageHandler {
return
this
.
encoders
;
}
/**
* {@inheritDoc}
* <p>When {@link #setRSocketStrategies(RSocketStrategies) rsocketStrategies}
* is set, this property is re-initialized with the decoders in it, and
* likewise when this property is set the {@code RSocketStrategies} are
* mutated to change the decoders in them.
* <p>By default this is set to the
* {@link RSocketStrategies.Builder#decoder(Decoder[]) defaults} from
* {@code RSocketStrategies}.
*/
@Override
public
void
setDecoders
(
List
<?
extends
Decoder
<?>>
decoders
)
{
super
.
setDecoders
(
decoders
);
this
.
strategies
=
this
.
strategies
.
mutate
()
.
decoders
(
list
->
{
list
.
clear
();
list
.
addAll
(
decoders
);
})
.
build
();
}
/**
* {@inheritDoc}
* <p>When {@link #setRSocketStrategies(RSocketStrategies) rsocketStrategies}
...
...
@@ -147,7 +146,7 @@ public class RSocketMessageHandler extends MessageMappingMessageHandler {
* from {@code RSocketStrategies}.
*/
@Override
public
void
setRouteMatcher
(
RouteMatcher
routeMatcher
)
{
public
void
setRouteMatcher
(
@Nullable
RouteMatcher
routeMatcher
)
{
super
.
setRouteMatcher
(
routeMatcher
);
this
.
strategies
=
this
.
strategies
.
mutate
().
routeMatcher
(
routeMatcher
).
build
();
}
...
...
@@ -181,17 +180,14 @@ public class RSocketMessageHandler extends MessageMappingMessageHandler {
* @param extractor the extractor to use
*/
public
void
setMetadataExtractor
(
MetadataExtractor
extractor
)
{
this
.
metadataExtractor
=
extractor
;
this
.
strategies
=
this
.
strategies
.
mutate
().
metadataExtractor
(
this
.
metadataExtractor
).
build
();
this
.
strategies
=
this
.
strategies
.
mutate
().
metadataExtractor
(
extractor
).
build
();
}
/**
* Return the configured {@link #setMetadataExtractor MetadataExtractor}.
* This may be {@code null} before {@link #afterPropertiesSet()}.
*/
@Nullable
public
MetadataExtractor
getMetadataExtractor
()
{
return
this
.
metadataExtractor
;
return
this
.
strategies
.
metadataExtractor
()
;
}
/**
...
...
@@ -210,11 +206,11 @@ public class RSocketMessageHandler extends MessageMappingMessageHandler {
*/
public
void
setRSocketStrategies
(
RSocketStrategies
rsocketStrategies
)
{
this
.
strategies
=
rsocketStrategies
;
setDecoders
(
this
.
strategies
.
decoders
()
);
setEncoders
(
this
.
strategies
.
encoders
());
s
etRouteMatcher
(
this
.
strategies
.
routeMatcher
());
s
etMetadataExtractor
(
this
.
strategies
.
metadataExtracto
r
());
setReactiveAdapterRegistry
(
this
.
strategies
.
reactiveAdapterRegistry
());
this
.
encoders
.
clear
(
);
this
.
encoders
.
addAll
(
this
.
strategies
.
encoders
());
s
uper
.
setDecoders
(
this
.
strategies
.
decoders
());
s
uper
.
setRouteMatcher
(
this
.
strategies
.
routeMatche
r
());
s
uper
.
s
etReactiveAdapterRegistry
(
this
.
strategies
.
reactiveAdapterRegistry
());
}
/**
...
...
@@ -284,19 +280,19 @@ public class RSocketMessageHandler extends MessageMappingMessageHandler {
@Override
@Nullable
protected
CompositeMessageCondition
getCondition
(
AnnotatedElement
element
)
{
MessageMapping
ann
ot
1
=
AnnotatedElementUtils
.
findMergedAnnotation
(
element
,
MessageMapping
.
class
);
if
(
ann
ot1
!=
null
&&
annot
1
.
value
().
length
>
0
)
{
String
[]
patterns
=
processDestinations
(
ann
ot
1
.
value
());
MessageMapping
ann1
=
AnnotatedElementUtils
.
findMergedAnnotation
(
element
,
MessageMapping
.
class
);
if
(
ann
1
!=
null
&&
ann
1
.
value
().
length
>
0
)
{
String
[]
patterns
=
processDestinations
(
ann1
.
value
());
return
new
CompositeMessageCondition
(
RSocketFrameTypeMessageCondition
.
REQUEST_CONDITION
,
new
DestinationPatternsMessageCondition
(
patterns
,
get
RouteMatcher
()));
new
DestinationPatternsMessageCondition
(
patterns
,
obtain
RouteMatcher
()));
}
ConnectMapping
ann
ot
2
=
AnnotatedElementUtils
.
findMergedAnnotation
(
element
,
ConnectMapping
.
class
);
if
(
ann
ot
2
!=
null
)
{
String
[]
patterns
=
processDestinations
(
ann
ot
2
.
value
());
ConnectMapping
ann2
=
AnnotatedElementUtils
.
findMergedAnnotation
(
element
,
ConnectMapping
.
class
);
if
(
ann2
!=
null
)
{
String
[]
patterns
=
processDestinations
(
ann2
.
value
());
return
new
CompositeMessageCondition
(
RSocketFrameTypeMessageCondition
.
CONNECT_CONDITION
,
new
DestinationPatternsMessageCondition
(
patterns
,
get
RouteMatcher
()));
new
DestinationPatternsMessageCondition
(
patterns
,
obtain
RouteMatcher
()));
}
return
null
;
}
...
...
@@ -362,22 +358,18 @@ public class RSocketMessageHandler extends MessageMappingMessageHandler {
}
private
MessagingRSocket
createResponder
(
ConnectionSetupPayload
setupPayload
,
RSocket
rsocket
)
{
String
s
=
setupPayload
.
dataMimeType
();
MimeType
dataMimeType
=
StringUtils
.
hasText
(
s
)
?
MimeTypeUtils
.
parseMimeType
(
s
)
:
this
.
defaultDataMimeType
;
String
s
tr
=
setupPayload
.
dataMimeType
();
MimeType
dataMimeType
=
StringUtils
.
hasText
(
s
tr
)
?
MimeTypeUtils
.
parseMimeType
(
str
)
:
this
.
defaultDataMimeType
;
Assert
.
notNull
(
dataMimeType
,
"No `dataMimeType` in ConnectionSetupPayload and no default value"
);
Assert
.
isTrue
(
isDataMimeTypeSupported
(
dataMimeType
),
"Data MimeType '"
+
dataMimeType
+
"' not supported"
);
s
=
setupPayload
.
metadataMimeType
();
MimeType
metaMimeType
=
StringUtils
.
hasText
(
s
)
?
MimeTypeUtils
.
parseMimeType
(
s
)
:
this
.
defaultMetadataMimeType
;
s
tr
=
setupPayload
.
metadataMimeType
();
MimeType
metaMimeType
=
StringUtils
.
hasText
(
s
tr
)
?
MimeTypeUtils
.
parseMimeType
(
str
)
:
this
.
defaultMetadataMimeType
;
Assert
.
notNull
(
metaMimeType
,
"No `metadataMimeType` in ConnectionSetupPayload and no default value"
);
RSocketRequester
requester
=
RSocketRequester
.
wrap
(
rsocket
,
dataMimeType
,
metaMimeType
,
this
.
strategies
);
Assert
.
state
(
getRouteMatcher
()
!=
null
,
()
->
"No RouteMatcher. Was afterPropertiesSet not called?"
);
return
new
MessagingRSocket
(
dataMimeType
,
metaMimeType
,
this
.
metadataExtractor
,
requester
,
this
,
getRouteMatcher
(),
this
.
strategies
);
RSocketRequester
requester
=
RSocketRequester
.
wrap
(
rsocket
,
dataMimeType
,
metaMimeType
,
this
.
strategies
);
return
new
MessagingRSocket
(
dataMimeType
,
metaMimeType
,
getMetadataExtractor
(),
requester
,
this
,
obtainRouteMatcher
(),
this
.
strategies
);
}
private
boolean
isDataMimeTypeSupported
(
MimeType
dataMimeType
)
{
...
...
spring-test/src/main/java/org/springframework/test/context/jdbc/SqlScriptsTestExecutionListener.java
浏览文件 @
e6f86c5c
...
...
@@ -163,6 +163,7 @@ public class SqlScriptsTestExecutionListener extends AbstractTestExecutionListen
/**
* Get the {@code @SqlMergeMode} annotation declared on the supplied {@code element}.
*/
@Nullable
private
SqlMergeMode
getSqlMergeModeFor
(
AnnotatedElement
element
)
{
return
AnnotatedElementUtils
.
findMergedAnnotation
(
element
,
SqlMergeMode
.
class
);
}
...
...
spring-test/src/main/java/org/springframework/test/context/support/TestPropertySourceAttributes.java
浏览文件 @
e6f86c5c
...
...
@@ -32,6 +32,7 @@ import org.springframework.util.Assert;
import
org.springframework.util.ClassUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ResourceUtils
;
import
org.springframework.util.StringUtils
;
/**
* {@code TestPropertySourceAttributes} encapsulates attributes declared
...
...
@@ -196,7 +197,7 @@ class TestPropertySourceAttributes {
* @see TestPropertySource#locations
*/
String
[]
getLocations
()
{
return
this
.
locations
.
toArray
(
new
String
[
0
]
);
return
StringUtils
.
toStringArray
(
this
.
locations
);
}
/**
...
...
@@ -217,7 +218,7 @@ class TestPropertySourceAttributes {
* @see TestPropertySource#properties
*/
String
[]
getProperties
()
{
return
this
.
properties
.
toArray
(
new
String
[
0
]
);
return
StringUtils
.
toStringArray
(
this
.
properties
);
}
/**
...
...
@@ -245,7 +246,9 @@ class TestPropertySourceAttributes {
}
private
static
Class
<?>
declaringClass
(
MergedAnnotation
<?>
mergedAnnotation
)
{
return
(
Class
<?>)
mergedAnnotation
.
getSource
();
Object
source
=
mergedAnnotation
.
getSource
();
Assert
.
state
(
source
instanceof
Class
,
"No source class available"
);
return
(
Class
<?>)
source
;
}
}
spring-test/src/main/java/org/springframework/test/context/support/TestPropertySourceUtils.java
浏览文件 @
e6f86c5c
...
...
@@ -130,9 +130,7 @@ public abstract class TestPropertySourceUtils {
logger
.
trace
(
String
.
format
(
"Processing inlined properties for TestPropertySource attributes %s"
,
attrs
));
}
String
[]
attrProps
=
attrs
.
getProperties
();
if
(
attrProps
!=
null
)
{
properties
.
addAll
(
0
,
Arrays
.
asList
(
attrProps
));
}
properties
.
addAll
(
0
,
Arrays
.
asList
(
attrProps
));
if
(!
attrs
.
isInheritProperties
())
{
break
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录