Package org.codelibs.fess.theme
Class ThemeRegistry
java.lang.Object
org.codelibs.fess.theme.ThemeRegistry
Registry of static themes available to the running Fess instance.
Loads themes from the directory configured via
theme.directory.path (default themes/). Legacy JSP themes
installed as plugins are rendered via LastaFlute's view resolution and the
VirtualHostHelper; they are intentionally
not tracked here.
reload() produces an immutable snapshot under a synchronized
lock; readers (getTheme(String), getAllThemes(),
resolveActiveTheme(String)) observe the latest snapshot without
locking.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.codelibs.fess.mylasta.direction.FessConfigInjected Fess configuration used to resolve the themes directory and default theme. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns an immutable view of every registered theme keyed by name.Looks up a theme by name.voidinit()Initialises the registry by performing the first scan.voidreload()Rescans the themes directory, replacing the in-memory snapshot atomically.resolveActiveTheme(String virtualHostKey) Resolves the theme to apply for the current request.
-
Field Details
-
fessConfig
protected org.codelibs.fess.mylasta.direction.FessConfig fessConfigInjected Fess configuration used to resolve the themes directory and default theme.
-
-
Constructor Details
-
ThemeRegistry
public ThemeRegistry()Default constructor. The registry is wired by the DI container; static themes are loaded lazily viainit().
-
-
Method Details
-
init
@PostConstruct public void init()Initialises the registry by performing the first scan. Failures are logged and swallowed so a misconfigured themes directory does not break application start-up. -
reload
public void reload()Rescans the themes directory, replacing the in-memory snapshot atomically. -
getTheme
Looks up a theme by name.- Parameters:
name- theme name (blank values yield empty)- Returns:
- the matching theme, or empty when no theme with that name is registered
-
getAllThemes
Returns an immutable view of every registered theme keyed by name.- Returns:
- unmodifiable map of registered themes
-
resolveActiveTheme
Resolves the theme to apply for the current request.Selection order:
- If
virtualHostKeyresolves to a known theme, use it. - Otherwise fall back to the global default theme stored under the
Constants.DEFAULT_THEME_PROPERTYsystem property. - Return empty when neither lookup succeeds.
- Parameters:
virtualHostKey- theme name derived from the request's virtual host (may benullor blank)- Returns:
- the resolved theme, or empty if none configured
- If
-