Class JettyServerHelper

java.lang.Object
com.illumon.util.jettyhelper.JettyServerHelper

public class JettyServerHelper extends Object
Class to help with Jetty server implementation. This is intended to be used with an Iris process, and reads various properties based on this provided class/process name.
mainClassName.webserver.enabled - if this is defined as false, no services will be created.
mainClassName.webserver.authenticationRequired - unless this is defined as false, users will be required to authenticate to access web services.
mainClassName.webserver.port - the port to be used for the Jetty server.
mainClassName.webserver.sniHostCheck - true to require the SSL certificate always match the host name, false to disable this check
  • Field Details

  • Constructor Details

    • JettyServerHelper

      public JettyServerHelper(@NotNull com.fishlib.configuration.Configuration configuration, @NotNull JettyServerHelper.Parameters parameters, AuditEventLogger auditEventLogLogger, IrisGroupProvider irisGroupProvider)
      Create an instance of the JettyServerHelper
      Parameters:
      configuration - the Configuration instance to use
      parameters - The parameters for this helper instance
      auditEventLogLogger - Optional audit event log logger for logging events
      irisGroupProvider - the IrisGroupProvider if authentication is required
    • JettyServerHelper

      public JettyServerHelper(@NotNull com.fishlib.configuration.Configuration configuration, @NotNull JettyServerHelper.Parameters parameters, AuditEventLogger auditEventLogLogger, IrisGroupProvider irisGroupProvider, @NotNull ServerEndpointResolver endpointResolver)
      Create an instance of the JettyServerHelper
      Parameters:
      configuration - the Configuration instance to use
      parameters - The parameters for this helper instance
      auditEventLogLogger - Optional audit event log logger for logging events
      irisGroupProvider - the IrisGroupProvider if authentication is required
      endpointResolver - resolver interface to get dynamic web port when applicable and signal when the port is bound
  • Method Details

    • addServletContainerInitializer

      public void addServletContainerInitializer(jakarta.servlet.ServletContainerInitializer initializer)
    • requireHttp11

      public void requireHttp11()
    • startServer

      public void startServer()
    • getJettyPort

      public int getJettyPort()
      Get the Jetty server's port
      Returns:
      the Jetty server's port
    • stop

      public void stop() throws Exception
      Stop the Jetty server
      Throws:
      Exception - from the underlying stop() call
    • addJettyServlet

      public void addJettyServlet(String name, Supplier<String> lambda)
      Add a Lambda servlet to the Jetty server
      Parameters:
      name - the name of the servlet, used to build the path specifications
      lambda - the lambda to run for the specified name
    • addServlet

      public void addServlet(String name, jakarta.servlet.http.HttpServlet httpservlet, String... methods)
      Add a raw HttpServlet servlet to the Jetty server
      Parameters:
      name - the name of the servlet, used to build the path specifications
      httpservlet - the servlet that is bound to the specified name
      methods - The HTTP methods that should be allowed for this servlet
    • addServlet

      public void addServlet(@NotNull String name, @NotNull jakarta.servlet.http.HttpServlet httpservlet, @NotNull Map<String,String> params, @NotNull String... methods)
      Add a raw HttpServlet servlet to the Jetty server with init params.
      Parameters:
      name - the name of the servlet, used to build the path specifications
      httpservlet - the servlet that is bound to the specified name
      params - The init parameters that should be set on the ServletHolder
      methods - The HTTP methods that should be allowed for this servlet
    • addHomeJettyServlet

      public void addHomeJettyServlet(Supplier<String> lambda)
      Add the home lambda servlet to provide the home page
      Parameters:
      lambda - the home lambda to run
    • setAllowUriViolations

      public void setAllowUriViolations(org.eclipse.jetty.http.UriCompliance.Violation... violations)
      Parameters:
      violations - a list of ee10 / servlet 6.0 uri spec violations to ignore (needed for acl write server jax-rs api)