Class ResourceRequestWrapper
- java.lang.Object
-
- jakarta.portlet.filter.RenderStateWrapper
-
- jakarta.portlet.filter.PortletRequestWrapper
-
- jakarta.portlet.filter.ClientDataRequestWrapper
-
- jakarta.portlet.filter.ResourceRequestWrapper
-
- All Implemented Interfaces:
ClientDataRequest,PortletRequest,RenderState,ResourceRequest
public class ResourceRequestWrapper extends ClientDataRequestWrapper implements ResourceRequest
TheResourceRequestWrapperprovides a convenient implementation of theResourceRequestinterface that can be subclassed by developers. This class implements the Wrapper or Decorator pattern. Methods default to calling through to the wrapped request object.- Since:
- 2.0
- See Also:
ResourceRequest
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jakarta.portlet.PortletRequest
PortletRequest.P3PUserInfos
-
-
Field Summary
-
Fields inherited from class jakarta.portlet.filter.RenderStateWrapper
wrapped
-
Fields inherited from interface jakarta.portlet.PortletRequest
ACTION_PHASE, ACTION_SCOPE_ID, BASIC_AUTH, CCPP_PROFILE, CLIENT_CERT_AUTH, DIGEST_AUTH, EVENT_PHASE, FORM_AUTH, HEADER_PHASE, LIFECYCLE_PHASE, RENDER_HEADERS, RENDER_MARKUP, RENDER_PART, RENDER_PHASE, RESOURCE_PHASE, USER_INFO
-
Fields inherited from interface jakarta.portlet.ResourceRequest
ETAG
-
-
Constructor Summary
Constructors Constructor Description ResourceRequestWrapper(ResourceRequest request)Creates anResourceRequestadaptor wrapping the given request object.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description StringgetCacheability()Returns the cache level of this resource request.jakarta.servlet.DispatcherTypegetDispatcherType()Gets the dispatcher type of this request.StringgetETag()Returns the validation tag if the portlet container has a cached response for this validation tag, ornullif no cached response exists.PortletAsyncContextgetPortletAsyncContext()Gets theAsyncContextthat was created or reinitialized by the most recent invocation ofstartAsync()orstartAsync(ResourceRequest,ResourceResponse)on this request.Map<String,String[]>getPrivateRenderParameterMap()Deprecated.ResourceRequestgetRequest()Return the wrapped request object.StringgetResourceID()Returns the resource ID set on the ResourceURL ornullif no resource ID was set on the URL.ResourceParametersgetResourceParameters()Gets the resource parameters set for this request.booleanisAsyncStarted()Checks if this request has been put into asynchronous mode.booleanisAsyncSupported()Checks if this request supports asynchronous operation.voidsetRequest(ResourceRequest request)Sets the request object being wrapped.PortletAsyncContextstartPortletAsync()Puts this request into asynchronous mode and initializes theAsyncContextobject.PortletAsyncContextstartPortletAsync(ResourceRequest request, ResourceResponse response)Puts this request into asynchronous mode and initializes theAsyncContextobject.-
Methods inherited from class jakarta.portlet.filter.ClientDataRequestWrapper
getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getMethod, getPart, getParts, getPortletInputStream, getReader, setCharacterEncoding, setRequest
-
Methods inherited from class jakarta.portlet.filter.PortletRequestWrapper
getAttribute, getAttributeNames, getAuthType, getContextPath, getCookies, getLocale, getLocales, getParameter, getParameterMap, getParameterNames, getParameterValues, getPortalContext, getPortletContext, getPortletMode, getPortletSession, getPortletSession, getPreferences, getPrivateParameterMap, getProperties, getProperty, getPropertyNames, getPublicParameterMap, getRemoteUser, getRenderParameters, getRequestedSessionId, getResponseContentType, getResponseContentTypes, getScheme, getServerName, getServerPort, getUserAgent, getUserPrincipal, getWindowID, getWindowState, isPortletModeAllowed, isRequestedSessionIdValid, isSecure, isUserInRole, isWindowStateAllowed, removeAttribute, setAttribute, setRequest
-
Methods inherited from class jakarta.portlet.filter.RenderStateWrapper
getWrapped, setWrapped
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jakarta.portlet.ClientDataRequest
getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getMethod, getPart, getParts, getPortletInputStream, getReader, setCharacterEncoding
-
Methods inherited from interface jakarta.portlet.PortletRequest
getAttribute, getAttributeNames, getAuthType, getContextPath, getCookies, getLocale, getLocales, getParameter, getParameterMap, getParameterNames, getParameterValues, getPortalContext, getPortletContext, getPortletSession, getPortletSession, getPreferences, getPrivateParameterMap, getProperties, getProperty, getPropertyNames, getPublicParameterMap, getRemoteUser, getRequestedSessionId, getScheme, getServerName, getServerPort, getUserAgent, getUserPrincipal, getWindowID, isPortletModeAllowed, isRequestedSessionIdValid, isSecure, isUserInRole, isWindowStateAllowed, removeAttribute, setAttribute
-
Methods inherited from interface jakarta.portlet.RenderState
getRenderParameters
-
Methods inherited from interface jakarta.portlet.ResourceRequest
getPortletMode, getResponseContentType, getResponseContentTypes, getWindowState
-
-
-
-
Constructor Detail
-
ResourceRequestWrapper
public ResourceRequestWrapper(ResourceRequest request)
Creates anResourceRequestadaptor wrapping the given request object.- Parameters:
request- the resource request to wrap- Throws:
IllegalArgumentException- if the request isnull
-
-
Method Detail
-
getRequest
public ResourceRequest getRequest()
Return the wrapped request object.- Overrides:
getRequestin classClientDataRequestWrapper- Returns:
- the wrapped request
-
setRequest
public void setRequest(ResourceRequest request)
Sets the request object being wrapped.- Parameters:
request- the request to set- Throws:
IllegalArgumentException- if the request is null.
-
getETag
public String getETag()
Description copied from interface:ResourceRequestReturns the validation tag if the portlet container has a cached response for this validation tag, ornullif no cached response exists.This call returns the same value as
ResourceRequest.getProperty(ResourceRequest.ETAG).- Specified by:
getETagin interfaceResourceRequest- Returns:
- the validation tag if the portlet container
has a cached response for this validation tag, or
nullif no cached response exists.
-
getResourceID
public String getResourceID()
Description copied from interface:ResourceRequestReturns the resource ID set on the ResourceURL ornullif no resource ID was set on the URL.- Specified by:
getResourceIDin interfaceResourceRequest- Returns:
- the resource ID set on the ResourceURL,or
nullif no resource ID was set on the URL.
-
getPrivateRenderParameterMap
@Deprecated public Map<String,String[]> getPrivateRenderParameterMap()
Deprecated.Description copied from interface:ResourceRequestReturns aMapof the private render parameters of this request. Private parameters are not shared with other portlets or components. The returned parameters are "x-www-form-urlencoded" decoded.The parameters returned do not include the resource parameters that the portlet may have set on the resource URL triggering this
serveResourcecall.The values in the returned
Mapare from type String array (String[]).If no private parameters exist this method returns an empty
Map.- Specified by:
getPrivateRenderParameterMapin interfaceResourceRequest- Returns:
- an immutable
Mapcontaining private parameter names as keys and private parameter values as map values, or an emptyMapif no private parameters exist. The keys in the parameter map are of type String. The values in the parameter map are of type String array (String[]).
-
getCacheability
public String getCacheability()
Description copied from interface:ResourceRequestReturns the cache level of this resource request.Possible return values are:
ResourceURL.FULL, ResourceURL.PORTLETorResourceURL.PAGE.- Specified by:
getCacheabilityin interfaceResourceRequest- Returns:
- the cache level of this resource request.
-
getResourceParameters
public ResourceParameters getResourceParameters()
Description copied from interface:ResourceRequestGets the resource parameters set for this request.Resource parameters are additional portlet parameters added to the URL triggering the request that extend the state information provided by the render parameters.
PortletParametersprovides a description of the parameter concept.- Specified by:
getResourceParametersin interfaceResourceRequest- Returns:
- an immutable
ResourceParametersobject representing the resource parameters - See Also:
PortletParameters,MutableResourceParameters,ResourceURL
-
startPortletAsync
public PortletAsyncContext startPortletAsync() throws IllegalStateException
Description copied from interface:ResourceRequestPuts this request into asynchronous mode and initializes theAsyncContextobject.Calling this method will cause committal of the associated response to be delayed until
AsyncContext#completeis called on the returnedAsyncContext, or the asynchronous operation has timed out.This method clears the list of
AsyncListenerinstances (if any) that were registered with theAsyncContextreturned by the previous call to one of thestartAsyncmethods, after calling eachAsyncListenerat itsonStartAsyncmethod.Subsequent invocations of this method, or its overloaded variant, will return the same
AsyncContextinstance, reinitialized as appropriate.The
AsyncContextobject can be used as described by the servlet specification. TheServletRequestandServletResponseobjects obtained from theAsyncContextwill provide functionality appropriate for the portlet environment.The original
ResourceRequestandResourceResponseobjects will be made available as request attributes on theServletRequestobject obtained from theAsyncContextunder the namesjakarta.portlet.requestandjakarta.portlet.response, respectively. ThePortletConfigobject will be made available on theServletRequestunder the namejakarta.portlet.config.The
AsyncContext#dispatch()method will cause the portlet resource method to be invoked with theResourceRequestandResourceResponseobjects available as attributes on theServletRequestobject obtained from theAsyncContext. In this case, theResourceRequest#isAsyncStarted()method will returnfalseand theResourceRequest#getDispatcherType()method will returnDispatcherType#ASYNC.A portlet
ResourceFilterthat allocates resources and attaches them to theResourceRequestor that wraps theResourceRequestorResourceResponseshould not release resources in the outbound direction if asynchronous mode has been started. A portletResourceFiltercan use the values provided by theResourceRequest#isAsyncStarted()and theResourceRequest#getDispatcherType()methods to determine when to allocate and release resources.- Specified by:
startPortletAsyncin interfaceResourceRequest- Returns:
- the (re)initialized AsyncContext
- Throws:
IllegalStateException- if this request is within the scope of a filter or servlet that does not support asynchronous operations (that is, isAsyncSupported() returns false), or if this method is called again without any asynchronous dispatch (resulting from one of the PortletAsyncContext#dispatch methods), is called outside the scope of any such dispatch, or is called again within the scope of the same dispatch, or if the response has already been closed- See Also:
ServletRequest.startAsync(),AsyncContext,ResourceRequest.isAsyncStarted(),ResourceRequest.getDispatcherType(),ResourceFilter
-
startPortletAsync
public PortletAsyncContext startPortletAsync(ResourceRequest request, ResourceResponse response) throws IllegalStateException
Description copied from interface:ResourceRequestPuts this request into asynchronous mode and initializes theAsyncContextobject.Calling this method will cause committal of the associated response to be delayed until
AsyncContext#completeis called on the returnedAsyncContext, or the asynchronous operation has timed out.This method clears the list of
AsyncListenerinstances (if any) that were registered with theAsyncContextreturned by the previous call to one of thestartAsyncmethods, after calling eachAsyncListenerat itsonStartAsyncmethod.The
AsyncContextobject can be used as described by the servlet specification. TheServletRequestandServletResponseobjects obtained from theAsyncContextwill provide functionality appropriate for the portlet environment.The
ResourceRequestandResourceResponseobjects passed as arguments to this method will be made available as request attributes on theServletRequestobject obtained from theAsyncContextunder the namesjakarta.portlet.requestandjakarta.portlet.response, respectively. ThePortletConfigobject will be made available on theServletRequestunder the namejakarta.portlet.config.Subsequent invocations of this method, or its zero-argument variant, will return the same
AsyncContextinstance, reinitialized as appropriate. If a call to this method is followed by a call to its zero-argument variant, the specified (and possibly wrapped)ResourceRequestandResourceResponseobjects will remain available as request attributes on theServletRequestobject obtained from theAsyncContext.The
AsyncContext#dispatch()method will cause the portlet resource method to be invoked with theResourceRequestandResourceResponseobjects available as attributes on theServletRequestobject obtained from theAsyncContext. In this case, theResourceRequest#isAsyncStarted()method will returnfalseand theResourceRequest#getDispatcherType()method will returnDispatcherType#ASYNC.A portlet
ResourceFilterthat allocates resources and attaches them to theResourceRequestor that wraps theResourceRequestorResourceResponseshould not release resources in the outbound direction if asynchronous mode has been started. A portletResourceFiltercan use the values provided by theResourceRequest#isAsyncStarted()and theResourceRequest#getDispatcherType()methods to determine when to allocate and release resources.- Specified by:
startPortletAsyncin interfaceResourceRequest- Parameters:
request- the resource requestresponse- the resource response- Returns:
- the (re)initialized AsyncContext
- Throws:
IllegalStateException- if this request is within the scope of a filter or servlet that does not support asynchronous operations (that is, isAsyncSupported() returns false), or if this method is called again without any asynchronous dispatch (resulting from one of the PortletAsyncContext#dispatch methods), is called outside the scope of any such dispatch, or is called again within the scope of the same dispatch, or if the response has already been closed- See Also:
ServletRequest.startAsync(),AsyncContext,ResourceRequest.isAsyncStarted(),ResourceRequest.getDispatcherType(),ResourceFilter
-
isAsyncStarted
public boolean isAsyncStarted()
Description copied from interface:ResourceRequestChecks if this request has been put into asynchronous mode.A
ResourceRequestis put into asynchronous mode by callingstartAsync()orstartAsync(ResourceRequest,ResourceResponse)on it.This method returns
falseif this request was put into asynchronous mode, but has since been dispatched using one of theAsyncContext#dispatchmethods or released from asynchronous mode via a call toAsyncContext#complete.- Specified by:
isAsyncStartedin interfaceResourceRequest- Returns:
trueif asynchronous mode has been started- See Also:
ResourceRequest.startPortletAsync(),ResourceRequest.startPortletAsync(ResourceRequest, ResourceResponse)
-
isAsyncSupported
public boolean isAsyncSupported()
Description copied from interface:ResourceRequestChecks if this request supports asynchronous operation.Asynchronous operation is disabled for this request if this request is within the scope of a filter or servlet that has not been annotated or flagged in the portlet configuration as being able to support asynchronous handling.
- Specified by:
isAsyncSupportedin interfaceResourceRequest- Returns:
trueif this request supports asynchronous operation
-
getPortletAsyncContext
public PortletAsyncContext getPortletAsyncContext()
Description copied from interface:ResourceRequestGets theAsyncContextthat was created or reinitialized by the most recent invocation ofstartAsync()orstartAsync(ResourceRequest,ResourceResponse)on this request.- Specified by:
getPortletAsyncContextin interfaceResourceRequest- Returns:
- the
AsyncContext(re)initialized by the most recentstartAsyncmethod invocation - See Also:
ServletRequest.startAsync(),AsyncContext
-
getDispatcherType
public jakarta.servlet.DispatcherType getDispatcherType()
Description copied from interface:ResourceRequestGets the dispatcher type of this request.The initial dispatcher type of a request is defined as
DispatcherType.REQUEST. The dispatcher type of a request dispatched via aRequestDispatcheris given asDispatcherType.FORWARDorDispatcherType.INCLUDE, while the dispatcher type of an asynchronous request dispatched via one of theAsyncContext#dispatchmethods is given asDispatcherType.ASYNC.- Specified by:
getDispatcherTypein interfaceResourceRequest- Returns:
- the dispatcher type of this request
- See Also:
DispatcherType
-
-