Package com.illumon.util.jettyhelper
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.-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJettyServerHelper.ParametersParameter struct for creatingJettyServerHelperinstances. -
Constructor Summary
Constructors Constructor Description JettyServerHelper(com.fishlib.configuration.Configuration configuration, JettyServerHelper.Parameters parameters, com.fishlib.io.logger.Logger log, AuditEventLogger auditEventLogLogger, IrisGroupProvider irisGroupProvider)Create an instance of the JettyServerHelper -
Method Summary
Modifier and Type Method Description voidaddHomeJettyServlet(Supplier<String> lambda)Add the home lambda servlet to provide the home pagevoidaddJettyServlet(String name, Supplier<String> lambda)Add a Lambda servlet to the Jetty serverintgetJettyPort()Get the Jetty server's portorg.eclipse.jetty.servlet.ServletContextHandlergetJettyServerContextHandler()Get the Jetty server's context handlervoidstartServer()Start the Jetty server, and if SSL was requested use our libraries to use itvoidstop()Stop 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 useparameters- The parameters for this helper instancelog- a Logger instanceauditEventLogLogger- Optional audit event log logger for logging eventsirisGroupProvider- 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
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
Add a Lambda servlet to the Jetty server- Parameters:
name- the name of the servlet, used to build the path specificationslambda- the lambda to run for the specified name
-
addHomeJettyServlet
Add the home lambda servlet to provide the home page- Parameters:
lambda- the home lambda to run
-