Package com.illumon.util.jettyhelper
Class JettyServerHelper
java.lang.Object
com.illumon.util.jettyhelper.JettyServerHelper
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 ClassesModifier and TypeClassDescriptionstatic class
Parameter struct for creatingJettyServerHelper
instances. -
Constructor Summary
ConstructorsConstructorDescriptionJettyServerHelper
(com.fishlib.configuration.Configuration configuration, JettyServerHelper.Parameters parameters, com.fishlib.io.logger.Logger log, io.deephaven.enterprise.auth.audit.AuditEventLogger auditEventLogLogger, IrisGroupProvider irisGroupProvider) Create an instance of the JettyServerHelperJettyServerHelper
(com.fishlib.configuration.Configuration configuration, JettyServerHelper.Parameters parameters, com.fishlib.io.logger.Logger log, io.deephaven.enterprise.auth.audit.AuditEventLogger auditEventLogLogger, IrisGroupProvider irisGroupProvider, ServerEndpointResolver endpointResolver) Create an instance of the JettyServerHelper -
Method Summary
Modifier and TypeMethodDescriptionvoid
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 servervoid
addServlet
(String name, javax.servlet.http.HttpServlet httpservlet, Map<String, String> params) Add a raw HttpServlet servlet to the Jetty server with init params.int
Get the Jetty server's portorg.eclipse.jetty.servlet.ServletContextHandler
Get the Jetty server's context handlervoid
logAuditEvent
(io.deephaven.enterprise.auth.UserContext userContext, String event, String details) If it's defined, log an event to the audit event logvoid
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, io.deephaven.enterprise.auth.audit.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
-
JettyServerHelper
public JettyServerHelper(@NotNull com.fishlib.configuration.Configuration configuration, @NotNull JettyServerHelper.Parameters parameters, com.fishlib.io.logger.Logger log, io.deephaven.enterprise.auth.audit.AuditEventLogger auditEventLogLogger, IrisGroupProvider irisGroupProvider, @NotNull ServerEndpointResolver endpointResolver) 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 requiredendpointResolver
- resolver interface to get dynamic web port when applicable and signal when the port is bound
-
-
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
-
addServlet
public void addServlet(@NotNull String name, @NotNull javax.servlet.http.HttpServlet httpservlet, @NotNull Map<String, String> params) Add a raw HttpServlet servlet to the Jetty server with init params.- Parameters:
name
- the name of the servlet, used to build the path specificationshttpservlet
- the servlet that is bound to the specified nameparams
- The init parameters that should be set on theServletHolder
-
addHomeJettyServlet
Add the home lambda servlet to provide the home page- Parameters:
lambda
- the home lambda to run
-
logAuditEvent
public void logAuditEvent(io.deephaven.enterprise.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 eventevent
- the eventdetails
- the event details
-