com.vaadin.flow.server.webjar.

Class WebJarServer

  • All Implemented Interfaces:

    Serializable


    public class WebJarServer
    extends Object
    implements Serializable

    Handles requests that may require webJars contents. In this case, writes the required resource contents from a webJar into the response.

    By default, webJars are enabled for development mode and disabled for production mode. There is a way to override this behavior by setting Constants.DISABLE_WEBJARS param.

    Since:

    1.0.

    Author:

    Vaadin Ltd

    See Also:

    Serialized Form

    • Constructor Detail

      • WebJarServer

        public WebJarServer(DeploymentConfiguration deploymentConfiguration)

        Creates a webJar server that is able to search webJars for files and return them.

        Parameters:

        deploymentConfiguration - configuration for the deployment, not null

    • Method Detail

      • tryServeWebJarResource

        public boolean tryServeWebJarResource(HttpServletRequest request,
                                              HttpServletResponse response)
                                       throws IOException

        Searches for file requested in the webJars. If found, the file contents is written into request.

        Parameters:

        request - the servlet request

        response - the servlet response

        Returns:

        true if response was populated with webJar contents, false otherwise

        Throws:

        IOException - if response population fails

      • getWebJarResourcePath

        public Optional<String> getWebJarResourcePath(String filePathInContext)

        Gets web jar resource path if it exists.

        Parameters:

        filePathInContext - servlet context path for file

        Returns:

        an optional web jar resource path, or an empty optional if the resource is not web jar resource