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 class
JettyServerHelper.Parameters
Parameter struct for creatingJettyServerHelper
instances. -
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 void
addHomeJettyServlet(Supplier<String> lambda)
Add the home lambda servlet to provide the home pagevoid
addJettyServlet(String name, Supplier<String> lambda)
Add a Lambda servlet to the Jetty servervoid
addServlet(String name, javax.servlet.http.HttpServlet httpservlet)
Add a raw HttpServlet servlet to the Jetty serverint
getJettyPort()
Get the Jetty server's portorg.eclipse.jetty.servlet.ServletContextHandler
getJettyServerContextHandler()
Get the Jetty server's context handlervoid
logAuditEvent(com.fishlib.auth.UserContext userContext, String event, String details)
If it's defined, log an event to the audit event logvoid
startServer()
Start the Jetty server, and if SSL was requested use our libraries to use itvoid
stop()
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
-
addServlet
Add a raw HttpServlet servlet to the Jetty server- Parameters:
name
- the name of the servlet, used to build the path specificationshttpservlet
- the servlet that is bound to the specified name
-
addHomeJettyServlet
Add the home lambda servlet to provide the home page- Parameters:
lambda
- the home lambda to run
-
logAuditEvent
If it's defined, log an event to the audit event log- Parameters:
userContext
- the user context for the eventevent
- the eventdetails
- the event details
-