Portlet asynchronous support is modeled after servlet asynchronous support, and in
general, the portlet async methods behave in the same manner as their
AsyncContext analog.
A PortletAsyncContext is created and initialized by a call to
ResourceRequest#startAsync() or
ResourceRequest#startAsync(ServletRequest, ServletResponse).
Repeated invocations of these methods will return the same
PortletAsyncContext instance, reinitialized as appropriate.
In the event that an asynchronous operation times out, the container will
invoke the onTimeout method of all PortletAsyncListener instances registered
with the PortletAsyncContext on which the asynchronous operation was initiated.
If none of the listeners call complete() or any of the
dispatch() methods, the portlet container will
complete the request on behalf of the application and may respond with error information.
javax.servlet.AsyncContext, PortletAsyncListener, PortletAsyncEvent
| Modifier and Type | Method and Description |
|---|---|
| public void | addListener(PortletAsyncListener
the listener to be added listener)
Registers the given
PortletAsyncListener with the most recent
asynchronous cycle that was started by a call to one of the
ResourceRequest.startAsync() methods. |
| public void | addListener(PortletAsyncListener
the listener to be added listener, ResourceRequest the request object to be included in the request, ResourceResponse PortletAsyncEventthe response object to be included in the response)PortletAsyncEvent
Registers the given
PortletAsyncListener with the most recent
asynchronous cycle that was started by a call to one of the
ResourceRequest.startAsync() methods. |
| public void | complete()
Completes the
PortletAsynchronous operation
and closes the response associated with this PortletAsyncContext object. |
| public <T extends PortletAsyncListener> T | Returns: the instantiated classthe class to be instantiated cls)
Instantiates the given
PortletAsyncListener class. |
| public void | dispatch()
Dispatches the request and response objects of this
PortletAsyncContext to
the portlet container. |
| public void | |
| public ResourceRequest | Returns: The resource request object
Gets the request that was used to initialize this
PortletAsyncContext by calling
ResourceRequest.startAsync() or ResourceRequest.startAsync(ServletRequest, ServletResponse). |
| public ResourceResponse | Returns: The resource response object
Gets the response that was used to initialize this
PortletAsyncContext by calling
ResourceRequest.startAsync() or ResourceRequest.startAsync(ServletRequest, ServletResponse). |
| public long | Returns: the timeout in milliseconds
Gets the timeout (in milliseconds) for this PortletAsyncContext.
|
| public boolean | Returns: true if this PortletAsyncContext was initialized with the original
request and response objects by calling ResourceRequest.startAsync(),
or if it was initialized by calling
ResourceRequest.startAsync(ResourceRequest, ResourceResponse), and neither
the ResourceRequest nor ResourceResponse arguments carried any
application-provided wrappers; false otherwise
Checks if this
PortletAsyncContext was initialized with the original or
application-wrapped request and response objects. |
| public void | setTimeout(long
the timeout in milliseconds time)
Sets the timeout (in milliseconds) for this
PortletAsyncContext. |
| public void |
| addListener | back to summary |
|---|---|
| public void addListener(PortletAsyncListener listener) throws IllegalStateException
Registers the given
PortletAsyncListener with the most recent
asynchronous cycle that was started by a call to one of the
ResourceRequest.startAsync() methods.
The given
When one of the listener methods is invoked, the
| |
| addListener | back to summary |
|---|---|
| public void addListener(PortletAsyncListener listener, ResourceRequest request, ResourceResponse response) throws IllegalStateException
Registers the given
PortletAsyncListener with the most recent
asynchronous cycle that was started by a call to one of the
ResourceRequest.startAsync() methods.
The given
The given
| |
| complete | back to summary |
|---|---|
| public void complete() throws IllegalStateException
Completes the
PortletAsynchronous operation
and closes the response associated with this PortletAsyncContext object.
The
It is legal to call this method any time after a call to
| |
| createPortletAsyncListener | back to summary |
|---|---|
| public <T extends PortletAsyncListener> T createPortletAsyncListener(Class<T> cls) throws PortletException
Instantiates the given
PortletAsyncListener class.
The returned
The given This method supports resource injection if contextual support is available, and if the given class represents a Managed Bean. See the Java EE platform and JSR 299 specifications for additional details about Managed Beans and resource injection.
| |
| dispatch | back to summary |
|---|---|
| public void dispatch() throws IllegalStateException
Dispatches the request and response objects of this
PortletAsyncContext to
the portlet container.
The portlet container will dispatch the the request and response to the portlet resource method in which the first asynchronous processing cycle was initiated. This method returns immediately after passing the request and response objects to a container managed thread which will perform the dispatch operation. If this method is called before the container-initiated dispatch that called startAsync has returned to the container, the dispatch operation will be delayed until after the container-initiated dispatch has returned to the container.
The dispatcher type of the request is set to
Control over the request and response is delegated to the dispatch target,
and the response will be closed when the dispatch target has completed
execution, unless Any errors or exceptions that may occur during the execution of this method must be caught and handled by the container as follows:
There can be at most one asynchronous dispatch operation per asynchronous
cycle, which is started by a call to one of the
| |
| dispatch | back to summary |
|---|---|
| public void dispatch(String path) throws IllegalStateException
Dispatches the request and response objects of this
PortletAsyncContext to
the given path within the PortletContext.
The path parameter is interpreted in the same way as in
There can be at most one asynchronous dispatch operation per asynchronous
cycle, which is started by a call to one of the
See
| |
| getResourceRequest | back to summary |
|---|---|
| public ResourceRequest getResourceRequest() throws IllegalStateException
Gets the request that was used to initialize this
PortletAsyncContext by calling
ResourceRequest.startAsync() or ResourceRequest.startAsync(ServletRequest, ServletResponse).
| |
| getResourceResponse | back to summary |
|---|---|
| public ResourceResponse getResourceResponse() throws IllegalStateException
Gets the response that was used to initialize this
PortletAsyncContext by calling
ResourceRequest.startAsync() or ResourceRequest.startAsync(ServletRequest, ServletResponse).
| |
| getTimeout | back to summary |
|---|---|
| public long getTimeout()
Gets the timeout (in milliseconds) for this PortletAsyncContext.
This method returns the container's default timeout for asynchronous operations,
or the timeout value passed to the most recent invocation of
A timeout value of zero or less indicates no timeout.
| |
| hasOriginalRequestAndResponse | back to summary |
|---|---|
| public boolean hasOriginalRequestAndResponse()
Checks if this
PortletAsyncContext was initialized with the original or
application-wrapped request and response objects.
This information may be used by filters invoked in the outbound direction, after a request was put into asynchronous mode, to determine whether any request and/or response wrappers that they added during their inbound invocation need to be preserved for the duration of the asynchronous operation, or may be released.
| |
| setTimeout | back to summary |
|---|---|
| public void setTimeout(long time)
Sets the timeout (in milliseconds) for this
PortletAsyncContext.
The timeout applies to this
The timeout will expire if neither the
If The default value is 30000 ms.
| |
| start | back to summary |
|---|---|
| public void start(Runnable run) throws IllegalStateException
Causes the container to dispatch a thread, possibly from a managed thread pool,
to run the specified
Runnable. The container may propagate appropriate
contextual information to the Runnable.
| |