Class AdminServlet
- All Implemented Interfaces:
jakarta.servlet.Servlet,jakarta.servlet.ServletConfig,Serializable
AdminMixin mixin.
Mounts as a sibling top-level servlet at /admin/* and serves the same operational
endpoints (/threads, /heap, /cache/flush, /ratelimit) as the
mixin by delegating to a shared flavor-neutral AdminProvider worker bean — so the two forms
cannot drift.
Whereas the AdminMixin mixin pins its ops at /admin/<endpoint> for
composition into a host at /, this companion declares the mount at the class level
(@Rest(paths="/admin/*")) and pins the ops at the bare endpoint names
(e.g. /threads) — eliminating the path-doubling that mixin-shaped ops would produce
when the servlet itself is mounted at /admin/*.
Default-deny security posture:
Like the mixin, this servlet is annotated @Rest(guards=DenyAllGuard.class),
so every admin path returns 403 Forbidden until the importer registers a
RestGuardList factory. Pair the servlet with whatever authentication / authorization
story your service uses.
Microservice registration:
See Also:
- Since:
- 10.0.0
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.juneau.rest.server.servlet.RestServlet
RestServlet.Builder<R extends RestServlet,SELF extends RestServlet.Builder<R, SELF>>, RestServlet.DefaultBuilder<R extends RestServlet> -
Field Summary
Fields inherited from class jakarta.servlet.http.HttpServlet
LEGACY_DO_HEAD -
Constructor Summary
ConstructorsModifierConstructorDescriptionNo-arg constructor — uses a defaultAdminProviderworker.protectedAdminServlet(AdminProvider worker) Worker constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidgetHeap(RestResponse res) [GET /heap] — emit JVM heap and non-heap memory statistics.voidgetRateLimit(RestRequest req, RestResponse res) [GET /ratelimit] — emit registeredRateLimitGuardbean configuration.voidgetThreads(RestResponse res) [GET /threads] — emit a JSON list of currently-live threads.voidpostCacheFlush(RestRequest req, RestResponse res) [POST /cache/flush] — run all registered cache-flush hooks (or a subset).Methods inherited from class org.apache.juneau.rest.server.servlet.RestServlet
builder, createAuthenticator, destroy, doLog, getContext, getPath, getPaths, getRequest, getResponse, getRestBuilder, init, log, log, service, setContextMethods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPatch, doPost, doPut, doTrace, getLastModified, isSensitiveHeader, serviceMethods inherited from class jakarta.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
-
Constructor Details
-
AdminServlet
public AdminServlet()No-arg constructor — uses a defaultAdminProviderworker. -
AdminServlet
Worker constructor.- Parameters:
worker- The shared flavor-neutral admin worker this servlet delegates to. Must not benull.
-
-
Method Details
-
getThreads
[GET /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 /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 /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 /ratelimit] — emit registeredRateLimitGuardbean configuration.- 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.NotFound- If noRateLimitGuardbean is registered on the importer's bean store.
-