Class ResourceHandlerWrapper
- java.lang.Object
-
- jakarta.faces.application.ResourceHandler
-
- jakarta.faces.application.ResourceHandlerWrapper
-
- All Implemented Interfaces:
FacesWrapper<ResourceHandler>
public abstract class ResourceHandlerWrapper extends ResourceHandler implements FacesWrapper<ResourceHandler>
Provides a simple implementation of
ResourceHandler
that can be subclassed by developers wishing to provide specialized behavior to an existingResourceHandler
instance. The default implementation of all methods is to call through to the wrappedResourceHandler
.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 jakarta.faces.application.ResourceHandler
FACES_SCRIPT_LIBRARY_NAME, FACES_SCRIPT_RESOURCE_NAME, JSF_SCRIPT_LIBRARY_NAME, JSF_SCRIPT_RESOURCE_NAME, LOCALE_PREFIX, RESOURCE_CONTRACT_XML, RESOURCE_EXCLUDES_DEFAULT_VALUE, RESOURCE_EXCLUDES_PARAM_NAME, RESOURCE_IDENTIFIER, WEBAPP_CONTRACTS_DIRECTORY_PARAM_NAME, WEBAPP_RESOURCES_DIRECTORY_PARAM_NAME
-
-
Constructor Summary
Constructors Constructor Description ResourceHandlerWrapper()
Deprecated.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
-
-
-
Constructor Detail
-
ResourceHandlerWrapper
@Deprecated public ResourceHandlerWrapper()
Deprecated.Use the other constructor taking the implementation being wrapped.
-
ResourceHandlerWrapper
public ResourceHandlerWrapper(ResourceHandler wrapped)
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 Detail
-
getWrapped
public ResourceHandler getWrapped()
Description copied from interface:FacesWrapper
A class that implements this interface uses this method to return an instance of the class being wrapped.
- Specified by:
getWrapped
in interfaceFacesWrapper<ResourceHandler>
- Returns:
- the wrapped instance.
-
createResource
public Resource createResource(String resourceName)
The default behavior of this method is to call
ResourceHandler.createResource(String)
on the wrappedResourceHandler
object.- Specified by:
createResource
in classResourceHandler
- Parameters:
resourceName
- the name of the resource.- Returns:
- a newly created
Resource
instance, suitable for use in encoding or decoding the named resource.
-
createResourceFromId
public Resource createResourceFromId(String resourceId)
The default behavior of this method is to call
ResourceHandler.createResourceFromId(String)
on the wrappedResourceHandler
object.- Overrides:
createResourceFromId
in classResourceHandler
- Parameters:
resourceId
- the resource identifier of the resource.- Returns:
- a newly created
Resource
instance, suitable for use in encoding or decoding the named resource. - Since:
- 2.2
-
createResource
public Resource createResource(String resourceName, String libraryName)
The default behavior of this method is to call
ResourceHandler.createResource(String, String)
on the wrappedResourceHandler
object.- Specified by:
createResource
in 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
Resource
instance, suitable for use in encoding or decoding the named resource.
-
createViewResource
public ViewResource createViewResource(FacesContext context, String resourceName)
The default behavior of this method is to call
ResourceHandler.createViewResource(jakarta.faces.context.FacesContext, java.lang.String)
on the wrappedResourceHandler
object.- Overrides:
createViewResource
in classResourceHandler
- Parameters:
context
- theFacesContext
for this request.resourceName
- the name of the resource to be interpreted as a view by theViewDeclarationLanguage
.- Returns:
- a newly created
ViewResource
instance, 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 wrappedResourceHandler
object.- Overrides:
getViewResources
in classResourceHandler
- Parameters:
facesContext
- TheFacesContext
for 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. SeeResourceVisitOption
for details on those.- Returns:
- the
Stream
of 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 wrappedResourceHandler
object.- Overrides:
getViewResources
in classResourceHandler
- Parameters:
facesContext
- TheFacesContext
for this request.path
- The initial path from which to start looking for view resourcesoptions
- The options to influence the traversal. SeeResourceVisitOption
for details on those.- Returns:
- the
Stream
of view resource names - Since:
- 2.3
-
createResource
public Resource createResource(String resourceName, String libraryName, String contentType)
The default behavior of this method is to call
ResourceHandler.createResource(String, String, String)
on the wrappedResourceHandler
object.- Specified by:
createResource
in 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 thisResource
instance will return fromResource.getContentType()
. If the value isnull
, The content-type of the resource is derived by passing the resourceName toExternalContext.getMimeType(java.lang.String)
- Returns:
- a newly created
Resource
instance, suitable for use in encoding or decoding the named resource.
-
handleResourceRequest
public void handleResourceRequest(FacesContext context) throws IOException
The default behavior of this method is to call
ResourceHandler.handleResourceRequest(jakarta.faces.context.FacesContext)
on the wrappedResourceHandler
object.- Specified by:
handleResourceRequest
in classResourceHandler
- Parameters:
context
- theFacesContext
for this request- Throws:
IOException
- when an I/O error occurs.
-
isResourceRequest
public boolean isResourceRequest(FacesContext context)
The default behavior of this method is to call
ResourceHandler.isResourceRequest(jakarta.faces.context.FacesContext)
on the wrappedResourceHandler
object.- Specified by:
isResourceRequest
in classResourceHandler
- Parameters:
context
- theFacesContext
for this request- Returns:
true
if the current request is a resource request,false
otherwise.
-
isResourceURL
public boolean isResourceURL(String url)
The default behavior of this method is to call
ResourceHandler.isResourceURL(java.lang.String)
on the wrappedResourceHandler
object.- Overrides:
isResourceURL
in classResourceHandler
- Parameters:
url
- the url to inspect for the presence ofResourceHandler.RESOURCE_IDENTIFIER
.- Returns:
true
if this is a resource URL,false
otherwise.
-
libraryExists
public boolean libraryExists(String libraryName)
The default behavior of this method is to call
ResourceHandler.libraryExists(String)
on the wrappedResourceHandler
object.- Specified by:
libraryExists
in classResourceHandler
- Parameters:
libraryName
- the library name.- Returns:
true
if the library exists,false
otherwise.
-
getRendererTypeForResourceName
public String getRendererTypeForResourceName(String resourceName)
The default behavior of this method is to call
ResourceHandler.getRendererTypeForResourceName(String)
on the wrappedResourceHandler
object.- Specified by:
getRendererTypeForResourceName
in classResourceHandler
- Parameters:
resourceName
- the resource name.- Returns:
- the renderer type.
-
markResourceRendered
public void markResourceRendered(FacesContext context, String resourceName, String libraryName)
The default behavior of this method is to call
ResourceHandler.markResourceRendered(FacesContext, String, String)
on the wrappedResourceHandler
object.- Overrides:
markResourceRendered
in classResourceHandler
- Parameters:
context
- TheFacesContext
for 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
public boolean isResourceRendered(FacesContext context, String resourceName, String libraryName)
The default behavior of this method is to call
ResourceHandler.isResourceRendered(FacesContext, String, String)
on the wrappedResourceHandler
object.- Overrides:
isResourceRendered
in classResourceHandler
- Parameters:
context
- TheFacesContext
for 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
-
-