|
15 | 15 | */
|
16 | 16 | package org.springframework.web.context.request.async;
|
17 | 17 |
|
| 18 | +import java.util.PriorityQueue; |
18 | 19 | import java.util.concurrent.Callable;
|
19 | 20 |
|
20 | 21 | import org.apache.commons.logging.Log;
|
|
28 | 29 | * concurrently on behalf of the application, with a {@code DeferredResult} the
|
29 | 30 | * application can produce the result from a thread of its choice.
|
30 | 31 | *
|
| 32 | + * <p>Subclasses can extend this class to easily associate additional data or |
| 33 | + * behavior with the {@link DeferredResult}. For example, one might want to |
| 34 | + * associate the user used to create the {@link DeferredResult} by extending the |
| 35 | + * class and adding an addition property for the user. In this way, the user |
| 36 | + * could easily be accessed later without the need to use a data structure to do |
| 37 | + * the mapping. |
| 38 | + * |
| 39 | + * <p>An example of associating additional behavior to this class might be |
| 40 | + * realized by extending the class to implement an additional interface. For |
| 41 | + * example, one might want to implement a {@link Comparable} so that when the |
| 42 | + * {@link DeferredResult} is added to a {@link PriorityQueue} it is handled in |
| 43 | + * the correct order. |
| 44 | + * |
31 | 45 | * @author Rossen Stoyanchev
|
| 46 | + * @author Rob Winch |
32 | 47 | * @since 3.2
|
33 | 48 | */
|
34 |
| -public final class DeferredResult<T> { |
| 49 | +public class DeferredResult<T> { |
35 | 50 |
|
36 | 51 | private static final Log logger = LogFactory.getLog(DeferredResult.class);
|
37 | 52 |
|
@@ -88,14 +103,14 @@ public DeferredResult(Long timeout, Object timeoutResult) {
|
88 | 103 | * timeout result was provided to the constructor. The request may also
|
89 | 104 | * expire due to a timeout or network error.
|
90 | 105 | */
|
91 |
| - public boolean isSetOrExpired() { |
| 106 | + public final boolean isSetOrExpired() { |
92 | 107 | return ((this.result != RESULT_NONE) || this.expired);
|
93 | 108 | }
|
94 | 109 |
|
95 | 110 | /**
|
96 | 111 | * Return the configured timeout value in milliseconds.
|
97 | 112 | */
|
98 |
| - Long getTimeoutValue() { |
| 113 | + final Long getTimeoutValue() { |
99 | 114 | return this.timeout;
|
100 | 115 | }
|
101 | 116 |
|
@@ -126,7 +141,7 @@ public void onCompletion(Runnable callback) {
|
126 | 141 | * @param resultHandler the handler
|
127 | 142 | * @see {@link DeferredResultProcessingInterceptor}
|
128 | 143 | */
|
129 |
| - public void setResultHandler(DeferredResultHandler resultHandler) { |
| 144 | + public final void setResultHandler(DeferredResultHandler resultHandler) { |
130 | 145 | Assert.notNull(resultHandler, "DeferredResultHandler is required");
|
131 | 146 | synchronized (this) {
|
132 | 147 | this.resultHandler = resultHandler;
|
@@ -179,7 +194,7 @@ public boolean setErrorResult(Object result) {
|
179 | 194 | return setResultInternal(result);
|
180 | 195 | }
|
181 | 196 |
|
182 |
| - DeferredResultProcessingInterceptor getInterceptor() { |
| 197 | + final DeferredResultProcessingInterceptor getInterceptor() { |
183 | 198 | return new DeferredResultProcessingInterceptorAdapter() {
|
184 | 199 |
|
185 | 200 | @Override
|
|
0 commit comments