Class JavaxToJakartaRequestWrapper
- All Implemented Interfaces:
jakarta.servlet.http.HttpServletRequest,jakarta.servlet.ServletRequest,Adaptable,SlingJakartaHttpServletRequest
SlingHttpServletRequest to adapt it to the Jakarta Servlet API.- Since:
- 2.9.0
-
Field Summary
Fields inherited from interface jakarta.servlet.http.HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<AdapterType>
AdapterTypeAdapts the adaptable to another type.@Nullable jakarta.servlet.http.CookieReturns the named cookie from the HTTP request ornullif no such cookie exists in the request.@Nullable jakarta.servlet.RequestDispatchergetRequestDispatcher(@NotNull String path, RequestDispatcherOptions options) Returns aRequestDispatcherobject that acts as a wrapper for the resource located at the given path.@Nullable jakarta.servlet.RequestDispatchergetRequestDispatcher(@NotNull Resource resource) Same asSlingJakartaHttpServletRequest.getRequestDispatcher(Resource,RequestDispatcherOptions)but using empty options.@Nullable jakarta.servlet.RequestDispatchergetRequestDispatcher(@NotNull Resource resource, RequestDispatcherOptions options) Returns aRequestDispatcherobject that acts as a wrapper for the resource located at the given resource.@Nullable RequestParametergetRequestParameter(@NotNull String name) Returns the value of a request parameter as aRequestParameter, ornullif the parameter does not exist.@NotNull List<RequestParameter>Returns the request parameters as instances of theRequestParameterinterface in the order or the request where the query string parameters are first and the POST request parameters are second.@NotNull RequestParameterMapReturns aMapof the parameters of this request.@Nullable RequestParameter[]getRequestParameters(@NotNull String name) Returns an array ofRequestParameterobjects containing all of the values the given request parameter has, ornullif the parameter does not exist.@NotNull RequestPathInfoReturns theRequestPathInfopertaining to this request.@NotNull RequestProgressTrackerReturns theRequestProgressTrackerof this request.@NotNull ResourceReturns theResourceobject on whose behalf the servlet acts.@Nullable ResourceBundlegetResourceBundle(String baseName, Locale locale) Returns the resource bundle of the given base name for the given locale.@Nullable ResourceBundlegetResourceBundle(Locale locale) Returns the resource bundle for the given locale.@NotNull ResourceResolverReturns theResourceResolverwhich resolved theresourceof this request.@Nullable StringReturns the framework preferred content type for the response.@NotNull Enumeration<String>Gets a list of content types which the framework accepts for the response.static @Nullable SlingJakartaHttpServletRequesttoJakartaRequest(@Nullable SlingHttpServletRequest request) Create a new wrapperstatic @Nullable jakarta.servlet.http.HttpServletRequesttoJakartaRequest(javax.servlet.http.HttpServletRequest request) Create a new wrapperstatic @Nullable jakarta.servlet.ServletRequesttoJakartaRequest(javax.servlet.ServletRequest request) Create a new wrapperMethods inherited from class org.apache.felix.http.jakartawrappers.HttpServletRequestWrapper
authenticate, changeSessionId, getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getHttpServletMapping, getIntHeader, getMethod, getPart, getParts, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, getTrailerFields, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isTrailerFieldsReady, isUserInRole, login, logout, newPushBuilder, upgradeMethods inherited from class org.apache.felix.http.jakartawrappers.ServletRequestWrapper
getAsyncContext, getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getProtocolRequestId, getReader, getRemoteAddr, getRemoteHost, getRemotePort, getRequest, getRequestDispatcher, getRequestId, getScheme, getServerName, getServerPort, getServletConnection, getServletContext, getTranslatedAttributeName, getWrapper, isAsyncStarted, isAsyncSupported, isSecure, removeAttribute, setAttribute, setCharacterEncoding, startAsync, startAsyncMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jakarta.servlet.http.HttpServletRequest
authenticate, changeSessionId, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getHttpServletMapping, getIntHeader, getMethod, getPart, getParts, getPathInfo, getPathTranslated, getQueryString, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, getTrailerFields, isRequestedSessionIdFromCookie, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isTrailerFieldsReady, isUserInRole, login, logout, newPushBuilder, upgradeMethods inherited from interface jakarta.servlet.ServletRequest
getAsyncContext, getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getProtocolRequestId, getReader, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getRequestId, getScheme, getServerName, getServerPort, getServletConnection, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, removeAttribute, setAttribute, setCharacterEncoding, setCharacterEncoding, startAsync, startAsyncMethods inherited from interface org.apache.sling.api.SlingJakartaHttpServletRequest
getAuthType, getRemoteUser, getUserPrincipal
-
Constructor Details
-
JavaxToJakartaRequestWrapper
-
-
Method Details
-
toJakartaRequest
@Nullable public static @Nullable jakarta.servlet.ServletRequest toJakartaRequest(@Nullable javax.servlet.ServletRequest request) Create a new wrapper- Parameters:
request- The request object (may be null)- Returns:
- null if the request parameter is null or the wrapped request object otherwise
-
toJakartaRequest
@Nullable public static @Nullable jakarta.servlet.http.HttpServletRequest toJakartaRequest(@Nullable javax.servlet.http.HttpServletRequest request) Create a new wrapper- Parameters:
request- The http request object (may be null)- Returns:
- null if the request parameter is null or the wrapped request object otherwise
-
toJakartaRequest
@Nullable public static @Nullable SlingJakartaHttpServletRequest toJakartaRequest(@Nullable @Nullable SlingHttpServletRequest request) Create a new wrapper- Parameters:
request- The sling http request object (may be null)- Returns:
- null if the request parameter is null or the wrapped request object otherwise
-
getCookie
Description copied from interface:SlingJakartaHttpServletRequestReturns the named cookie from the HTTP request ornullif no such cookie exists in the request.- Specified by:
getCookiein interfaceSlingJakartaHttpServletRequest- Parameters:
name- The name of the cookie to return.- Returns:
- The named cookie or
nullif no such cookie exists.
-
getRequestDispatcher
@Nullable public @Nullable jakarta.servlet.RequestDispatcher getRequestDispatcher(@NotNull @NotNull String path, RequestDispatcherOptions options) Description copied from interface:SlingJakartaHttpServletRequestReturns aRequestDispatcherobject that acts as a wrapper for the resource located at the given path. ARequestDispatcherobject can be used to include the resource in a response.Returns
nullif aRequestDispatchercannot be returned for any reason.- Specified by:
getRequestDispatcherin interfaceSlingJakartaHttpServletRequest- Parameters:
path- aStringspecifying the pathname to the resource. If it is relative, it must be relative against the current servlet.options- influence the rendering of the included Resource- Returns:
- a
RequestDispatcherobject that acts as a wrapper for theresourceornullif an error occurs preparing the dispatcher.
-
getRequestDispatcher
@Nullable public @Nullable jakarta.servlet.RequestDispatcher getRequestDispatcher(@NotNull @NotNull Resource resource, RequestDispatcherOptions options) Description copied from interface:SlingJakartaHttpServletRequestReturns aRequestDispatcherobject that acts as a wrapper for the resource located at the given resource. ARequestDispatcherobject can be used to include the resource in a response.Returns
nullif aRequestDispatchercannot be returned for any reason.- Specified by:
getRequestDispatcherin interfaceSlingJakartaHttpServletRequest- Parameters:
resource- TheResourceinstance whose response content may be included by the returned dispatcher.options- influence the rendering of the included Resource- Returns:
- a
RequestDispatcherobject that acts as a wrapper for theresourceornullif an error occurs preparing the dispatcher.
-
getRequestDispatcher
@Nullable public @Nullable jakarta.servlet.RequestDispatcher getRequestDispatcher(@NotNull @NotNull Resource resource) Description copied from interface:SlingJakartaHttpServletRequestSame asSlingJakartaHttpServletRequest.getRequestDispatcher(Resource,RequestDispatcherOptions)but using empty options.- Specified by:
getRequestDispatcherin interfaceSlingJakartaHttpServletRequest- Parameters:
resource- TheResourceinstance whose response content may be included by the returned dispatcher.- Returns:
- a
RequestDispatcherobject that acts as a wrapper for theresourceornullif an error occurs preparing the dispatcher.
-
getRequestParameter
Description copied from interface:SlingJakartaHttpServletRequestReturns the value of a request parameter as aRequestParameter, ornullif the parameter does not exist.This method should only be used if the parameter has only one value. If the parameter might have more than one value, use
SlingJakartaHttpServletRequest.getRequestParameters(String).If this method is used with a multivalued parameter, the value returned is equal to the first value in the array returned by
getRequestParameters.This method is a shortcut for
getRequestParameterMap().getValue(String).- Specified by:
getRequestParameterin interfaceSlingJakartaHttpServletRequest- Parameters:
name- aStringspecifying the name of the parameter- Returns:
- a
RequestParameterrepresenting the single value of the parameter - See Also:
-
getRequestParameterList
Description copied from interface:SlingJakartaHttpServletRequestReturns the request parameters as instances of theRequestParameterinterface in the order or the request where the query string parameters are first and the POST request parameters are second.- Specified by:
getRequestParameterListin interfaceSlingJakartaHttpServletRequest- Returns:
- The list of
RequestParameterin request declaration order.
-
getRequestParameterMap
Description copied from interface:SlingJakartaHttpServletRequestReturns aMapof the parameters of this request.The values in the returned
Mapare from typeRequestParameterarray (RequestParameter[]).If no parameters exist this method returns an empty
Map.- Specified by:
getRequestParameterMapin interfaceSlingJakartaHttpServletRequest- Returns:
- an immutable
Mapcontaining parameter names as keys and parameter values as map values, or an emptyMapif no parameters exist. The keys in the parameter map are of type String. The values in the parameter map are of typeRequestParameterarray (RequestParameter[]).
-
getRequestParameters
Description copied from interface:SlingJakartaHttpServletRequestReturns an array ofRequestParameterobjects containing all of the values the given request parameter has, ornullif the parameter does not exist.If the parameter has a single value, the array has a length of 1.
This method is a shortcut for
getRequestParameterMap().getValues(String).- Specified by:
getRequestParametersin interfaceSlingJakartaHttpServletRequest- Parameters:
name- aStringcontaining the name of the parameter the value of which is requested- Returns:
- an array of
RequestParameterobjects containing the parameter values. - See Also:
-
getRequestPathInfo
Description copied from interface:SlingJakartaHttpServletRequestReturns theRequestPathInfopertaining to this request.- Specified by:
getRequestPathInfoin interfaceSlingJakartaHttpServletRequest- Returns:
- the request path info.
-
getRequestProgressTracker
Description copied from interface:SlingJakartaHttpServletRequestReturns theRequestProgressTrackerof this request.- Specified by:
getRequestProgressTrackerin interfaceSlingJakartaHttpServletRequest- Returns:
- The request progress tracker.
-
getResource
Description copied from interface:SlingJakartaHttpServletRequestReturns theResourceobject on whose behalf the servlet acts.- Specified by:
getResourcein interfaceSlingJakartaHttpServletRequest- Returns:
- The
Resourceobject of this request.
-
getResourceBundle
Description copied from interface:SlingJakartaHttpServletRequestReturns the resource bundle for the given locale.- Specified by:
getResourceBundlein interfaceSlingJakartaHttpServletRequest- Parameters:
locale- the locale for which to retrieve the resource bundle. If this isnull, the locale returned byServletRequest.getLocale()is used to select the resource bundle.- Returns:
- the resource bundle for the given locale
-
getResourceBundle
Description copied from interface:SlingJakartaHttpServletRequestReturns the resource bundle of the given base name for the given locale.- Specified by:
getResourceBundlein interfaceSlingJakartaHttpServletRequest- Parameters:
baseName- The base name of the resource bundle to returned. If this parameter isnull, the same resource bundle must be returned as if theSlingJakartaHttpServletRequest.getResourceBundle(Locale)method is called.locale- the locale for which to retrieve the resource bundle. If this isnull, the locale returned byServletRequest.getLocale()is used to select the resource bundle.- Returns:
- the resource bundle for the given locale
-
getResourceResolver
Description copied from interface:SlingJakartaHttpServletRequestReturns theResourceResolverwhich resolved theresourceof this request.- Specified by:
getResourceResolverin interfaceSlingJakartaHttpServletRequest- Returns:
- The resource resolver
-
getResponseContentType
Description copied from interface:SlingJakartaHttpServletRequestReturns the framework preferred content type for the response. The content type only includes the MIME type, not the character set.For included resources this method will returned the same string as returned by the
ServletResponse.getContentType()without the character set.- Specified by:
getResponseContentTypein interfaceSlingJakartaHttpServletRequest- Returns:
- preferred MIME type of the response
-
getResponseContentTypes
Description copied from interface:SlingJakartaHttpServletRequestGets a list of content types which the framework accepts for the response. This list is ordered with the most preferable types listed first. The content type only includes the MIME type, not the character set.For included resources this method will returned an enumeration containing a single entry which is the same string as returned by the
ServletResponse.getContentType()without the character set.- Specified by:
getResponseContentTypesin interfaceSlingJakartaHttpServletRequest- Returns:
- ordered list of MIME types for the response
-
adaptTo
Description copied from interface:AdaptableAdapts the adaptable to another type.Please note that it is explicitly left as an implementation detail whether each call to this method with the same
typeyields the same object or a new object on each call.Implementations of this method should document their adapted types as well as their behaviour with respect to returning newly created or same instances on each call.
- Specified by:
adaptToin interfaceAdaptable- Type Parameters:
AdapterType- The generic type to which this object is adapted to- Parameters:
type- The Class object of the target type, such asjavax.jcr.Node.classorjava.io.File.class- Returns:
- The adapter target or
nullif the object cannot adapt to the requested type
-