com.vaadin.flow.server.webjar.
Class WebJarServer
- java.lang.Object
-
- com.vaadin.flow.server.webjar.WebJarServer
-
All Implemented Interfaces:
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:
-
-
Constructor Summary
Constructors Constructor and Description WebJarServer(DeploymentConfiguration deploymentConfiguration)
Creates a webJar server that is able to search webJars for files and return them.
-
Method Summary
All Methods Modifier and Type Method and Description Optional<String>
getWebJarResourcePath(String filePathInContext)
Gets web jar resource path if it exists.
boolean
tryServeWebJarResource(HttpServletRequest request, HttpServletResponse response)
Searches for file requested in the webJars.
-
-
-
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, notnull
-
-
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 requestresponse
- the servlet responseReturns:
true
if response was populated with webJar contents,false
otherwiseThrows:
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 fileReturns:
an optional web jar resource path, or an empty optional if the resource is not web jar resource
-
-