Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
cf0a9167
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 搜索 >>
提交
cf0a9167
编写于
5月 09, 2015
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Consistent non-public AsyncRequestInterceptor classes
Issue: SPR-11694
上级
f9c39103
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
36 addition
and
31 deletion
+36
-31
spring-orm-hibernate4/src/main/java/org/springframework/orm/hibernate4/support/AsyncRequestInterceptor.java
...ework/orm/hibernate4/support/AsyncRequestInterceptor.java
+8
-7
spring-orm/src/main/java/org/springframework/orm/hibernate3/support/AsyncRequestInterceptor.java
...ework/orm/hibernate3/support/AsyncRequestInterceptor.java
+18
-9
spring-orm/src/main/java/org/springframework/orm/jpa/support/AsyncRequestInterceptor.java
...ingframework/orm/jpa/support/AsyncRequestInterceptor.java
+7
-6
spring-web/src/main/java/org/springframework/web/context/request/async/DeferredResultProcessingInterceptor.java
...xt/request/async/DeferredResultProcessingInterceptor.java
+3
-9
未找到文件。
spring-orm-hibernate4/src/main/java/org/springframework/orm/hibernate4/support/AsyncRequestInterceptor.java
浏览文件 @
cf0a9167
/*
* Copyright 2002-201
4
the original author or authors.
* Copyright 2002-201
5
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.
...
...
@@ -16,7 +16,6 @@
package
org.springframework.orm.hibernate4.support
;
import
java.util.concurrent.Callable
;
import
org.apache.commons.logging.Log
;
...
...
@@ -42,8 +41,7 @@ import org.springframework.web.context.request.async.DeferredResultProcessingInt
* @author Rossen Stoyanchev
* @since 3.2.5
*/
public
class
AsyncRequestInterceptor
extends
CallableProcessingInterceptorAdapter
implements
DeferredResultProcessingInterceptor
{
class
AsyncRequestInterceptor
extends
CallableProcessingInterceptorAdapter
implements
DeferredResultProcessingInterceptor
{
private
static
final
Log
logger
=
LogFactory
.
getLog
(
AsyncRequestInterceptor
.
class
);
...
...
@@ -78,7 +76,7 @@ public class AsyncRequestInterceptor extends CallableProcessingInterceptorAdapte
@Override
public
<
T
>
Object
handleTimeout
(
NativeWebRequest
request
,
Callable
<
T
>
task
)
{
this
.
timeoutInProgress
=
true
;
return
RESULT_NONE
;
// give other interceptors a chance to handle the timeout
return
RESULT_NONE
;
// give other interceptors a chance to handle the timeout
}
@Override
...
...
@@ -89,26 +87,29 @@ public class AsyncRequestInterceptor extends CallableProcessingInterceptorAdapte
private
void
closeAfterTimeout
()
{
if
(
this
.
timeoutInProgress
)
{
logger
.
debug
(
"Closing Hibernate Session after async request timeout"
);
SessionFactoryUtils
.
closeSession
(
sessionHolder
.
getSession
());
SessionFactoryUtils
.
closeSession
(
this
.
sessionHolder
.
getSession
());
}
}
// Implementation of DeferredResultProcessingInterceptor methods
@Override
public
<
T
>
void
beforeConcurrentHandling
(
NativeWebRequest
request
,
DeferredResult
<
T
>
deferredResult
)
{
}
@Override
public
<
T
>
void
preProcess
(
NativeWebRequest
request
,
DeferredResult
<
T
>
deferredResult
)
{
}
@Override
public
<
T
>
void
postProcess
(
NativeWebRequest
request
,
DeferredResult
<
T
>
deferredResult
,
Object
result
)
{
}
@Override
public
<
T
>
boolean
handleTimeout
(
NativeWebRequest
request
,
DeferredResult
<
T
>
deferredResult
)
{
this
.
timeoutInProgress
=
true
;
return
true
;
// give other interceptors a chance to handle the timeout
return
true
;
// give other interceptors a chance to handle the timeout
}
@Override
...
...
spring-orm/src/main/java/org/springframework/orm/hibernate3/support/AsyncRequestInterceptor.java
浏览文件 @
cf0a9167
/*
* Copyright 2002-201
3
the original author or authors.
* Copyright 2002-201
5
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,8 +41,7 @@ import org.springframework.web.context.request.async.DeferredResultProcessingInt
* @author Rossen Stoyanchev
* @since 3.2.5
*/
class
AsyncRequestInterceptor
extends
CallableProcessingInterceptorAdapter
implements
DeferredResultProcessingInterceptor
{
class
AsyncRequestInterceptor
extends
CallableProcessingInterceptorAdapter
implements
DeferredResultProcessingInterceptor
{
private
static
final
Log
logger
=
LogFactory
.
getLog
(
AsyncRequestInterceptor
.
class
);
...
...
@@ -58,6 +57,7 @@ class AsyncRequestInterceptor extends CallableProcessingInterceptorAdapter
this
.
sessionHolder
=
sessionHolder
;
}
@Override
public
<
T
>
void
preProcess
(
NativeWebRequest
request
,
Callable
<
T
>
task
)
{
bindSession
();
...
...
@@ -76,7 +76,7 @@ class AsyncRequestInterceptor extends CallableProcessingInterceptorAdapter
@Override
public
<
T
>
Object
handleTimeout
(
NativeWebRequest
request
,
Callable
<
T
>
task
)
{
this
.
timeoutInProgress
=
true
;
return
RESULT_NONE
;
// give other interceptors a chance to handle the timeout
return
RESULT_NONE
;
// give other interceptors a chance to handle the timeout
}
@Override
...
...
@@ -87,20 +87,29 @@ class AsyncRequestInterceptor extends CallableProcessingInterceptorAdapter
private
void
closeAfterTimeout
()
{
if
(
this
.
timeoutInProgress
)
{
logger
.
debug
(
"Closing Hibernate Session after async request timeout"
);
SessionFactoryUtils
.
closeSession
(
sessionHolder
.
getSession
());
SessionFactoryUtils
.
closeSession
(
this
.
sessionHolder
.
getSession
());
}
}
// Implementation of DeferredResultProcessingInterceptor methods
public
<
T
>
void
beforeConcurrentHandling
(
NativeWebRequest
request
,
DeferredResult
<
T
>
deferredResult
)
{}
public
<
T
>
void
preProcess
(
NativeWebRequest
request
,
DeferredResult
<
T
>
deferredResult
)
{}
public
<
T
>
void
postProcess
(
NativeWebRequest
request
,
DeferredResult
<
T
>
deferredResult
,
Object
result
)
{}
@Override
public
<
T
>
void
beforeConcurrentHandling
(
NativeWebRequest
request
,
DeferredResult
<
T
>
deferredResult
)
{
}
@Override
public
<
T
>
void
preProcess
(
NativeWebRequest
request
,
DeferredResult
<
T
>
deferredResult
)
{
}
@Override
public
<
T
>
void
postProcess
(
NativeWebRequest
request
,
DeferredResult
<
T
>
deferredResult
,
Object
result
)
{
}
@Override
public
<
T
>
boolean
handleTimeout
(
NativeWebRequest
request
,
DeferredResult
<
T
>
deferredResult
)
{
this
.
timeoutInProgress
=
true
;
return
true
;
// give other interceptors a chance to handle the timeout
return
true
;
// give other interceptors a chance to handle the timeout
}
@Override
...
...
spring-orm/src/main/java/org/springframework/orm/jpa/support/AsyncRequestInterceptor.java
浏览文件 @
cf0a9167
/*
* Copyright 2002-201
4
the original author or authors.
* Copyright 2002-201
5
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.
...
...
@@ -16,7 +16,6 @@
package
org.springframework.orm.jpa.support
;
import
java.util.concurrent.Callable
;
import
javax.persistence.EntityManagerFactory
;
...
...
@@ -42,8 +41,7 @@ import org.springframework.web.context.request.async.DeferredResultProcessingInt
* @author Rossen Stoyanchev
* @since 3.2.5
*/
public
class
AsyncRequestInterceptor
extends
CallableProcessingInterceptorAdapter
implements
DeferredResultProcessingInterceptor
{
class
AsyncRequestInterceptor
extends
CallableProcessingInterceptorAdapter
implements
DeferredResultProcessingInterceptor
{
private
static
final
Log
logger
=
LogFactory
.
getLog
(
AsyncRequestInterceptor
.
class
);
...
...
@@ -78,7 +76,7 @@ public class AsyncRequestInterceptor extends CallableProcessingInterceptorAdapte
@Override
public
<
T
>
Object
handleTimeout
(
NativeWebRequest
request
,
Callable
<
T
>
task
)
{
this
.
timeoutInProgress
=
true
;
return
RESULT_NONE
;
// give other interceptors a chance to handle the timeout
return
RESULT_NONE
;
// give other interceptors a chance to handle the timeout
}
@Override
...
...
@@ -96,19 +94,22 @@ public class AsyncRequestInterceptor extends CallableProcessingInterceptorAdapte
// Implementation of DeferredResultProcessingInterceptor methods
@Override
public
<
T
>
void
beforeConcurrentHandling
(
NativeWebRequest
request
,
DeferredResult
<
T
>
deferredResult
)
{
}
@Override
public
<
T
>
void
preProcess
(
NativeWebRequest
request
,
DeferredResult
<
T
>
deferredResult
)
{
}
@Override
public
<
T
>
void
postProcess
(
NativeWebRequest
request
,
DeferredResult
<
T
>
deferredResult
,
Object
result
)
{
}
@Override
public
<
T
>
boolean
handleTimeout
(
NativeWebRequest
request
,
DeferredResult
<
T
>
deferredResult
)
{
this
.
timeoutInProgress
=
true
;
return
true
;
// give other interceptors a chance to handle the timeout
return
true
;
// give other interceptors a chance to handle the timeout
}
@Override
...
...
spring-web/src/main/java/org/springframework/web/context/request/async/DeferredResultProcessingInterceptor.java
浏览文件 @
cf0a9167
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
5
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.
...
...
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.web.context.request.async
;
import
org.springframework.web.context.request.NativeWebRequest
;
...
...
@@ -45,21 +46,18 @@ public interface DeferredResultProcessingInterceptor {
* Invoked immediately before the start of concurrent handling, in the same
* thread that started it. This method may be used to capture state just prior
* to the start of concurrent processing with the given {@code DeferredResult}.
*
* @param request the current request
* @param deferredResult the DeferredResult for the current request
* @throws Exception in case of errors
*/
<
T
>
void
beforeConcurrentHandling
(
NativeWebRequest
request
,
DeferredResult
<
T
>
deferredResult
)
throws
Exception
;
<
T
>
void
beforeConcurrentHandling
(
NativeWebRequest
request
,
DeferredResult
<
T
>
deferredResult
)
throws
Exception
;
/**
* Invoked immediately after the start of concurrent handling, in the same
* thread that started it. This method may be used to detect the start of
* concurrent processing with the given {@code DeferredResult}.
*
* <p>The {@code DeferredResult} may have already been set, for example at
* the time of its creation or by another thread.
*
* @param request the current request
* @param deferredResult the DeferredResult for the current request
* @throws Exception in case of errors
...
...
@@ -71,11 +69,9 @@ public interface DeferredResultProcessingInterceptor {
* {@link DeferredResult#setResult(Object)} or
* {@link DeferredResult#setErrorResult(Object)}, and is also ready to
* handle the concurrent result.
*
* <p>This method may also be invoked after a timeout when the
* {@code DeferredResult} was created with a constructor accepting a default
* timeout result.
*
* @param request the current request
* @param deferredResult the DeferredResult for the current request
* @param concurrentResult the result to which the {@code DeferredResult}
...
...
@@ -88,7 +84,6 @@ public interface DeferredResultProcessingInterceptor {
* the {@code DeferredResult} has been set. Implementations may invoke
* {@link DeferredResult#setResult(Object) setResult} or
* {@link DeferredResult#setErrorResult(Object) setErrorResult} to resume processing.
*
* @param request the current request
* @param deferredResult the DeferredResult for the current request; if the
* {@code DeferredResult} is set, then concurrent processing is resumed and
...
...
@@ -103,7 +98,6 @@ public interface DeferredResultProcessingInterceptor {
* Invoked from a container thread when an async request completed for any
* reason including timeout and network error. This method is useful for
* detecting that a {@code DeferredResult} instance is no longer usable.
*
* @param request the current request
* @param deferredResult the DeferredResult for the current request
* @throws Exception in case of errors
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录