Skip to content

Commit cf0a916

Browse files
committed
Consistent non-public AsyncRequestInterceptor classes
Issue: SPR-11694
1 parent f9c3910 commit cf0a916

File tree

4 files changed

+36
-31
lines changed

4 files changed

+36
-31
lines changed

spring-orm-hibernate4/src/main/java/org/springframework/orm/hibernate4/support/AsyncRequestInterceptor.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,7 +16,6 @@
1616

1717
package org.springframework.orm.hibernate4.support;
1818

19-
2019
import java.util.concurrent.Callable;
2120

2221
import org.apache.commons.logging.Log;
@@ -42,8 +41,7 @@
4241
* @author Rossen Stoyanchev
4342
* @since 3.2.5
4443
*/
45-
public class AsyncRequestInterceptor extends CallableProcessingInterceptorAdapter
46-
implements DeferredResultProcessingInterceptor {
44+
class AsyncRequestInterceptor extends CallableProcessingInterceptorAdapter implements DeferredResultProcessingInterceptor {
4745

4846
private static final Log logger = LogFactory.getLog(AsyncRequestInterceptor.class);
4947

@@ -78,7 +76,7 @@ public <T> void postProcess(NativeWebRequest request, Callable<T> task, Object c
7876
@Override
7977
public <T> Object handleTimeout(NativeWebRequest request, Callable<T> task) {
8078
this.timeoutInProgress = true;
81-
return RESULT_NONE; // give other interceptors a chance to handle the timeout
79+
return RESULT_NONE; // give other interceptors a chance to handle the timeout
8280
}
8381

8482
@Override
@@ -89,26 +87,29 @@ public <T> void afterCompletion(NativeWebRequest request, Callable<T> task) thro
8987
private void closeAfterTimeout() {
9088
if (this.timeoutInProgress) {
9189
logger.debug("Closing Hibernate Session after async request timeout");
92-
SessionFactoryUtils.closeSession(sessionHolder.getSession());
90+
SessionFactoryUtils.closeSession(this.sessionHolder.getSession());
9391
}
9492
}
9593

9694

9795
// Implementation of DeferredResultProcessingInterceptor methods
9896

97+
@Override
9998
public <T> void beforeConcurrentHandling(NativeWebRequest request, DeferredResult<T> deferredResult) {
10099
}
101100

101+
@Override
102102
public <T> void preProcess(NativeWebRequest request, DeferredResult<T> deferredResult) {
103103
}
104104

105+
@Override
105106
public <T> void postProcess(NativeWebRequest request, DeferredResult<T> deferredResult, Object result) {
106107
}
107108

108109
@Override
109110
public <T> boolean handleTimeout(NativeWebRequest request, DeferredResult<T> deferredResult) {
110111
this.timeoutInProgress = true;
111-
return true; // give other interceptors a chance to handle the timeout
112+
return true; // give other interceptors a chance to handle the timeout
112113
}
113114

114115
@Override

spring-orm/src/main/java/org/springframework/orm/hibernate3/support/AsyncRequestInterceptor.java

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -41,8 +41,7 @@
4141
* @author Rossen Stoyanchev
4242
* @since 3.2.5
4343
*/
44-
class AsyncRequestInterceptor extends CallableProcessingInterceptorAdapter
45-
implements DeferredResultProcessingInterceptor {
44+
class AsyncRequestInterceptor extends CallableProcessingInterceptorAdapter implements DeferredResultProcessingInterceptor {
4645

4746
private static final Log logger = LogFactory.getLog(AsyncRequestInterceptor.class);
4847

@@ -58,6 +57,7 @@ public AsyncRequestInterceptor(SessionFactory sessionFactory, SessionHolder sess
5857
this.sessionHolder = sessionHolder;
5958
}
6059

60+
6161
@Override
6262
public <T> void preProcess(NativeWebRequest request, Callable<T> task) {
6363
bindSession();
@@ -76,7 +76,7 @@ public <T> void postProcess(NativeWebRequest request, Callable<T> task, Object c
7676
@Override
7777
public <T> Object handleTimeout(NativeWebRequest request, Callable<T> task) {
7878
this.timeoutInProgress = true;
79-
return RESULT_NONE; // give other interceptors a chance to handle the timeout
79+
return RESULT_NONE; // give other interceptors a chance to handle the timeout
8080
}
8181

8282
@Override
@@ -87,20 +87,29 @@ public <T> void afterCompletion(NativeWebRequest request, Callable<T> task) thro
8787
private void closeAfterTimeout() {
8888
if (this.timeoutInProgress) {
8989
logger.debug("Closing Hibernate Session after async request timeout");
90-
SessionFactoryUtils.closeSession(sessionHolder.getSession());
90+
SessionFactoryUtils.closeSession(this.sessionHolder.getSession());
9191
}
9292
}
9393

94+
9495
// Implementation of DeferredResultProcessingInterceptor methods
9596

96-
public <T> void beforeConcurrentHandling(NativeWebRequest request, DeferredResult<T> deferredResult) {}
97-
public <T> void preProcess(NativeWebRequest request, DeferredResult<T> deferredResult) {}
98-
public <T> void postProcess(NativeWebRequest request, DeferredResult<T> deferredResult, Object result) {}
97+
@Override
98+
public <T> void beforeConcurrentHandling(NativeWebRequest request, DeferredResult<T> deferredResult) {
99+
}
100+
101+
@Override
102+
public <T> void preProcess(NativeWebRequest request, DeferredResult<T> deferredResult) {
103+
}
104+
105+
@Override
106+
public <T> void postProcess(NativeWebRequest request, DeferredResult<T> deferredResult, Object result) {
107+
}
99108

100109
@Override
101110
public <T> boolean handleTimeout(NativeWebRequest request, DeferredResult<T> deferredResult) {
102111
this.timeoutInProgress = true;
103-
return true; // give other interceptors a chance to handle the timeout
112+
return true; // give other interceptors a chance to handle the timeout
104113
}
105114

106115
@Override

spring-orm/src/main/java/org/springframework/orm/jpa/support/AsyncRequestInterceptor.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,7 +16,6 @@
1616

1717
package org.springframework.orm.jpa.support;
1818

19-
2019
import java.util.concurrent.Callable;
2120
import javax.persistence.EntityManagerFactory;
2221

@@ -42,8 +41,7 @@
4241
* @author Rossen Stoyanchev
4342
* @since 3.2.5
4443
*/
45-
public class AsyncRequestInterceptor extends CallableProcessingInterceptorAdapter
46-
implements DeferredResultProcessingInterceptor {
44+
class AsyncRequestInterceptor extends CallableProcessingInterceptorAdapter implements DeferredResultProcessingInterceptor {
4745

4846
private static final Log logger = LogFactory.getLog(AsyncRequestInterceptor.class);
4947

@@ -78,7 +76,7 @@ public <T> void postProcess(NativeWebRequest request, Callable<T> task, Object c
7876
@Override
7977
public <T> Object handleTimeout(NativeWebRequest request, Callable<T> task) {
8078
this.timeoutInProgress = true;
81-
return RESULT_NONE; // give other interceptors a chance to handle the timeout
79+
return RESULT_NONE; // give other interceptors a chance to handle the timeout
8280
}
8381

8482
@Override
@@ -96,19 +94,22 @@ private void closeAfterTimeout() {
9694

9795
// Implementation of DeferredResultProcessingInterceptor methods
9896

97+
@Override
9998
public <T> void beforeConcurrentHandling(NativeWebRequest request, DeferredResult<T> deferredResult) {
10099
}
101100

101+
@Override
102102
public <T> void preProcess(NativeWebRequest request, DeferredResult<T> deferredResult) {
103103
}
104104

105+
@Override
105106
public <T> void postProcess(NativeWebRequest request, DeferredResult<T> deferredResult, Object result) {
106107
}
107108

108109
@Override
109110
public <T> boolean handleTimeout(NativeWebRequest request, DeferredResult<T> deferredResult) {
110111
this.timeoutInProgress = true;
111-
return true; // give other interceptors a chance to handle the timeout
112+
return true; // give other interceptors a chance to handle the timeout
112113
}
113114

114115
@Override

spring-web/src/main/java/org/springframework/web/context/request/async/DeferredResultProcessingInterceptor.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.web.context.request.async;
1718

1819
import org.springframework.web.context.request.NativeWebRequest;
@@ -45,21 +46,18 @@ public interface DeferredResultProcessingInterceptor {
4546
* Invoked immediately before the start of concurrent handling, in the same
4647
* thread that started it. This method may be used to capture state just prior
4748
* to the start of concurrent processing with the given {@code DeferredResult}.
48-
*
4949
* @param request the current request
5050
* @param deferredResult the DeferredResult for the current request
5151
* @throws Exception in case of errors
5252
*/
53-
<T> void beforeConcurrentHandling(NativeWebRequest request, DeferredResult<T> deferredResult) throws Exception;
53+
<T> void beforeConcurrentHandling(NativeWebRequest request, DeferredResult<T> deferredResult) throws Exception;
5454

5555
/**
5656
* Invoked immediately after the start of concurrent handling, in the same
5757
* thread that started it. This method may be used to detect the start of
5858
* concurrent processing with the given {@code DeferredResult}.
59-
*
6059
* <p>The {@code DeferredResult} may have already been set, for example at
6160
* the time of its creation or by another thread.
62-
*
6361
* @param request the current request
6462
* @param deferredResult the DeferredResult for the current request
6563
* @throws Exception in case of errors
@@ -71,11 +69,9 @@ public interface DeferredResultProcessingInterceptor {
7169
* {@link DeferredResult#setResult(Object)} or
7270
* {@link DeferredResult#setErrorResult(Object)}, and is also ready to
7371
* handle the concurrent result.
74-
*
7572
* <p>This method may also be invoked after a timeout when the
7673
* {@code DeferredResult} was created with a constructor accepting a default
7774
* timeout result.
78-
*
7975
* @param request the current request
8076
* @param deferredResult the DeferredResult for the current request
8177
* @param concurrentResult the result to which the {@code DeferredResult}
@@ -88,7 +84,6 @@ public interface DeferredResultProcessingInterceptor {
8884
* the {@code DeferredResult} has been set. Implementations may invoke
8985
* {@link DeferredResult#setResult(Object) setResult} or
9086
* {@link DeferredResult#setErrorResult(Object) setErrorResult} to resume processing.
91-
*
9287
* @param request the current request
9388
* @param deferredResult the DeferredResult for the current request; if the
9489
* {@code DeferredResult} is set, then concurrent processing is resumed and
@@ -103,7 +98,6 @@ public interface DeferredResultProcessingInterceptor {
10398
* Invoked from a container thread when an async request completed for any
10499
* reason including timeout and network error. This method is useful for
105100
* detecting that a {@code DeferredResult} instance is no longer usable.
106-
*
107101
* @param request the current request
108102
* @param deferredResult the DeferredResult for the current request
109103
* @throws Exception in case of errors

0 commit comments

Comments
 (0)