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.websocket.enabled - if this is defined as false, no services will be created.
mainClassName.websocket.sslRequired - unless this is defined as false, an SSL certificate will be required and used for the web services.
mainClassName.websocket.authenticationRequired - unless this is defined as false, users will be required to authenticate to access web services.
mainClassName.webPort - the port to be used for the Jetty server.
  • Constructor Details

    • JettyServerHelper

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

    • startServer

      public void startServer()
      Start the Jetty server, and if SSL was requested use our libraries to use it
    • 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
    • getJettyServerContextHandler

      public org.eclipse.jetty.servlet.ServletContextHandler getJettyServerContextHandler()
      Get the Jetty server's context handler
      Returns:
      the Jetty server's context handler
    • 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, javax.servlet.http.HttpServlet httpservlet)
      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
    • addHomeJettyServlet

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

      public void logAuditEvent​(com.fishlib.auth.UserContext userContext, String event, String details)
      If it's defined, log an event to the audit event log
      Parameters:
      userContext - the user context for the event
      event - the event
      details - the event details