Class AdminMixin
/admin/*: thread dump,
heap statistics, configurable cache-flush hooks, and rate-limit-bucket inspection.
Sibling of EchoMixin (/echo/*) and
RouteIndexMixin (/options). All three classes live in
the org.apache.juneau.rest.server.ops ops/introspection mixin pack.
Default-deny security posture:
The mixin is annotated with @Rest(guards=DenyAllGuard.class), so every
admin path returns 403 Forbidden until the importer registers a
@Bean RestGuardList factory on the host.
The framework's bean-store override seam replaces the entire annotation-derived guard
list (including this deny-all) with the user-supplied chain — pair the mixin with whatever
authentication / authorization story your service uses (bearer-token guard, API-key guard,
Spring Security adapter, etc.).
Why deny-all rather than a non-existent role-name placeholder? The role-guard approach
(declaring a role that no real principal has) has clean semantics but harder ergonomics: the
importer overrides by setting the principal's roles to include the placeholder, which couples
the host's auth strategy to a framework-internal role name. Replacing a RestGuardList
via @Bean keeps the override surface narrow — one factory method on the host
— and matches the way every other Juneau op-context bean is wired.
Configurable mount prefix:
The default mount prefix /admin can be overridden via the SVL variable
${juneau.admin.path:admin} — a single override relocates all four endpoints
(/threads, /heap, /cache/flush, /ratelimit) under the new
prefix. Set via system property (-Djuneau.admin.path=ops), environment variable
(JUNEAU_ADMIN_PATH=ops), or Config key
(juneau.admin.path = ops) to change the runtime mount without subclassing.
Resolution happens once at RestContext construction time (SVL resolution in @RestOp(path)).
Override accepts bare token (admin), leading slash (/admin), trailing slash
(admin/), or wildcard suffix (/admin/*) — all resolve to the same mount.
Mixin-only deployment:
This resource is designed for composition via @Rest(mixins=...). The four mount paths
(/admin/threads, /admin/heap, /admin/cache/flush,
/admin/ratelimit) are pinned at the op level by @RestGet/@RestPost(path=...)
on the handler methods; a class-level @Rest(paths=...) declaration would be silently
ignored under the mixin pattern (see @Rest(paths) Javadoc).
Composition example:
Endpoints:
GET /admin/threads— emits a JSON list of currently-live threads. The default thread filter excludes framework noise (JVM internals, servlet container, Spring Boot infrastructure); override viaAdminMixin.Builder.threadNamePrefixExclude(String...).GET /admin/heap— emits a JSON map withRuntimeheap stats (total,free,max,used) plusnon-heapmemory usage. No heap-dump file generation in v1 (security risk).POST /admin/cache/flush— runs all registered cache-flush hooks, or just a comma-separatednamessubset when supplied as a query parameter. Returns a JSON map of the hooks that were invoked. Hooks are registered name-keyed viaAdminMixin.Builder.cacheFlush(String,Runnable); users that want async semantics own the threading model.GET /admin/ratelimit— emits a JSON map keyed by bean name listing the registeredRateLimitGuardconfiguration and live per-bucket state. Each entry has two sub-fields:config(the guard's static configuration —class,limit,permitsPerSecond,xForwardedForAware,exemptPaths) andsnapshot(a sorted array ofRateLimitGuard.BucketStateentries describing every per-key bucket the storage backend currently tracks). Returns404 Not Foundwhen noRateLimitGuardbean is registered on the importer's bean store. Storage backends that don't overrideRateLimitGuard.Storage#snapshot()(e.g. Redis-backed impls that can't cheaply enumerate buckets) emit an emptysnapshotarray.
All four endpoints carry @OpSwagger(ignore=true) so the admin surface
stays out of any generated Swagger / OpenAPI spec.
See Also:
- Since:
- 10.0.0
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionDefault thread-name-prefix exclude list: filter out JVM internals, servlet container, and Spring Boot infrastructure threads. -
Constructor Summary
ConstructorsModifierConstructorDescriptionNo-arg constructor — delegates to a defaultAdminProviderworker (default thread filter and no cache-flush hooks).protectedAdminMixin(AdminProvider worker) Worker constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic AdminMixin.Buildercreate()Creates a new builder.Returns the registered cache-flush hooks (test/inspection helper).voidgetHeap(RestResponse res) [GET /admin/heap] — emit JVM heap and non-heap memory statistics.voidgetRateLimit(RestRequest req, RestResponse res) [GET /admin/ratelimit] — emit registeredRateLimitGuardbean configuration.Returns the configured thread-name-prefix exclude list (test/inspection helper).voidgetThreads(RestResponse res) [GET /admin/threads] — emit a JSON list of currently-live threads.voidpostCacheFlush(RestRequest req, RestResponse res) [POST /admin/cache/flush] — run all registered cache-flush hooks (or a subset).
-
Field Details
-
DEFAULT_THREAD_NAME_PREFIX_EXCLUDE
Default thread-name-prefix exclude list: filter out JVM internals, servlet container, and Spring Boot infrastructure threads.
-
-
Constructor Details
-
AdminMixin
public AdminMixin()No-arg constructor — delegates to a defaultAdminProviderworker (default thread filter and no cache-flush hooks). -
AdminMixin
Worker constructor.- Parameters:
worker- The sharedAdminProviderworker this flavor delegates to. Must not benull .
-
-
Method Details
-
create
Creates a new builder.- Returns:
- A new builder.
-
getThreads
[GET /admin/threads] — emit a JSON list of currently-live threads.- Parameters:
res- The current REST response.- Throws:
IOException- If an I/O error occurs while writing the response.
-
getHeap
[GET /admin/heap] — emit JVM heap and non-heap memory statistics.- Parameters:
res- The current REST response.- Throws:
IOException- If an I/O error occurs while writing the response.
-
postCacheFlush
[POST /admin/cache/flush] — run all registered cache-flush hooks (or a subset).- Parameters:
req- The current REST request —namesquery parameter is read off it.res- The current REST response.- Throws:
IOException- If an I/O error occurs while writing the response.
-
getRateLimit
[GET /admin/ratelimit] — emit registeredRateLimitGuardbean configuration.Returns
404 Not Foundwhen noRateLimitGuardbean is registered.- Parameters:
req- The current REST request — supplies the bean store for guard lookup.res- The current REST response.- Throws:
IOException- If an I/O error occurs while writing the response.
-
getCacheFlushHooks
Returns the registered cache-flush hooks (test/inspection helper).- Returns:
- The hooks, keyed by registration name. Never
null.
-
getThreadNamePrefixExclude
Returns the configured thread-name-prefix exclude list (test/inspection helper).- Returns:
- The exclude list. Never
null.
-