Class ToolkitPackRegistry
java.lang.Object
org.apache.juneau.console.freemarker.ToolkitPackRegistry
Registry of named toolkit packs for the
<@page toolkit=...> directive and for the packs cards require.
Built-in packs:
"jquery","datatables"and"datatables-buttons"(ToolkitPack.Kind.VENDOR) — WebJars, resolved throughWEBJAR_RESOLVERto the host'sWebJarsMixinmount."datatables"depends on"jquery";"datatables-buttons"on"datatables"."datatables-glue"(ToolkitPack.Kind.VENDOR) — the first-party glue (ViewsMixin.DATATABLES_JS_PATH, served byDataTablesMixin); depends on"datatables". Every<@card type="datatables">requires it."views"(ToolkitPack.Kind.RUNTIME) — the views runtime. JS order is a contract: bus (first), renders, icons, search, pagestate, urlstate, ribbon, views, config, regions, terminal-view, helpers.juneau-urlstate.jsmust precedejuneau-views.js/juneau-config.js."calendar"(ToolkitPack.Kind.RUNTIME) — thejuneau-calendar.*runtime fromjuneau-console-widgets, resolved throughWIDGETS_RESOLVER."xterm"(ToolkitPack.Kind.VENDOR) — the xterm.js WebJar (library and stylesheet), resolved throughWEBJAR_RESOLVER."terminal"(ToolkitPack.Kind.RUNTIME) — thejuneau-terminal.*runtime fromjuneau-terminal-region, resolved throughTerminalMixin.terminalAssetUrl(RestRequest, String); depends on"views"and"xterm". Every<@card type="terminal">requires it, so a page with a terminal card needs notoolkit=."charts"(ToolkitPack.Kind.RUNTIME) —juneau-charts.jsfromjuneau-console, resolved throughConsoleChromeMixin.consoleAssetUrl(RestRequest, String); depends on"echarts"and"data". Every<@card type="chart">requires it."joblog"(ToolkitPack.Kind.RUNTIME) —juneau-joblog.jsfromjuneau-console; no dependencies. Every<@card type="job-log">requires it."echarts"(ToolkitPack.Kind.VENDOR) — the ECharts WebJar (ECHARTS_JS_ASSET), optional on the classpath: a missing jar is E-70 at startup when the app opts in (ConsoleFreemarkerMixin.Builder.requirePacks), else at the first chart page."echarts-gl"(ToolkitPack.Kind.VENDOR) — the echarts-gl WebJar; depends on"echarts"; a page opts in withtoolkit("echarts-gl")."data"(ToolkitPack.Kind.RUNTIME) —juneau-data.js(JuneauViews.data); depends on"views".
resolve(List, RestRequest, List, String) expands the requested packs depth-first over
ToolkitPack.dependsOn() (each pack after its dependencies, siblings in request order, each pack once), skips
provided packs (their dependencies still load), skips an asset whose file name the
page already loads through init= or css= (with a WARN), and splits the result by kind.
validate() checks the static graph: unknown dependsOn names, cycles, and a VENDOR pack depending on
a RUNTIME pack.
- Since:
- 10.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceResolves an asset path to an absolute, cache-busted URL against the in-flight request.static final recordResolved absolute URLs, split by pack kind. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe echarts-gl library asset id (path unverified against the WebJar; no module depends on it).static final StringThe ECharts library asset id, forWEBJAR_RESOLVER.static final StringThe built-in"calendar"pack: the already-shippingjuneau-calendar.*runtime fromjuneau-console-widgets.static final StringThe built-in chart-card runtime pack (juneau-charts.js); depends on"echarts"and"data".static final StringDashboard chrome (PageSpec.dashboard); added by the builder, never needed intoolkit(...).static final StringThe built-in DataRegistry runtime pack (juneau-data.js); depends on"views".static final StringThe built-in DataTables WebJar pack (library plus default styling CSS).static final StringThe built-in DataTables Buttons WebJar pack (copy and CSV export, no JSZip or pdfmake).static final StringThe built-in pack holding the first-party DataTables glue.static final StringThe built-in ECharts WebJar pack (org.webjars.npm:echarts, optional on the classpath).static final StringThe built-in echarts-gl WebJar pack; depends on"echarts"; never required by a card type.static final StringThe built-in job-log card runtime pack (juneau-joblog.js); no dependencies.static final StringThe built-in jQuery WebJar pack.static final StringThe built-in terminal runtime pack; depends on"views"and"xterm".static final StringThe built-in views runtime pack.static final StringThe built-in xterm.js WebJar pack (library plus stylesheet).static final ToolkitPackRegistry.AssetUrlResolverThe default resolver:ViewsMixin.viewAssetUrl(RestRequest, String).static final ToolkitPackRegistry.AssetUrlResolverThe WebJar resolver: paths areWebJarResolver.asset(String, String, String)ids.static final ToolkitPackRegistry.AssetUrlResolverThe"calendar"pack resolver:WidgetsMixin.widgetAssetUrl(RestRequest, String). -
Constructor Summary
ConstructorsConstructorDescriptionConstructs the registry with the built-in packs installed. -
Method Summary
Modifier and TypeMethodDescriptioncheckWebJars(Collection<String> roots) Probes, at startup, every WebJar the given packs reach: each non-provided VENDOR pack resolved throughWEBJAR_RESOLVER.booleanprovide(Collection<String> names) Marks packs as already loaded by the app: they contribute no URLs, but their dependencies still load.booleanvoidregister(ToolkitPack pack) Registers a pack, replacing any pack with the same name (all of its fields, includingdependsOn).voidrequireKnown(Collection<String> names, String source) Checks that every name is a registered pack.Resolves the root packs and their dependencies to absolute URLs, split by kind.validate()Checks the static graph: everydependsOnand provided name is registered, there is no cycle, and no VENDOR pack depends on a RUNTIME pack.
-
Field Details
-
PACK_VIEWS
The built-in views runtime pack.- See Also:
-
PACK_CALENDAR
The built-in"calendar"pack: the already-shippingjuneau-calendar.*runtime fromjuneau-console-widgets. Never inferred fromtype="calendar"; a calendar page lists it explicitly (e.g.toolkit="views,calendar").- See Also:
-
PACK_JQUERY
The built-in jQuery WebJar pack.- See Also:
-
PACK_DATATABLES
The built-in DataTables WebJar pack (library plus default styling CSS).- See Also:
-
PACK_DATATABLES_GLUE
The built-in pack holding the first-party DataTables glue.- See Also:
-
PACK_DATATABLES_BUTTONS
The built-in DataTables Buttons WebJar pack (copy and CSV export, no JSZip or pdfmake).- See Also:
-
PACK_XTERM
The built-in xterm.js WebJar pack (library plus stylesheet).- See Also:
-
PACK_TERMINAL
The built-in terminal runtime pack; depends on"views"and"xterm".- See Also:
-
PACK_CHARTS
The built-in chart-card runtime pack (juneau-charts.js); depends on"echarts"and"data".- See Also:
-
PACK_JOBLOG
The built-in job-log card runtime pack (juneau-joblog.js); no dependencies.- See Also:
-
PACK_DASHBOARD
Dashboard chrome (PageSpec.dashboard); added by the builder, never needed intoolkit(...).- See Also:
-
PACK_ECHARTS
The built-in ECharts WebJar pack (org.webjars.npm:echarts, optional on the classpath).- See Also:
-
PACK_ECHARTS_GL
The built-in echarts-gl WebJar pack; depends on"echarts"; never required by a card type.- See Also:
-
PACK_DATA
The built-in DataRegistry runtime pack (juneau-data.js); depends on"views".- See Also:
-
ECHARTS_JS_ASSET
The ECharts library asset id, forWEBJAR_RESOLVER. -
ECHARTS_GL_JS_ASSET
The echarts-gl library asset id (path unverified against the WebJar; no module depends on it). -
VIEWS_RESOLVER
The default resolver:ViewsMixin.viewAssetUrl(RestRequest, String). -
WIDGETS_RESOLVER
The"calendar"pack resolver:WidgetsMixin.widgetAssetUrl(RestRequest, String). -
WEBJAR_RESOLVER
The WebJar resolver: paths areWebJarResolver.asset(String, String, String)ids.
-
-
Constructor Details
-
ToolkitPackRegistry
public ToolkitPackRegistry()Constructs the registry with the built-in packs installed.
-
-
Method Details
-
register
Registers a pack, replacing any pack with the same name (all of its fields, includingdependsOn).- Parameters:
pack- The pack.
-
provide
Marks packs as already loaded by the app: they contribute no URLs, but their dependencies still load.- Parameters:
names- The pack names.- Returns:
- This object.
-
contains
- Parameters:
name- A pack name.- Returns:
true if a pack with that name is registered.
-
validate
Checks the static graph: everydependsOnand provided name is registered, there is no cycle, and no VENDOR pack depends on a RUNTIME pack.- Returns:
- This object.
- Throws:
IllegalArgumentException- On the first problem found.
-
requireKnown
Checks that every name is a registered pack.- Parameters:
names- The pack names.source- Where the names came from, for the message (e.g.<@page toolkit=>).- Throws:
IllegalArgumentException- If a name is unknown.
-
reaches
- Parameters:
root- A registered pack name.target- A pack name.- Returns:
true iftargetisrootor one of its transitivedependsOn.
-
checkWebJars
Probes, at startup, every WebJar the given packs reach: each non-provided VENDOR pack resolved throughWEBJAR_RESOLVER.- Parameters:
roots- Root pack names; empty probes nothing.- Returns:
- This object.
- Throws:
IllegalStateException- E-70 when a WebJar or its file is not on the classpath.
-
resolve
public ToolkitPackRegistry.Resolved resolve(List<String> names, RestRequest req, List<String> pageUrls, String template) Resolves the root packs and their dependencies to absolute URLs, split by kind.- Parameters:
names- The root pack names, in order. Empty ornull = nothing (no request needed).req- The in-flight request.pageUrls- The page's owninit=andcss=URLs; a pack asset with the same file name is skipped with a WARN.template- The page template name, for the WARN.- Returns:
- The resolved URLs.
- Throws:
IllegalArgumentException- On an unknown pack or a cycle.IllegalStateException- If the request is missing or a resolver fails (e.g. a WebJar isn't on the classpath).
-