Class StaticHttpHandlerBase

    • Constructor Detail

      • StaticHttpHandlerBase

        public StaticHttpHandlerBase()
    • Method Detail

      • isFileCacheEnabled

        public boolean isFileCacheEnabled()
        Returns true if this StaticHttpHandler has been configured to use file cache to serve static resources, or false otherwise. Please note, even though this StaticHttpHandler might be configured to use file cache, file cache itself might be disabled FileCache.isEnabled(). In this case StaticHttpHandler will operate as if file cache was disabled.
        Returns:
        true if this StaticHttpHandler has been configured to use file cache to serve static resources, or false otherwise.
      • setFileCacheEnabled

        public void setFileCacheEnabled​(boolean isFileCacheEnabled)
        Set true to configure this StaticHttpHandler to use file cache to serve static resources, or false otherwise. Please note, even though this StaticHttpHandler might be configured to use file cache, file cache itself might be disabled FileCache.isEnabled(). In this case StaticHttpHandler will operate as if file cache was disabled.
        Parameters:
        isFileCacheEnabled - true to configure this StaticHttpHandler to use file cache to serve static resources, or false otherwise.
      • sendFile

        public static void sendFile​(Response response,
                                    java.io.File file)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • addToFileCache

        public final boolean addToFileCache​(Request req,
                                            Response res,
                                            java.io.File resource)
      • service

        public void service​(Request request,
                            Response response)
                     throws java.lang.Exception
        Based on the Request URI, try to map the file from the #getDocRoots(), and send it back to a client.
        Specified by:
        service in class HttpHandler
        Parameters:
        request - the Request
        response - the Response
        Throws:
        java.lang.Exception
      • getRelativeURI

        protected java.lang.String getRelativeURI​(Request request)
                                           throws java.lang.Exception
        Throws:
        java.lang.Exception
      • onMissingResource

        protected void onMissingResource​(Request request,
                                         Response response)
                                  throws java.lang.Exception
        The method will be called, if the static resource requested by the Request wasn't found, so StaticHttpHandler implementation may try to workaround this situation. The default implementation - sends a 404 response page by calling #customizedErrorPage(Request, Response).
        Parameters:
        request - the Request
        response - the Response
        Throws:
        java.lang.Exception
      • handle

        protected abstract boolean handle​(java.lang.String uri,
                                          Request request,
                                          Response response)
                                   throws java.lang.Exception
        Lookup a resource based on the request URI, and process it.
        Parameters:
        uri - The request URI
        request - the Request
        response - the Response
        Returns:
        true, if the static resource has been found and processed, or false, if the static resource hasn't been found
        Throws:
        java.lang.Exception
      • pickupContentType

        protected static void pickupContentType​(Response response,
                                                java.lang.String path)
      • addCachingHeaders

        protected static void addCachingHeaders​(Response response,
                                                java.io.File file)