EN · DE · RU · FR · ES

#2770: LessResourceReference.java

projectforge-wicket/src/main/java/de/micromata/less/LessResourceReference.java Wicket Resource Reference (LESS/CSS) · projectforge-wicket/src/main/java/de/micromata/less/LessResourceReference.java 72 lines · 35 code · 27 comments · 10 blank
A custom Wicket ResourceReference implementation that bridges the compiled CSS output of the LESS compiler into Wicket's resource mounting system. Instead of serving CSS from the classpath (like a standard PackageResource), this class wraps a FileResourceStream pointing to the filesystem location where the LESS compiler writes its output — enabling dynamic CSS compilation at development time while serving the compiled result through Wicket's standard resource URL endpoints with cache-busting versioning.

Architecture

Why a Custom ResourceReference?

Standard Wicket PackageResourceReference serves files from the classpath only. The LESS compilation workflow writes .css files to a filesystem directory (under baseDir/styles/) that is not on the classpath. LessResourceReference wraps the compiled file's path and delegates to a private LessPackageResource subclass that overrides getResourceStream() to return a FileResourceStream instead of looking up the classpath. This cleanly composes with Wicket's resource mounting API — the compiled CSS is mounted as .../styles/projectforge-version-{timestamp}.css.

Class Design

The private inner class LessPackageResource extends PackageResource but bypasses its classpath lookup entirely. The constructor passes dummy values (null for locale, style, variation) since those parameters are irrelevant for a file-based resource.

Git History

CommitWhat changed
868d6abb7 through ceb63e8a1Six annual copyright header updates (2001-2021 → 2001-2026). No changes to the Java class logic or structure — this file's implementation has been stable since its initial creation. The copyright range advances each year as part of a project-wide header update sweep.