Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
9b7af8b5
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,发现更多精彩内容 >>
提交
9b7af8b5
编写于
11月 05, 2017
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polishing
上级
07b479e2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
24 addition
and
23 deletion
+24
-23
spring-core/src/main/java/org/springframework/util/concurrent/DelegatingCompletableFuture.java
...ramework/util/concurrent/DelegatingCompletableFuture.java
+5
-0
spring-messaging/src/main/java/org/springframework/messaging/core/GenericMessagingTemplate.java
...ingframework/messaging/core/GenericMessagingTemplate.java
+7
-8
src/docs/asciidoc/languages/kotlin.adoc
src/docs/asciidoc/languages/kotlin.adoc
+12
-15
未找到文件。
spring-core/src/main/java/org/springframework/util/concurrent/DelegatingCompletableFuture.java
浏览文件 @
9b7af8b5
...
...
@@ -19,6 +19,8 @@ package org.springframework.util.concurrent;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.Future
;
import
org.springframework.util.Assert
;
/**
* Extension of {@link CompletableFuture} which allows for cancelling
* a delegate along with the {@link CompletableFuture} itself.
...
...
@@ -30,10 +32,13 @@ class DelegatingCompletableFuture<T> extends CompletableFuture<T> {
private
final
Future
<
T
>
delegate
;
public
DelegatingCompletableFuture
(
Future
<
T
>
delegate
)
{
Assert
.
notNull
(
delegate
,
"Delegate must not be null"
);
this
.
delegate
=
delegate
;
}
@Override
public
boolean
cancel
(
boolean
mayInterruptIfRunning
)
{
boolean
result
=
this
.
delegate
.
cancel
(
mayInterruptIfRunning
);
...
...
spring-messaging/src/main/java/org/springframework/messaging/core/GenericMessagingTemplate.java
浏览文件 @
9b7af8b5
...
...
@@ -97,12 +97,10 @@ public class GenericMessagingTemplate extends AbstractDestinationResolvingMessag
return
this
.
receiveTimeout
;
}
/**
* Set the name of the header used to determine the send timeout (if present).
* Default {@value #DEFAULT_SEND_TIMEOUT_HEADER}.
* The header is removed before sending the message to avoid propagation.
* @param sendTimeoutHeader the sendTimeoutHeader to set
* <p>The header is removed before sending the message to avoid propagation.
* @since 5.0
*/
public
void
setSendTimeoutHeader
(
String
sendTimeoutHeader
)
{
...
...
@@ -111,18 +109,17 @@ public class GenericMessagingTemplate extends AbstractDestinationResolvingMessag
}
/**
*
@return the configured sendTimeoutH
eader.
*
Return the configured send-timeout h
eader.
* @since 5.0
*/
public
String
getSendTimeoutHeader
()
{
return
sendTimeoutHeader
;
return
this
.
sendTimeoutHeader
;
}
/**
* Set the name of the header used to determine the send timeout (if present).
* Default {@value #DEFAULT_RECEIVE_TIMEOUT_HEADER}.
* The header is removed before sending the message to avoid propagation.
* @param receiveTimeoutHeader the receiveTimeoutHeader to set
* @since 5.0
*/
public
void
setReceiveTimeoutHeader
(
String
receiveTimeoutHeader
)
{
...
...
@@ -131,11 +128,11 @@ public class GenericMessagingTemplate extends AbstractDestinationResolvingMessag
}
/**
*
@return the configured receiveTimeoutHeader
*
Return the configured receive-timeout header.
* @since 5.0
*/
public
String
getReceiveTimeoutHeader
()
{
return
receiveTimeoutHeader
;
return
this
.
receiveTimeoutHeader
;
}
/**
...
...
@@ -157,6 +154,7 @@ public class GenericMessagingTemplate extends AbstractDestinationResolvingMessag
setDestinationResolver
(
new
BeanFactoryMessageChannelDestinationResolver
(
beanFactory
));
}
@Override
protected
final
void
doSend
(
MessageChannel
channel
,
Message
<?>
message
)
{
doSend
(
channel
,
message
,
sendTimeout
(
message
));
...
...
@@ -267,6 +265,7 @@ public class GenericMessagingTemplate extends AbstractDestinationResolvingMessag
}
}
/**
* A temporary channel for receiving a single reply message.
*/
...
...
src/docs/asciidoc/languages/kotlin.adoc
浏览文件 @
9b7af8b5
...
...
@@ -391,9 +391,8 @@ you will be able to write your Kotlin beans without any additional `open` keywor
=== Using immutable class instances for persistence
In Kotlin, it is very convenient and considered best practice to declare
read-only properties within the primary constructor, as in the following
example:
In Kotlin, it is very convenient and considered best practice to declare read-only properties
within the primary constructor, as in the following example:
[source,kotlin]
----
...
...
@@ -401,41 +400,39 @@ class Person(val name: String, val age: Int)
----
You can optionally add https://kotlinlang.org/docs/reference/data-classes.html[the `data` keyword]
to make the compiler automatically derive
s the following members from all properties
declared
in the primary constructor:
to make the compiler automatically derive
the following members from all properties declared
in the primary constructor:
* equals()/hashCode() pair
* toString() of the form "User(name=John, age=42)"
* componentN() functions corresponding to the properties in their order of declaration
* copy() function
This allows to change easily just one of the properties even if `User` properties are read-only:
his allows us to write:
This allows for easy changes to individual properties even if `Person` properties are read-only:
[source,kotlin]
----
data class Person(val name: String, val age: Int)
val jack =
User
(name = "Jack", age = 1)
val jack =
Person
(name = "Jack", age = 1)
val olderJack = jack.copy(age = 2)
----
But some persistence technologies like
JPA require a default constructor, preventing this
Common persistence technologies such as
JPA require a default constructor, preventing this
kind of design. Fortunately, there is now a workaround for this
https://stackoverflow.com/questions/32038177/kotlin-with-jpa-default-constructor-hell["default constructor hell"]
since Kotlin provides a https://kotlinlang.org/docs/reference/compiler-plugins.html#kotlin-jpa-compiler-plugin[kotlin-jpa]
plugin which generates synthetic no-arg constructor for classes annotated with JPA annotations.
If you need to leverage this kind of mechanism for other persistence technologies, you can
configur
e https://kotlinlang.org/docs/reference/compiler-plugins.html#how-to-use-no-arg-plugin[kotlin-noarg]
If you need to leverage this kind of mechanism for other persistence technologies, you can
configure
th
e https://kotlinlang.org/docs/reference/compiler-plugins.html#how-to-use-no-arg-plugin[kotlin-noarg]
plugin.
[NOTE]
====
As of
Kay release train, Spring Data supports Kotlin immutable class instances
and should not requir
e `kotlin-noarg` plugin if the module leverages Spring Data object
mapping
(like with MongoDB, Redis, Cassandra, etc.
).
As of
the Kay release train, Spring Data supports Kotlin immutable class instances and
does not require th
e `kotlin-noarg` plugin if the module leverages Spring Data object
mapping
s (like with MongoDB, Redis, Cassandra, etc
).
====
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录