Class AdminServlet

java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
org.apache.juneau.rest.server.servlet.RestServlet
org.apache.juneau.rest.server.ops.AdminServlet
All Implemented Interfaces:
jakarta.servlet.Servlet, jakarta.servlet.ServletConfig, Serializable

public class AdminServlet extends RestServlet
Standalone servlet companion of the 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:

@Bean Servlet admin() { return new AdminServlet(); // auto-mounted at /admin/* by JettyServerComponent }

See Also:
Since:
10.0.0
  • Constructor Details

    • AdminServlet

      public AdminServlet()
      No-arg constructor — uses a default AdminProvider worker.
    • AdminServlet

      protected AdminServlet(AdminProvider worker)
      Worker constructor.
      Parameters:
      worker - The shared flavor-neutral admin worker this servlet delegates to. Must not be null.
  • Method Details

    • getThreads

      public void getThreads(RestResponse res) throws IOException
      [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

      public void getHeap(RestResponse res) throws IOException
      [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

      public void postCacheFlush(RestRequest req, RestResponse res) throws IOException
      [POST /cache/flush] — run all registered cache-flush hooks (or a subset).
      Parameters:
      req - The current REST request — names query parameter is read off it.
      res - The current REST response.
      Throws:
      IOException - If an I/O error occurs while writing the response.
    • getRateLimit

      public void getRateLimit(RestRequest req, RestResponse res) throws IOException
      [GET /ratelimit] — emit registered RateLimitGuard bean 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 no RateLimitGuard bean is registered on the importer's bean store.