Class ThemeRegistry

java.lang.Object
org.codelibs.fess.theme.ThemeRegistry

public class ThemeRegistry extends Object
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 Details

    • fessConfig

      protected org.codelibs.fess.mylasta.direction.FessConfig fessConfig
      Injected 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 via init().
  • 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

      public Optional<Theme> getTheme(String name)
      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

      public Map<String,Theme> getAllThemes()
      Returns an immutable view of every registered theme keyed by name.
      Returns:
      unmodifiable map of registered themes
    • resolveActiveTheme

      public Optional<Theme> resolveActiveTheme(String virtualHostKey)
      Resolves the theme to apply for the current request.

      Selection order:

      1. If virtualHostKey resolves to a known theme, use it.
      2. Otherwise fall back to the global default theme stored under the Constants.DEFAULT_THEME_PROPERTY system property.
      3. Return empty when neither lookup succeeds.
      Parameters:
      virtualHostKey - theme name derived from the request's virtual host (may be null or blank)
      Returns:
      the resolved theme, or empty if none configured