Class ConsoleFreemarkerMixin
FreemarkerMixin that additionally makes the reserved-classpath admin-console chrome template
(org/apache/juneau/console/base.ftlh) — and the <@tag> macro it defines — resolvable
from any consumer template, without shadowing the consumer's own basePath-rooted template tree.
Used INSTEAD OF FreemarkerMixin, not beside it:
Register it typed as either FreemarkerMixin or ConsoleFreemarkerMixin — both declared
return types work. FreemarkerViewRenderer finds the exact-type FreemarkerMixin bean when one is
registered, and otherwise also looks for a bean declared under any registered subtype, which this class
registers via a static initializer:
or equivalently:
Consumer /templates is never shadowed:
The augmented Configuration's TemplateLoader tries the consumer's own basePath-derived
loader first; the reserved template is addressed by its full classpath-root-relative path
(BASE_TEMPLATE_PATH) on a second, classpath-root-rooted ClassTemplateLoader, so it cannot
collide with a consumer path such as /templates/base.ftlh. Consumer templates include it with a
loader-root-absolute path:
<#include "/org/apache/juneau/console/base.ftlh">
Consumer-supplied Configuration is the same instance, then fill-missing stamped:
When the request's BeanStore already has a Configuration bean (Spring/Spring-Boot autoconfig, or
a microservice BasicBeanStore.put), resolveConfiguration(org.apache.juneau.rest.server.RestRequest) still returns that same instance
(==) so consumer settings win (encoding, ObjectWrapper, exposeFields, template-update
delay, output format). It then fill-missing-stamps the reserved console shared variables
(page, card, navigation, node, theme, token, console,
main, the <@console> slot names head/scripts/brand/actions/
title/footer/body, and jcTagHtml) and splices the
reserved-path console loader only when BASE_TEMPLATE_PATH would not already resolve. A name the
consumer already set is left alone. There is no opt-out flag on this class — opt out by registering
FreemarkerMixin instead of ConsoleFreemarkerMixin.
- Since:
- 10.0.0
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe reserved classpath-root-relative location of the shipped console chrome template (defines the<@tag>macro).static final StringDefault consumer chrome template included by<@page>when none is configured.Fields inherited from class org.apache.juneau.rest.server.view.freemarker.FreemarkerMixin
DEFAULT_BASE_PATH, DEFAULT_CACHE_TEMPLATES, DEFAULT_EXPOSE_FIELDS, DEFAULT_TEMPLATE_SUFFIX -
Constructor Summary
ConstructorsModifierConstructorDescriptionNo-arg constructor — mirrorsFreemarkerMixin()so the mixin walk'sBeanInstantiatoris not forced to depend on builder-detection alone.protectedBuilder constructor. -
Method Summary
Modifier and TypeMethodDescriptioncreate()Creates a new builder.freemarker.template.ConfigurationResolves the activeConfigurationand fill-missing-stamps console shared variables onto it.Methods inherited from class org.apache.juneau.rest.server.view.freemarker.FreemarkerMixin
applyTemplateSuffix, getBasePath, getObjectWrapper, getTemplateSuffix, isCacheTemplates, isExposeFields, registeredSubtypes, registerSubtype, render
-
Field Details
-
BASE_TEMPLATE_PATH
The reserved classpath-root-relative location of the shipped console chrome template (defines the<@tag>macro). Load-bearing for the collision-free-namespacing argument in the class javadoc — do not shorten.- See Also:
-
DEFAULT_CHROME_TEMPLATE
Default consumer chrome template included by<@page>when none is configured.- See Also:
-
-
Constructor Details
-
ConsoleFreemarkerMixin
public ConsoleFreemarkerMixin()No-arg constructor — mirrorsFreemarkerMixin()so the mixin walk'sBeanInstantiatoris not forced to depend on builder-detection alone. -
ConsoleFreemarkerMixin
Builder constructor.- Parameters:
builder- The builder. Must not benull.- Throws:
IllegalArgumentException- If the toolkit packs, provided packs or card requirements don't validate.IllegalStateException- E-70 if a required pack reaches a WebJar that is not on the classpath (seeConsoleFreemarkerMixin.Builder.requirePacks(String...)).
-
-
Method Details
-
create
Creates a new builder.- Returns:
- A new builder.
-
resolveConfiguration
Resolves the activeConfigurationand fill-missing-stamps console shared variables onto it.Always delegates to
super.resolveConfiguration(req)first so a consumerConfigurationbean wins for settings. Then:- Fill-missing names:
page,card,navigation,node,theme,token,console,main, the<@console>slot names (head,scripts,brand,actions,title,footer,body), andjcTagHtmlare set only whengetSharedVariable(name)is unset. A consumer value is kept. - Loader splice: the classpath-root console
ClassTemplateLoaderis wrapped in only whenBASE_TEMPLATE_PATHwould not already resolve through the current loader. - Wrap-once + presence: identity-cached per mixin instance so a second call does not
re-wrap; presence checks so N Rest resources sharing one Spring singleton
Configurationdo not nestMultiTemplateLoader.
- Overrides:
resolveConfigurationin classFreemarkerMixin- Parameters:
req- The current REST request.- Returns:
- The active FreeMarker configuration. Never
null.
- Fill-missing names:
-