Class JuneauRestServletContainerInitializer

java.lang.Object
org.apache.juneau.rest.server.servlet.JuneauRestServletContainerInitializer
All Implemented Interfaces:
jakarta.servlet.ServletContainerInitializer

public class JuneauRestServletContainerInitializer extends Object implements jakarta.servlet.ServletContainerInitializer
Plain Servlet-spec ServletContainerInitializer that auto-mounts RestServlet subclasses at their self-declared top-level paths in non-Spring (e.g. web.xml / external WAR) deployments.

Discovered by the container via META-INF/services/jakarta.servlet.ServletContainerInitializer and (through @HandlesTypes(RestServlet.class)) handed every concrete RestServlet on the webapp classpath. It mirrors the Jetty-microservice and Spring Boot auto-registration mechanisms: the mount paths are read from the top-level chain (@Rest(paths) / getPaths()) via RestContext.resolveTopLevelPaths(...) — not path() (child-composition).

Activation:

Opt-in via the context init parameter juneau.rest.auto-register=true (parity with the Spring Boot juneau.rest.auto-register property). When unset or not true, the initializer does nothing, so it never collides with servlets the deployer declared manually in web.xml. Declare it in web.xml:

<context-param> <param-name>juneau.rest.auto-register</param-name> <param-value>true</param-value> </context-param>

Behavior:

For each handled class that is concrete, carries a @Rest annotation, is no-arg instantiable, and resolves to at least one top-level path, an instance is created and added to the servlet context at each resolved path. Classes that resolve to no top-level paths (pure mixins / child-composed resources) or that cannot be instantiated with a no-arg constructor are skipped.

See Also:
Since:
10.0.0
  • Field Details

  • Constructor Details

  • Method Details

    • onStartup

      public void onStartup(Set<Class<?>> classes, jakarta.servlet.ServletContext ctx) throws jakarta.servlet.ServletException
      Specified by:
      onStartup in interface jakarta.servlet.ServletContainerInitializer
      Throws:
      jakarta.servlet.ServletException