Class JuneauServletRegistrations

java.lang.Object
org.apache.juneau.rest.server.springboot.JuneauServletRegistrations

public class JuneauServletRegistrations extends Object
Always-available factory helper that builds a Spring Boot ServletRegistrationBean whose URL mappings are derived from a Juneau servlet's self-declared top-level paths.

Use this from an explicit @Bean method when you want the mount path to come from the servlet's own @Rest(paths) declaration (or its getPaths() override) rather than a hard-coded string in your configuration class:

@Bean public ServletRegistrationBean<?> jspServlet(BeanStore beanStore) { return JuneauServletRegistrations.forServlet(new JspServlet(), beanStore); }

The mapping is resolved via RestContext.resolveTopLevelPaths(...) — the same runtime-override resolution chain the Jetty microservice auto-discovery loop and the Spring Boot auto-configuration use — so behavior is identical across runtimes. No path string is hard-coded here; a servlet that resolves to no top-level paths is rejected with an IllegalArgumentException (declare @Rest(paths=...) or override getPaths()).

See Also:
Since:
10.0.0
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T extends jakarta.servlet.Servlet>
    org.springframework.boot.web.servlet.ServletRegistrationBean<T>
    forServlet(T servlet, BeanStore beanStore)
    Builds a ServletRegistrationBean for the supplied Juneau servlet, mapping it at the top-level paths it self-declares.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • forServlet

      public static <T extends jakarta.servlet.Servlet> org.springframework.boot.web.servlet.ServletRegistrationBean<T> forServlet(T servlet, BeanStore beanStore)
      Builds a ServletRegistrationBean for the supplied Juneau servlet, mapping it at the top-level paths it self-declares.
      Type Parameters:
      T - The servlet type.
      Parameters:
      servlet - The Juneau REST servlet to register. Must not be null and must carry a @Rest annotation that resolves to at least one top-level path (via paths() or a getPaths() override).
      beanStore - The bean store used for SVL resolution of @Rest(paths) elements (e.g. $C{key} / ${env} templates). May be null (SVL is then skipped; literal paths pass through unchanged).
      Returns:
      A registration bean mapping the servlet at its self-declared paths.
      Throws:
      IllegalArgumentException - If servlet is null or resolves to no top-level paths.