Class ResourceWrapper

  • All Implemented Interfaces:
    FacesWrapper<Resource>


    public abstract class ResourceWrapper
    extends Resource
    implements 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
    • Constructor Detail

      • ResourceWrapper

        @Deprecated
        public ResourceWrapper​()
        Deprecated. Use the other constructor taking the implementation being wrapped.
      • ResourceWrapper

        public 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
    • Method Detail

      • getWrapped

        public Resource 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 interface FacesWrapper<Resource>
        Returns:
        the wrapped instance.
      • getInputStream

        public java.io.InputStream getInputStream​()
                                           throws java.io.IOException

        The default behavior of this method is to call Resource.getInputStream() on the wrapped ResourceHandler object.

        Specified by:
        getInputStream in class Resource
        Returns:
        an InputStream containing the bytes of the resource.

        Any EL expressions present in the resource must be evaluated before serving the bytes of the resource. Note that due to browser and server caching, EL expressions in a resource file will generally only be evaluated once, when the resource is first served up. Therefore, using EL expressions that refer to per-request data is not advisable since this data can become stale.

        Throws:
        java.io.IOException - if the current request is not a resource request.
      • getURL

        public java.net.URL getURL​()

        The default behavior of this method is to call Resource.getURL() on the wrapped ResourceHandler object.

        Specified by:
        getURL in class Resource
        Returns:
        Return an actual URL instance that refers to this resource instance.
      • getResponseHeaders

        public java.util.Map<java.lang.String,java.lang.String> getResponseHeaders​()

        The default behavior of this method is to call Resource.getResponseHeaders() on the wrapped ResourceHandler object.

        Specified by:
        getResponseHeaders in class Resource
        Returns:
        a mutable Map<String, String> of headers that will be included with the response.
      • getRequestPath

        public java.lang.String getRequestPath​()

        The default behavior of this method is to call Resource.getRequestPath() on the wrapped ResourceHandler object.

        Specified by:
        getRequestPath in 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.
      • setContentType

        public void setContentType​(java.lang.String contentType)

        The default behavior of this method is to call Resource.setContentType(String) on the wrapped ResourceHandler object.

        Overrides:
        setContentType in class Resource
        Parameters:
        contentType - the MIME content-type for this resource. The default implementation must accept null as a parameter.
      • setLibraryName

        public void setLibraryName​(java.lang.String libraryName)

        The default behavior of this method is to call Resource.setLibraryName(String) on the wrapped ResourceHandler object.

        Overrides:
        setLibraryName in class Resource
        Parameters:
        libraryName - the libraryName for this resource. The default implementation must accept null for the libraryName.