Class ResourceHandlerWrapper
- All Implemented Interfaces:
FacesWrapper<ResourceHandler>
Provides a simple
implementation of ResourceHandler that can be subclassed by developers wishing to provide specialized
behavior to an existing ResourceHandler instance. The default implementation of all methods is to call
through to the wrapped ResourceHandler.
Usage: extend this class and push the implementation being wrapped to the constructor and use getWrapped() to
access the instance being wrapped.
- Since:
- 2.0
-
Field Summary
Fields inherited from class ResourceHandler
CSP_POLICY_PARAM_NAME, DEFAULT_CSP_POLICY, ENABLE_CSP_NONCE_PARAM_NAME, FACES_SCRIPT_LIBRARY_NAME, FACES_SCRIPT_RESOURCE_NAME, LOCALE_PREFIX, RESOURCE_CONTRACT_XML, RESOURCE_EXCLUDES_DEFAULT_VALUE, RESOURCE_EXCLUDES_PARAM_NAME, RESOURCE_IDENTIFIER, WEBAPP_CONTRACTS_DIRECTORY_DEFAULT_VALUE, WEBAPP_CONTRACTS_DIRECTORY_PARAM_NAME, WEBAPP_RESOURCES_DIRECTORY_DEFAULT_VALUE, WEBAPP_RESOURCES_DIRECTORY_PARAM_NAMEModifier and TypeFieldDescriptionstatic final StringThe string context parameter name to determine the Content Security Policy (CSP) policy to be sent in theContent-Security-Policyresponse header.static final StringThe default value for theContent-Security-Policyresponse header if theResourceHandler.ENABLE_CSP_NONCE_PARAM_NAMEis set totrueand theResourceHandler.CSP_POLICY_PARAM_NAMEis not provided.static final StringThe boolean context parameter name to explicitly enable Content Security Policy (CSP) nonce generation.static final StringLibrary name of Jakarta Faces script resource.static final StringResource name of Jakarta Faces script resource.static final StringThe name of a key within the application message bundle named by the return fromApplication.getMessageBundle()whose value is the locale prefix used to find a packaged resource to return fromResourceHandler.createResource(String)(or one of its variants).static final StringThis file must be located inMETA-INF/contracts/<contractName>/in a jar file that contains a resource library contract, where<contractName>is the name of the contract.static final StringThe default value for theResourceHandler.RESOURCE_EXCLUDES_PARAM_NAMEinit param.static final StringTheServletContextinit parameter consulted by theResourceHandler.handleResourceRequest(FacesContext)to tell which kinds of resources must never be served up in response to a resource request.static final StringResource.getRequestPath()returns the value of this constant as the prefix of the URI.static final StringThe default value of theResourceHandler.WEBAPP_CONTRACTS_DIRECTORY_PARAM_NAMEcontext-param.static final StringIf a<context-param>with the param name equal to the value ofResourceHandler.WEBAPP_CONTRACTS_DIRECTORY_PARAM_NAMEexists, the runtime must interpret its value as a path, relative to the web app root, where resource library contracts are to be located.static final StringThe default value of theResourceHandler.WEBAPP_RESOURCES_DIRECTORY_PARAM_NAMEcontext-param.static final StringIf a<context-param>with the param name equal to the value ofResourceHandler.WEBAPP_RESOURCES_DIRECTORY_PARAM_NAMEexists, the runtime must interpret its value as a path, relative to the web app root, where resources are to be located. -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.Use the other constructor taking the implementation being wrapped.ResourceHandlerWrapper(ResourceHandler wrapped) If this resource handler has been decorated, the implementation doing the decorating should push the implementation being wrapped to this constructor. -
Method Summary
Modifier and TypeMethodDescriptioncreateResource(String resourceName) The default behavior of this method is to callResourceHandler.createResource(String)on the wrappedResourceHandlerobject.createResource(String resourceName, String libraryName) The default behavior of this method is to callResourceHandler.createResource(String, String)on the wrappedResourceHandlerobject.createResource(String resourceName, String libraryName, String contentType) The default behavior of this method is to callResourceHandler.createResource(String, String, String)on the wrappedResourceHandlerobject.createResourceFromId(String resourceId) The default behavior of this method is to callResourceHandler.createResourceFromId(String)on the wrappedResourceHandlerobject.createViewResource(FacesContext context, String resourceName) The default behavior of this method is to callResourceHandler.createViewResource(FacesContext, String)on the wrappedResourceHandlerobject.getCurrentNonce(FacesContext context) The default behavior of this method is to callResourceHandler.getCurrentNonce(FacesContext)on the wrappedResourceHandlerobject.getRendererTypeForResourceName(String resourceName) The default behavior of this method is to callResourceHandler.getRendererTypeForResourceName(String)on the wrappedResourceHandlerobject.getViewResources(FacesContext facesContext, String path, int maxDepth, ResourceVisitOption... options) The default behavior of this method is to callResourceHandler.getViewResources(FacesContext, String, int, ResourceVisitOption...)on the wrappedResourceHandlerobject.getViewResources(FacesContext facesContext, String path, ResourceVisitOption... options) The default behavior of this method is to callResourceHandler.getViewResources(FacesContext, String, ResourceVisitOption...)on the wrappedResourceHandlerobject.A class that implements this interface uses this method to return an instance of the class being wrapped.voidhandleResourceRequest(FacesContext context) The default behavior of this method is to callResourceHandler.handleResourceRequest(jakarta.faces.context.FacesContext)on the wrappedResourceHandlerobject.booleanisResourceRendered(FacesContext context, String resourceName, String libraryName) The default behavior of this method is to callResourceHandler.isResourceRendered(FacesContext, String, String)on the wrappedResourceHandlerobject.booleanisResourceRequest(FacesContext context) The default behavior of this method is to callResourceHandler.isResourceRequest(jakarta.faces.context.FacesContext)on the wrappedResourceHandlerobject.booleanisResourceURL(String url) The default behavior of this method is to callResourceHandler.isResourceURL(String)on the wrappedResourceHandlerobject.booleanlibraryExists(String libraryName) The default behavior of this method is to callResourceHandler.libraryExists(String)on the wrappedResourceHandlerobject.voidmarkResourceRendered(FacesContext context, String resourceName, String libraryName) The default behavior of this method is to callResourceHandler.markResourceRendered(FacesContext, String, String)on the wrappedResourceHandlerobject.
-
Constructor Details
-
ResourceHandlerWrapper
Deprecated.Use the other constructor taking the implementation being wrapped. -
ResourceHandlerWrapper
If this resource handler has been decorated, the implementation doing the decorating should push the implementation being wrapped to this constructor. The
getWrapped()will then return the implementation being wrapped.- Parameters:
wrapped- The implementation being wrapped.- Since:
- 2.3
-
-
Method Details
-
getWrapped
Description copied from interface:FacesWrapperA class that implements this interface uses this method to return an instance of the class being wrapped.
- Specified by:
getWrappedin interfaceFacesWrapper<ResourceHandler>- Returns:
- the wrapped instance.
-
createResource
The default behavior of this method is to call
ResourceHandler.createResource(String)on the wrappedResourceHandlerobject.- Specified by:
createResourcein classResourceHandler- Parameters:
resourceName- the name of the resource.- Returns:
- a newly created
Resourceinstance, suitable for use in encoding or decoding the named resource.
-
createResourceFromId
The default behavior of this method is to call
ResourceHandler.createResourceFromId(String)on the wrappedResourceHandlerobject.- Overrides:
createResourceFromIdin classResourceHandler- Parameters:
resourceId- the resource identifier of the resource.- Returns:
- a newly created
Resourceinstance, suitable for use in encoding or decoding the named resource. - Since:
- 2.2
-
createResource
The default behavior of this method is to call
ResourceHandler.createResource(String, String)on the wrappedResourceHandlerobject.- Specified by:
createResourcein classResourceHandler- Parameters:
resourceName- the name of the resource.libraryName- the name of the library (or contract) in which this resource resides, may benull. If there is a conflict between the name of a resource library and a resource library contract, the resource library takes precedence. May not include relative paths, such as "../".- Returns:
- a newly created
Resourceinstance, suitable for use in encoding or decoding the named resource.
-
createViewResource
The default behavior of this method is to call
ResourceHandler.createViewResource(FacesContext, String)on the wrappedResourceHandlerobject.- Overrides:
createViewResourcein classResourceHandler- Parameters:
context- theFacesContextfor this request.resourceName- the name of the resource to be interpreted as a view by theViewDeclarationLanguage.- Returns:
- a newly created
ViewResourceinstance, suitable for use by theViewDeclarationLanguage.
-
getViewResources
public Stream<String> getViewResources(FacesContext facesContext, String path, int maxDepth, ResourceVisitOption... options) The default behavior of this method is to call
ResourceHandler.getViewResources(FacesContext, String, int, ResourceVisitOption...)on the wrappedResourceHandlerobject.- Overrides:
getViewResourcesin classResourceHandler- Parameters:
facesContext- TheFacesContextfor this request.path- The initial path from which to start looking for view resourcesmaxDepth- The absolute maximum depth of nested directories to visit counted from the root (/).options- The options to influence the traversal. SeeResourceVisitOptionfor details on those.- Returns:
- the
Streamof view resource names - Since:
- 2.3
-
getViewResources
public Stream<String> getViewResources(FacesContext facesContext, String path, ResourceVisitOption... options) The default behavior of this method is to call
ResourceHandler.getViewResources(FacesContext, String, ResourceVisitOption...)on the wrappedResourceHandlerobject.- Overrides:
getViewResourcesin classResourceHandler- Parameters:
facesContext- TheFacesContextfor this request.path- The initial path from which to start looking for view resourcesoptions- The options to influence the traversal. SeeResourceVisitOptionfor details on those.- Returns:
- the
Streamof view resource names - Since:
- 2.3
-
createResource
The default behavior of this method is to call
ResourceHandler.createResource(String, String, String)on the wrappedResourceHandlerobject.- Specified by:
createResourcein classResourceHandler- Parameters:
resourceName- the name of the resource.libraryName- the name of the library in which this resource resides, may benull. May not include relative paths, such as "../".contentType- the mime content that thisResourceinstance will return fromResource.getContentType(). If the value isnull, The content-type of the resource is derived by passing the resourceName toExternalContext.getMimeType(String)- Returns:
- a newly created
Resourceinstance, suitable for use in encoding or decoding the named resource.
-
handleResourceRequest
The default behavior of this method is to call
ResourceHandler.handleResourceRequest(jakarta.faces.context.FacesContext)on the wrappedResourceHandlerobject.- Specified by:
handleResourceRequestin classResourceHandler- Parameters:
context- theFacesContextfor this request- Throws:
IOException- when an I/O error occurs.
-
isResourceRequest
The default behavior of this method is to call
ResourceHandler.isResourceRequest(jakarta.faces.context.FacesContext)on the wrappedResourceHandlerobject.- Specified by:
isResourceRequestin classResourceHandler- Parameters:
context- theFacesContextfor this request- Returns:
trueif the current request is a resource request,falseotherwise.
-
isResourceURL
The default behavior of this method is to call
ResourceHandler.isResourceURL(String)on the wrappedResourceHandlerobject.- Overrides:
isResourceURLin classResourceHandler- Parameters:
url- the url to inspect for the presence ofResourceHandler.RESOURCE_IDENTIFIER.- Returns:
trueif this is a resource URL,falseotherwise.
-
libraryExists
The default behavior of this method is to call
ResourceHandler.libraryExists(String)on the wrappedResourceHandlerobject.- Specified by:
libraryExistsin classResourceHandler- Parameters:
libraryName- the library name.- Returns:
trueif the library exists,falseotherwise.
-
getRendererTypeForResourceName
The default behavior of this method is to call
ResourceHandler.getRendererTypeForResourceName(String)on the wrappedResourceHandlerobject.- Specified by:
getRendererTypeForResourceNamein classResourceHandler- Parameters:
resourceName- the resource name.- Returns:
- the renderer type.
-
markResourceRendered
The default behavior of this method is to call
ResourceHandler.markResourceRendered(FacesContext, String, String)on the wrappedResourceHandlerobject.- Overrides:
markResourceRenderedin classResourceHandler- Parameters:
context- TheFacesContextfor this request.resourceName- The name of the resource.libraryName- The name of the library in which the resource resides, may benull.- Since:
- 2.3
-
isResourceRendered
The default behavior of this method is to call
ResourceHandler.isResourceRendered(FacesContext, String, String)on the wrappedResourceHandlerobject.- Overrides:
isResourceRenderedin classResourceHandler- Parameters:
context- TheFacesContextfor this request.resourceName- The name of the resource.libraryName- The name of the library in which this resource resides, may benull.- Returns:
- Whether the resource as identified by given resource and library name has been rendered.
- Since:
- 2.3
-
getCurrentNonce
The default behavior of this method is to call
ResourceHandler.getCurrentNonce(FacesContext)on the wrappedResourceHandlerobject.- Overrides:
getCurrentNoncein classResourceHandler- Parameters:
context- TheFacesContextfor this request.- Returns:
- a Base64-encoded CSP nonce value generated from at least 128 bits of a cryptographically secure random source, or
nullif CSP nonce support is not enabled. - Since:
- 5.0
-