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.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-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classParameter struct for creatingJettyServerHelperinstances. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionJettyServerHelper(com.fishlib.configuration.Configuration configuration, JettyServerHelper.Parameters parameters, AuditEventLogger auditEventLogLogger, IrisGroupProvider irisGroupProvider) Create an instance of the JettyServerHelperJettyServerHelper(com.fishlib.configuration.Configuration configuration, JettyServerHelper.Parameters parameters, AuditEventLogger auditEventLogLogger, IrisGroupProvider irisGroupProvider, ServerEndpointResolver endpointResolver) Create an instance of the JettyServerHelper -
Method Summary
Modifier and TypeMethodDescriptionvoidaddHomeJettyServlet(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 servervoidaddServlet(String name, jakarta.servlet.http.HttpServlet httpservlet, String... methods) Add a raw HttpServlet servlet to the Jetty servervoidaddServlet(String name, jakarta.servlet.http.HttpServlet httpservlet, Map<String, String> params, String... methods) Add a raw HttpServlet servlet to the Jetty server with init params.voidaddServletContainerInitializer(jakarta.servlet.ServletContainerInitializer initializer) intGet the Jetty server's portvoidvoidsetAllowUriViolations(org.eclipse.jetty.http.UriCompliance.Violation... violations) voidvoidstop()Stop the Jetty server
-
Field Details
-
DEFAULT_SNI_HOST_CHECK_PROPERTY
- See Also:
-
-
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 useparameters- The parameters for this helper 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, 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 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
-
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
Stop the Jetty server- Throws:
Exception- from the underlying stop() call
-
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
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 specificationshttpservlet- the servlet that is bound to the specified namemethods- 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 specificationshttpservlet- the servlet that is bound to the specified nameparams- The init parameters that should be set on theServletHoldermethods- The HTTP methods that should be allowed for this servlet
-
addHomeJettyServlet
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)
-