|
Spring Framework | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.web.context.request.async.DeferredResult
public final class DeferredResult
DeferredResult provides an alternative to using a Callable for async request
processing. With a Callable the framework manages a thread on behalf of the
application through an AsyncTaskExecutor
. With a DeferredResult the
application sets the result in a thread of its choice.
The following sequence describes the intended use scenario:
set(Object)
If the application calls set(Object)
in thread-2 before the
DeferredResult is initialized by the framework in thread-1, then thread-2
will block and wait for the initialization to complete. Therefore an
application should never create and set the DeferredResult in the same
thread because the initialization will never complete.
Constructor Summary | |
---|---|
DeferredResult()
Create a new instance. |
|
DeferredResult(java.lang.Object timeoutResult)
Create a new instance and also provide a default result to use if a timeout occurs before set(Object) is called. |
Method Summary | |
---|---|
void |
set(java.lang.Object result)
Complete async processing with the given result. |
boolean |
trySet(java.lang.Object result)
A variant of set(Object) that absorbs a potential, resulting
StaleAsyncWebRequestException . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DeferredResult()
public DeferredResult(java.lang.Object timeoutResult)
set(Object)
is called.
Method Detail |
---|
public void set(java.lang.Object result) throws StaleAsyncWebRequestException
StaleAsyncWebRequestException
- if the underlying async request
has already timed out or ended due to a network error.public boolean trySet(java.lang.Object result) throws StaleAsyncWebRequestException
set(Object)
that absorbs a potential, resulting
StaleAsyncWebRequestException
.
false
if the outcome was a StaleAsyncWebRequestException
StaleAsyncWebRequestException
|
Spring Framework | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |