Class FaviconMixin

java.lang.Object
org.apache.juneau.rest.server.servlet.RestMixin
org.apache.juneau.rest.server.convention.FaviconMixin

public class FaviconMixin extends RestMixin
Mixin that serves a favicon.ico icon at /favicon.ico.

Sibling of SeoMixin (robots.txt / sitemap.xml), VersionMixin (/version), and WellKnownMixin (/.well-known/*). All four classes live in the org.apache.juneau.rest.server.convention convention-endpoints mixin pack.

Compose into a host resource via @Rest(mixins=FaviconMixin.class); the /favicon.ico URL becomes available alongside the host's own endpoints with no further wiring.

Hardcoded mount path:

Unlike the sibling api-docs and ops mixins (see SwaggerMixin, VersionMixin, etc.) the mount path here is not SVL-configurable — /favicon.ico is fixed by browser convention and the link rel="icon" default the HTML spec inherits from WHATWG HTML. Browsers fetch /favicon.ico from the site root regardless of any application-level routing rewrites, so a runtime mount-path override here would have no practical effect.

Mixin-only deployment:

This resource is designed for composition via @Rest(mixins=...). The mount path is pinned at the op level by @RestGet(path="/favicon.ico") on getFavicon(); a class-level @Rest(paths=...) declaration would be silently ignored under the mixin pattern (see @Rest(paths) Javadoc).

Composition example:

@Rest(path="/api", mixins=FaviconMixin.class) public class ApiResource extends RestServlet { // Use the default Juneau-branded favicon. } // Or override the icon bytes via a @Bean factory: @Bean FaviconMixin favicon() { return FaviconMixin.create().bytes(myLogoBytes).build(); }

Behavior:
  • GET /favicon.ico returns the configured icon bytes with Content-Type: image/x-icon and Cache-Control: max-age=2592000, public (30 days — favicons rarely change and browsers re-fetch frequently when uncached).
  • The default icon (juneau-favicon.ico on the framework classpath) is a 16×16 Juneau-branded ICO; users replace it by registering an alternate @Bean FaviconMixin whose builder supplies different bytes.
  • The handler is excluded from generated Swagger / OpenAPI specs via @OpSwagger(ignore=true) — favicons are not API-meaningful.
Builder API:
See Also:
Since:
10.0.0
  • Field Details

  • Constructor Details

    • FaviconMixin

      public FaviconMixin()
      No-arg constructor — used when a host registers the mixin without supplying a builder-configured @Bean FaviconMixin. Delegates to a default FaviconProvider worker (the framework-shipped Juneau-branded favicon).
    • FaviconMixin

      protected FaviconMixin(FaviconProvider worker)
      Worker constructor.
      Parameters:
      worker - The shared FaviconProvider worker this flavor delegates to. Must not be null.
    • FaviconMixin

      protected FaviconMixin(FaviconProvider worker, RestBuilder<?> builder)
      Worker + builder constructor.

      Used by FaviconMixin.Builder.build() to both delegate to the shared FaviconProvider worker and stash the programmatic RestBuilder(carrying any @Rest-level overrides such as path) so those values take precedence over the mixin class's own @Rest annotation.

      Why worker + builder, not the flavor Builder:
      • Takes the already-built worker bean (not the flavor FaviconMixin.Builder) so the flavor can be constructed from ANY independently-supplied worker — e.g. a user's own @Bean FaviconProvider or BeanStore bean, per the delegate-bean model — not only via this flavor's own builder.
      • Takes the generic RestBuilder(here this from FaviconMixin.Builder.build()) so it honors the uniform §2.4 Foo(RestBuilder<?>) injection contract the base class and DI resolution key on; the base knows nothing about the concrete flavor builder or the worker type.
      • Holds the finished worker product (the final FaviconProvider field), not a transient builder; the worker is materialized exactly once at FaviconMixin.Builder.build() time.
      • Keeps the capability worker and the REST-level config as two distinct inputs.
      Parameters:
      worker - The shared FaviconProvider worker this flavor delegates to. Must not be null.
      builder - The programmatic configuration builder. May be null.
  • Method Details