Class ResourceWrapper
- java.lang.Object
- 
- jakarta.faces.application.ViewResource
- 
- jakarta.faces.application.Resource
- 
- jakarta.faces.application.ResourceWrapper
 
 
 
- 
- All Implemented Interfaces:
- FacesWrapper<Resource>
 
 public abstract class ResourceWrapper extends Resource implements FacesWrapper<Resource> Provides a simple implementation of Resourcethat can be subclassed by developers wishing to provide specialized behavior to an existingResourceinstance. The default implementation of all methods is to call through to the wrappedResource.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.ResourceCOMPONENT_RESOURCE_KEY
 
- 
 - 
Constructor SummaryConstructors Constructor Description ResourceWrapper()Deprecated.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 SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetContentType()The default behavior of this method is to callResource.getContentType()on the wrappedResourceHandlerobject.InputStreamgetInputStream()The default behavior of this method is to callResource.getInputStream()on the wrappedResourceHandlerobject.StringgetLibraryName()The default behavior of this method is to callResource.getLibraryName()on the wrappedResourceHandlerobject.StringgetRequestPath()The default behavior of this method is to callResource.getRequestPath()on the wrappedResourceHandlerobject.StringgetResourceName()The default behavior of this method is to callResource.getResourceName()on the wrappedResourceHandlerobject.Map<String,String>getResponseHeaders()The default behavior of this method is to callResource.getResponseHeaders()on the wrappedResourceHandlerobject.URLgetURL()The default behavior of this method is to callResource.getURL()on the wrappedResourceHandlerobject.ResourcegetWrapped()A class that implements this interface uses this method to return an instance of the class being wrapped.voidsetContentType(String contentType)The default behavior of this method is to callResource.setContentType(String)on the wrappedResourceHandlerobject.voidsetLibraryName(String libraryName)The default behavior of this method is to callResource.setLibraryName(String)on the wrappedResourceHandlerobject.voidsetResourceName(String resourceName)The default behavior of this method is to callResource.setResourceName(String)on the wrappedResourceHandlerobject.booleanuserAgentNeedsUpdate(FacesContext context)The default behavior of this method is to callResource.userAgentNeedsUpdate(jakarta.faces.context.FacesContext)on the wrappedResourceHandlerobject.
 
- 
- 
- 
Constructor Detail- 
ResourceWrapperpublic ResourceWrapper(Resource wrapped) 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 public ResourceWrapper() Deprecated.Use the other constructor taking the implementation being wrapped.
 
- 
 - 
Method Detail- 
getWrappedpublic Resource 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 interface- FacesWrapper<Resource>
- Returns:
- the wrapped instance.
 
 - 
getInputStreampublic InputStream getInputStream() throws IOException The default behavior of this method is to call Resource.getInputStream()on the wrappedResourceHandlerobject.- Specified by:
- getInputStreamin class- Resource
- Returns:
- an InputStreamcontaining 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.
 
 - 
getURLpublic URL getURL() The default behavior of this method is to call Resource.getURL()on the wrappedResourceHandlerobject.
 - 
getResponseHeaderspublic Map<String,String> getResponseHeaders() The default behavior of this method is to call Resource.getResponseHeaders()on the wrappedResourceHandlerobject.- Specified by:
- getResponseHeadersin class- Resource
- Returns:
- a mutable Map<String, String>of headers that will be included with the response.
 
 - 
getRequestPathpublic String getRequestPath() The default behavior of this method is to call Resource.getRequestPath()on the wrappedResourceHandlerobject.- Specified by:
- getRequestPathin class- Resource
- 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.
 
 - 
userAgentNeedsUpdatepublic boolean userAgentNeedsUpdate(FacesContext context) The default behavior of this method is to call Resource.userAgentNeedsUpdate(jakarta.faces.context.FacesContext)on the wrappedResourceHandlerobject.- Specified by:
- userAgentNeedsUpdatein class- Resource
- Parameters:
- context- the Faces context.
- Returns:
- trueor- falsedepending on whether or not the user-agent needs an update of this resource.
 
 - 
getContentTypepublic String getContentType() The default behavior of this method is to call Resource.getContentType()on the wrappedResourceHandlerobject.- Overrides:
- getContentTypein class- Resource
- Returns:
- the MIME content-type for this resource.
 
 - 
setContentTypepublic void setContentType(String contentType) The default behavior of this method is to call Resource.setContentType(String)on the wrappedResourceHandlerobject.- Overrides:
- setContentTypein class- Resource
- Parameters:
- contentType- the MIME content-type for this resource. The default implementation must accept- nullas a parameter.
 
 - 
getLibraryNamepublic String getLibraryName() The default behavior of this method is to call Resource.getLibraryName()on the wrappedResourceHandlerobject.- Overrides:
- getLibraryNamein class- Resource
- Returns:
- Return the libraryName for this resource. May be null.
 
 - 
setLibraryNamepublic void setLibraryName(String libraryName) The default behavior of this method is to call Resource.setLibraryName(String)on the wrappedResourceHandlerobject.- Overrides:
- setLibraryNamein class- Resource
- Parameters:
- libraryName- the libraryName for this resource. The default implementation must accept- nullfor the libraryName.
 
 - 
getResourceNamepublic String getResourceName() The default behavior of this method is to call Resource.getResourceName()on the wrappedResourceHandlerobject.- Overrides:
- getResourceNamein class- Resource
- Returns:
- Return the resourceName for this resource. Will never be null.
 
 - 
setResourceNamepublic void setResourceName(String resourceName) The default behavior of this method is to call Resource.setResourceName(String)on the wrappedResourceHandlerobject.- Overrides:
- setResourceNamein class- Resource
- Parameters:
- resourceName- a non-null String.
 
 
- 
 
-