- All Implemented Interfaces:
FacesWrapper<Resource>
Provides a simple implementation of Resource
that can be subclassed by developers wishing to provide specialized behavior to an existing Resource
instance. The default implementation of all methods is to call through to the wrapped Resource
.
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.Resource
COMPONENT_RESOURCE_KEY
-
Constructor Summary
ConstructorDescriptionDeprecated.Use the other constructor taking the implementation being wrapped.ResourceWrapper
(Resource wrapped) If this resource has been decorated, the implementation doing the decorating should push the implementation being wrapped to this constructor. -
Method Summary
Modifier and TypeMethodDescriptionThe default behavior of this method is to callResource.getContentType()
on the wrappedResourceHandler
object.The default behavior of this method is to callResource.getInputStream()
on the wrappedResourceHandler
object.The default behavior of this method is to callResource.getLibraryName()
on the wrappedResourceHandler
object.The default behavior of this method is to callResource.getRequestPath()
on the wrappedResourceHandler
object.The default behavior of this method is to callResource.getResourceName()
on the wrappedResourceHandler
object.The default behavior of this method is to callResource.getResponseHeaders()
on the wrappedResourceHandler
object.getURL()
The default behavior of this method is to callResource.getURL()
on the wrappedResourceHandler
object.A class that implements this interface uses this method to return an instance of the class being wrapped.void
setContentType
(String contentType) The default behavior of this method is to callResource.setContentType(String)
on the wrappedResourceHandler
object.void
setLibraryName
(String libraryName) The default behavior of this method is to callResource.setLibraryName(String)
on the wrappedResourceHandler
object.void
setResourceName
(String resourceName) The default behavior of this method is to callResource.setResourceName(String)
on the wrappedResourceHandler
object.boolean
userAgentNeedsUpdate
(FacesContext context) The default behavior of this method is to callResource.userAgentNeedsUpdate(jakarta.faces.context.FacesContext)
on the wrappedResourceHandler
object.
-
Constructor Details
-
ResourceWrapper
If this resource 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
-
ResourceWrapper
Deprecated.Use the other constructor taking the implementation being wrapped.
-
-
Method Details
-
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<Resource>
- Returns:
- the wrapped instance.
-
getInputStream
The default behavior of this method is to call
Resource.getInputStream()
on the wrappedResourceHandler
object.- Specified by:
getInputStream
in classResource
- Returns:
- an
InputStream
containing the bytes of the resource.Any Jakarta Expression Language expressions present in the resource must be evaluated before serving the bytes of the resource. Note that due to browser and server caching, Jakarta Expression Language expressions in a resource file will generally only be evaluated once, when the resource is first served up. Therefore, using Jakarta Expression Language expressions that refer to per-request data is not advisable since this data can become stale.
- Throws:
IOException
- if the current request is not a resource request.
-
getURL
The default behavior of this method is to call
Resource.getURL()
on the wrappedResourceHandler
object. -
getResponseHeaders
The default behavior of this method is to call
Resource.getResponseHeaders()
on the wrappedResourceHandler
object.- Specified by:
getResponseHeaders
in classResource
- Returns:
- a mutable
Map<String, String>
of headers that will be included with the response.
-
getRequestPath
The default behavior of this method is to call
Resource.getRequestPath()
on the wrappedResourceHandler
object.- Specified by:
getRequestPath
in classResource
- Returns:
- the path to this resource, intended to be included in the encoded view that is sent to the browser when sending a faces response.
-
userAgentNeedsUpdate
The default behavior of this method is to call
Resource.userAgentNeedsUpdate(jakarta.faces.context.FacesContext)
on the wrappedResourceHandler
object.- Specified by:
userAgentNeedsUpdate
in classResource
- Parameters:
context
- the Faces context.- Returns:
true
orfalse
depending on whether or not the user-agent needs an update of this resource.
-
getContentType
The default behavior of this method is to call
Resource.getContentType()
on the wrappedResourceHandler
object.- Overrides:
getContentType
in classResource
- Returns:
- the MIME content-type for this resource.
-
setContentType
The default behavior of this method is to call
Resource.setContentType(String)
on the wrappedResourceHandler
object.- Overrides:
setContentType
in classResource
- Parameters:
contentType
- the MIME content-type for this resource. The default implementation must acceptnull
as a parameter.
-
getLibraryName
The default behavior of this method is to call
Resource.getLibraryName()
on the wrappedResourceHandler
object.- Overrides:
getLibraryName
in classResource
- Returns:
- Return the libraryName for this resource. May be
null
.
-
setLibraryName
The default behavior of this method is to call
Resource.setLibraryName(String)
on the wrappedResourceHandler
object.- Overrides:
setLibraryName
in classResource
- Parameters:
libraryName
- the libraryName for this resource. The default implementation must acceptnull
for the libraryName.
-
getResourceName
The default behavior of this method is to call
Resource.getResourceName()
on the wrappedResourceHandler
object.- Overrides:
getResourceName
in classResource
- Returns:
- Return the resourceName for this resource. Will never be null.
-
setResourceName
The default behavior of this method is to call
Resource.setResourceName(String)
on the wrappedResourceHandler
object.- Overrides:
setResourceName
in classResource
- Parameters:
resourceName
- a non-null String.
-