Class VersionMixin
/version (configurable).
Sibling of FaviconMixin, SeoMixin, and
WellKnownMixin. All four classes live in the
org.apache.juneau.rest.server.convention convention-endpoints mixin pack.
Compose into a host resource via
@Rest(mixins=VersionMixin.class); the /version URL becomes available
alongside the host's own endpoints with no further wiring.
Configurable mount path:
The default mount /version can be overridden via the SVL variable
${juneau.version.path:version} — set via system property
(-Djuneau.version.path=build-info), environment variable
(JUNEAU_VERSION_PATH=build-info), or Config key
(juneau.version.path = build-info) to change the runtime mount without subclassing.
Resolution happens once at RestContext construction time.
Override accepts bare token (version), leading slash (/version), or trailing
slash (version/) — all resolve to the same mount.
Migration note (10.0.0): Earlier development snapshots of this mixin mounted at three
historical aliases — /version, /info, and /about — on a
single op. That multi-path default has been collapsed to a single SVL-configurable mount as
part of the "single path per op" principle. Deployers who relied on the
/info or /about aliases must now either set
-Djuneau.version.path=info (or about), compose a second instance with the
desired override, or subclass and supply their own @RestGet(path=...) method.
Mixin-only deployment:
This resource is designed for composition via @Rest(mixins=...). The mount path is
pinned at the op level by @RestGet(path="/{juneau.version.path:version}") on
getInfo(org.apache.juneau.rest.server.RestResponse); a class-level @Rest(paths=...) declaration would be silently
ignored under the mixin pattern (see @Rest(paths) Javadoc).
Composition example:
Default lookup chain:
The default fromManifest() reader walks the
VersionMixin classloader for /META-INF/MANIFEST.MF and reads the standard
Implementation-Title, Implementation-Version, Implementation-Vendor, and
Build-Jdk attributes (lowercased to name, version, vendor,
javaVersion). The default fromGitProperties() reader
walks the same classloader for /git.properties (the canonical
git-commit-id-maven-plugin output) and surfaces git.commit.id,
git.branch, and git.build.time as gitCommit, gitBranch, and
buildTime. Missing files / missing keys map to "(unknown)" or are simply omitted
— never an exception.
Spring Boot fat-jar caveat: Spring Boot rewrites MANIFEST.MF during repackaging.
The mixin's no-arg-default reader uses VersionMixin.class.getClassLoader();
users who want the importer's app manifest under a Spring Boot executable jar should register an
explicit fromManifest(importerClassLoader) call so the
lookup starts from the importer's classloader rather than the framework's.
Output:
The endpoint returns a JSON map — e.g.:
{
Endpoints are excluded from generated Swagger / OpenAPI specs via
@OpSwagger(ignore=true).
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
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionNo-arg constructor — delegates to a defaultVersionProviderworker (readsMANIFEST.MF,git.properties, and the JVM version from the framework classloader).protectedVersionMixin(VersionProvider worker) Worker constructor.protectedVersionMixin(VersionProvider worker, RestBuilder<?> builder) Worker + builder constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic VersionMixin.Buildercreate()Creates a new builder, with@Value-annotated fields populated throughBeanInstantiatorfrom the activeSettingschain.static VersionMixin.BuildervoidgetInfo(RestResponse res) [GET /version] — emit the assembled metadata as a JSON map.Returns the configured info map (test/inspection helper).Methods inherited from class org.apache.juneau.rest.server.servlet.RestMixin
builder, getHostContext, getRestBuilder, setContext
-
Field Details
-
UNKNOWN
Sentinel value returned for entries that the worker couldn't resolve.- See Also:
-
-
Constructor Details
-
VersionMixin
public VersionMixin()No-arg constructor — delegates to a defaultVersionProviderworker (readsMANIFEST.MF,git.properties, and the JVM version from the framework classloader). -
VersionMixin
Worker constructor.- Parameters:
worker- The sharedVersionProviderworker this flavor delegates to. Must not benull .
-
VersionMixin
Worker + builder constructor.Used by
VersionMixin.Builder.build()to both delegate to the sharedVersionProviderworker 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
VersionMixin.Builder) so the flavor can be constructed from ANY independently-supplied worker — e.g. a user's own@Bean VersionProvideror BeanStore bean, per the delegate-bean model — not only via this flavor's own builder. - Takes the generic
RestBuilder(herethisfromVersionMixin.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
finalVersionProviderfield), not a transient builder; the worker is materialized exactly once atVersionMixin.Builder.build()time. - Keeps the capability worker and the REST-level config as two distinct inputs.
- Parameters:
worker- The sharedVersionProviderworker 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, with@Value-annotated fields populated throughBeanInstantiatorfrom the activeSettingschain.- Returns:
- A new builder.
-
create
- Parameters:
beanStore- The bean store to use for dependency injection.- Returns:
- A new builder.
-
getInfo
[GET /version] — emit the assembled metadata as a JSON map.- Parameters:
res- The current REST response.- Throws:
IOException- If an I/O error occurs while writing the response.
-
getInfoMap
Returns the configured info map (test/inspection helper).- Returns:
- The info map.
-