Class FaviconMixin
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:
Behavior:
GET /favicon.icoreturns the configured icon bytes withContent-Type: image/x-iconandCache-Control: max-age=2592000, public(30 days — favicons rarely change and browsers re-fetch frequently when uncached).- The default icon (
juneau-favicon.icoon the framework classpath) is a 16×16 Juneau-branded ICO; users replace it by registering an alternate@Bean FaviconMixinwhose builder supplies different bytes. - The handler is excluded from generated Swagger / OpenAPI specs via
@OpSwagger(ignore=true)— favicons are not API-meaningful.
Builder API:
create()— entry point for configuring an instance.bytes(byte[])— raw favicon bytes.classpath(String)— load icon bytes from a classpath resource (resolved against theFaviconMixinclassloader).cacheControl(String)— override the default 30-dayCache-Controlheader.
See Also:
- Since:
- 10.0.0
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.apache.juneau.rest.server.servlet.RestMixin
RestMixin.DefaultBuilder<R extends RestMixin> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDefaultCache-Controlheader value:max-age=2592000, public(30 days). -
Constructor Summary
ConstructorsModifierConstructorDescriptionNo-arg constructor — used when a host registers the mixin without supplying a builder-configured@Bean FaviconMixin.protectedFaviconMixin(FaviconProvider worker) Worker constructor.protectedFaviconMixin(FaviconProvider worker, RestBuilder<?> builder) Worker + builder constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic FaviconMixin.Buildercreate()Creates a new builder for configuring aFaviconMixin.[GET /favicon.ico] — serve the configured favicon bytes.Methods inherited from class org.apache.juneau.rest.server.servlet.RestMixin
builder, getHostContext, getRestBuilder, setContext
-
Field Details
-
DEFAULT_CACHE_CONTROL
DefaultCache-Controlheader value:max-age=2592000, public(30 days).- See Also:
-
-
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 defaultFaviconProviderworker (the framework-shipped Juneau-branded favicon). -
FaviconMixin
Worker constructor.- Parameters:
worker- The sharedFaviconProviderworker this flavor delegates to. Must not benull .
-
FaviconMixin
Worker + builder constructor.Used by
FaviconMixin.Builder.build()to both delegate to the sharedFaviconProviderworker and stash the programmaticRestBuilder(carrying any@Rest-level overrides such aspath) so those values take precedence over the mixin class's own@Restannotation.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 FaviconProvideror BeanStore bean, per the delegate-bean model — not only via this flavor's own builder. - Takes the generic
RestBuilder(herethisfromFaviconMixin.Builder.build()) so it honors the uniform §2.4Foo(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
finalFaviconProviderfield), not a transient builder; the worker is materialized exactly once atFaviconMixin.Builder.build()time. - Keeps the capability worker and the REST-level config as two distinct inputs.
- Parameters:
worker- The sharedFaviconProviderworker this flavor delegates to. Must not benull .builder- The programmatic configuration builder. May benull .
- Takes the already-built worker bean (not the flavor
-
-
Method Details
-
create
Creates a new builder for configuring aFaviconMixin.- Returns:
- A new builder.
-
getFavicon
[GET /favicon.ico] — serve the configured favicon bytes.- Returns:
- The favicon as an
HttpResourcewith proper headers.
-