Class DevResource

  • All Implemented Interfaces:
    javax.faces.FacesWrapper<javax.faces.application.Resource>
    Direct Known Subclasses:
    DevResource

    public class DevResource
    extends javax.faces.application.ResourceWrapper
    A resource meant only for development. It reads the resource directly from the file system and makes sure it is never cached. This is useful especially for transpiled JavaScript or CSS files that change while the server is running.

    To enable this feature, you must start formcycle with the dev mode profile:

    • Faces development stage must be set to Production
    • The system property de.xima.fc.dev_mode must be set to true.

    To use this feature, you must add either dev-path or dev-path-base as a URL parameter to a Faces resource URL. dev-path points directly to the path of the file on the file system, dev-path-base appends the path of the Faces resource to the base URL. The path may be relative, in which case it is resolved against the value of the system property

    Author:
    XIMA MEDIA GmbH
    • Constructor Detail

      • DevResource

        public DevResource​(javax.faces.application.Resource wrapped,
                           String devPath)
        Parameters:
        wrapped - Original compressed resource for which a development resource exists.
        devPath - Path to the development resource on the file system.
      • DevResource

        public DevResource​(javax.faces.application.Resource wrapped,
                           String devPath,
                           String devPathBase)
        Parameters:
        wrapped - Original compressed resource for which a development resource exists.
        devPath - Path to the development resource on the file system, required.
        devPathBase - Base path for the development resource, may be empty. Added to imports in the resource's content, e.g. @import "..." in CSS files.
    • Method Detail

      • getInputStream

        public InputStream getInputStream()
                                   throws IOException
        Overrides:
        getInputStream in class javax.faces.application.ResourceWrapper
        Throws:
        IOException
      • getRequestPath

        public String getRequestPath()
        Overrides:
        getRequestPath in class javax.faces.application.ResourceWrapper
      • userAgentNeedsUpdate

        public boolean userAgentNeedsUpdate​(javax.faces.context.FacesContext context)
        Overrides:
        userAgentNeedsUpdate in class javax.faces.application.ResourceWrapper
      • wrap

        public static javax.faces.application.Resource wrap​(javax.faces.application.Resource resource,
                                                            String devPath)
        Wraps the resource with the dev path, if dev mode is enabled.
        Parameters:
        resource - Resource to wrap.
        devPath - Dev path with the dev resource.
        Returns:
        A wrapped dev resource.