Class FrontendDependencyUrlResolver
- All Implemented Interfaces:
Serializable
value() of frontend dependency annotations to a
canonical form that
BootstrapHandler.BootstrapUriResolver can
expand at render time.
The same rules are used whether the annotation is on an
AppShellConfigurator or on an ordinary
Component.
Used for StyleSheet values, and
for the JavaScript values that
are loaded at runtime instead of being bundled. Callers should note that a
rejected value (see the rules below) yields null rather than an
exception, and that the dependency is then skipped.
For internal framework use only.
- Since:
- 25.1.19
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisRuntimeDependencyUrl(String value) Tells whether the given value is a runtime-loaded URL ? i.e. should be served by the servlet container at runtime rather than passed to the frontend bundler.static booleanisRuntimeJavaScript(JavaScript javaScript) Tells whether the givenJavaScriptannotation is loaded at runtime as ascriptelement rather than bundled.static StringresolveRuntimeJavaScript(String value) Normalizes the value of aJavaScriptannotation that is loaded at runtime (seeisRuntimeJavaScript(JavaScript)) so that the bootstrap URI resolver can expand it.static StringresolveToContextRoot(String rawValue) Normalizes a frontend-dependency URL value to a form that the bootstrap URI resolver can expand.
-
Method Details
-
resolveToContextRoot
Normalizes a frontend-dependency URL value to a form that the bootstrap URI resolver can expand.Rules, in order:
nullor blank values returnnull.- Values containing path traversals (
..) are rejected with a warning andnullis returned. http://,https://,//,context://andbase://prefixes, and URLs with any other scheme (a value containing://), are returned unchanged.- A leading
./is stripped. - If the value (after the previous step) starts with
/, it is returned unchanged. - Otherwise,
context://is prepended so the value resolves against the servlet context root.
- Parameters:
rawValue- the raw annotation value- Returns:
- the normalized value, or
nullif rejected
-
isRuntimeDependencyUrl
Tells whether the given value is a runtime-loaded URL ? i.e. should be served by the servlet container at runtime rather than passed to the frontend bundler.Returns
truefor values starting with any of:http://,https://,//,context://,base://, or/, and for URLs with any other scheme (a value containing://), which the bundler skips as well (seeUrlUtil.isExternal(java.lang.String)). Returnsfalsefornull, blank, or any other value (e.g. bare relative paths and bundler import specifiers).- Parameters:
value- the raw annotation value- Returns:
trueif the value is a runtime URL- Since:
- 25.4
-
isRuntimeJavaScript
Tells whether the givenJavaScriptannotation is loaded at runtime as ascriptelement rather than bundled.That is the case for
JavaScript.Type.MODULEvalues and for runtime URLs (seeisRuntimeDependencyUrl(String)).- Parameters:
javaScript- the annotation to check, notnull- Returns:
trueif the value is loaded at runtime- Since:
- 25.4
-
resolveRuntimeJavaScript
Normalizes the value of aJavaScriptannotation that is loaded at runtime (seeisRuntimeJavaScript(JavaScript)) so that the bootstrap URI resolver can expand it.Values with a protocol (external URLs but also
context://andbase://) are returned unchanged. All other values, such as absolute paths or bare relativeJavaScript.Type.MODULEvalues, go throughresolveToContextRoot(String).- Parameters:
value- the raw annotation value- Returns:
- the normalized value, or
nullif the value was rejected - Since:
- 25.4
-