Package io.micronaut.servlet.jetty
Class JettyFactory
java.lang.Object
io.micronaut.http.ssl.SslBuilder<SSLContext>
io.micronaut.servlet.engine.server.ServletServerFactory
io.micronaut.servlet.jetty.JettyFactory
Factory for the Jetty server.
- Since:
- 1.0
- Author:
- graemerocher
-
Field Summary
-
Constructor Summary
ConstructorDescriptionJettyFactory
(io.micronaut.core.io.ResourceResolver resourceResolver, JettyConfiguration serverConfiguration, io.micronaut.http.ssl.SslConfiguration sslConfiguration, io.micronaut.context.ApplicationContext applicationContext, List<ServletStaticResourceConfiguration> staticResourceConfigurations) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
configureConnectors
(@NonNull org.eclipse.jetty.server.Server server, @NonNull org.eclipse.jetty.server.ServerConnector http, @Nullable org.eclipse.jetty.server.ServerConnector https) Configures the server connectors.protected void
configureServletInitializer
(org.eclipse.jetty.server.Server server, org.eclipse.jetty.servlet.ServletContextHandler contextHandler, Collection<jakarta.servlet.ServletContainerInitializer> servletContainerInitializers) Configures the servlet initializer.protected org.eclipse.jetty.server.Server
jettyServer
(io.micronaut.context.ApplicationContext applicationContext, MicronautServletConfiguration configuration, JettyConfiguration.JettySslConfiguration jettySslConfiguration) Builds the Jetty server bean.protected org.eclipse.jetty.server.Server
jettyServer
(io.micronaut.context.ApplicationContext applicationContext, MicronautServletConfiguration configuration, JettyConfiguration.JettySslConfiguration jettySslConfiguration, Collection<jakarta.servlet.ServletContainerInitializer> servletContainerInitializers) Builds the Jetty server bean.protected @NonNull org.eclipse.jetty.server.ServerConnector
newHttpConnector
(@NonNull org.eclipse.jetty.server.Server server, @NonNull String host, @NonNull Integer port) Create the HTTP connector.protected @NonNull org.eclipse.jetty.server.ServerConnector
newHttpsConnector
(@NonNull org.eclipse.jetty.server.Server server, @NonNull io.micronaut.http.ssl.SslConfiguration sslConfiguration, JettyConfiguration.JettySslConfiguration jettySslConfiguration) Create the HTTPS connector.protected @NonNull org.eclipse.jetty.servlet.ServletContextHandler
newJettyContext
(@NonNull org.eclipse.jetty.server.Server server, @NonNull String contextPath) Create the Jetty context.protected @NonNull org.eclipse.jetty.server.Server
newServer
(@NonNull io.micronaut.context.ApplicationContext applicationContext, @NonNull MicronautServletConfiguration configuration) Create a new server instance.Methods inherited from class io.micronaut.servlet.engine.server.ServletServerFactory
build, build, getApplicationContext, getConfiguredHost, getConfiguredPort, getContextPath, getEnvironment, getServerConfiguration, getSslConfiguration, getStaticResourceConfigurations
Methods inherited from class io.micronaut.http.ssl.SslBuilder
getKeyManagerFactory, getKeyStore, getTrustManagerFactory, getTrustManagerFactory, getTrustStore, load
-
Field Details
-
RESOURCE_BASE
- See Also:
-
-
Constructor Details
-
JettyFactory
public JettyFactory(io.micronaut.core.io.ResourceResolver resourceResolver, JettyConfiguration serverConfiguration, io.micronaut.http.ssl.SslConfiguration sslConfiguration, io.micronaut.context.ApplicationContext applicationContext, List<ServletStaticResourceConfiguration> staticResourceConfigurations) Default constructor.- Parameters:
resourceResolver
- The resource resolverserverConfiguration
- The server configsslConfiguration
- The SSL configapplicationContext
- The app contextstaticResourceConfigurations
- The static resource configs
-
-
Method Details
-
jettyServer
protected org.eclipse.jetty.server.Server jettyServer(io.micronaut.context.ApplicationContext applicationContext, MicronautServletConfiguration configuration, JettyConfiguration.JettySslConfiguration jettySslConfiguration) Builds the Jetty server bean.- Parameters:
applicationContext
- This application contextconfiguration
- The servlet configurationjettySslConfiguration
- The Jetty SSL config- Returns:
- The Jetty server bean
-
jettyServer
@Singleton @Primary protected org.eclipse.jetty.server.Server jettyServer(io.micronaut.context.ApplicationContext applicationContext, MicronautServletConfiguration configuration, JettyConfiguration.JettySslConfiguration jettySslConfiguration, Collection<jakarta.servlet.ServletContainerInitializer> servletContainerInitializers) Builds the Jetty server bean.- Parameters:
applicationContext
- This application contextconfiguration
- The servlet configurationjettySslConfiguration
- The Jetty SSL configservletContainerInitializers
- The micronaut servlet initializer- Returns:
- The Jetty server bean
-
newHttpConnector
@NonNull protected @NonNull org.eclipse.jetty.server.ServerConnector newHttpConnector(@NonNull @NonNull org.eclipse.jetty.server.Server server, @NonNull @NonNull String host, @NonNull @NonNull Integer port) Create the HTTP connector.- Parameters:
server
- The serverhost
- The hostport
- The port- Returns:
- The server connector.
-
newHttpsConnector
@NonNull protected @NonNull org.eclipse.jetty.server.ServerConnector newHttpsConnector(@NonNull @NonNull org.eclipse.jetty.server.Server server, @NonNull @NonNull io.micronaut.http.ssl.SslConfiguration sslConfiguration, @NonNull JettyConfiguration.JettySslConfiguration jettySslConfiguration) Create the HTTPS connector.- Parameters:
server
- The serversslConfiguration
- The SSL configurationjettySslConfiguration
- The Jetty SSL configuration- Returns:
- The server connector
-
configureServletInitializer
protected void configureServletInitializer(org.eclipse.jetty.server.Server server, org.eclipse.jetty.servlet.ServletContextHandler contextHandler, Collection<jakarta.servlet.ServletContainerInitializer> servletContainerInitializers) Configures the servlet initializer.- Parameters:
server
- The servercontextHandler
- The context handlerservletContainerInitializers
- The servlet initializers
-
newJettyContext
@NonNull protected @NonNull org.eclipse.jetty.servlet.ServletContextHandler newJettyContext(@NonNull @NonNull org.eclipse.jetty.server.Server server, @NonNull @NonNull String contextPath) Create the Jetty context.- Parameters:
server
- The servercontextPath
- The context path- Returns:
- The handler
-
configureConnectors
protected void configureConnectors(@NonNull @NonNull org.eclipse.jetty.server.Server server, @NonNull @NonNull org.eclipse.jetty.server.ServerConnector http, @Nullable @Nullable org.eclipse.jetty.server.ServerConnector https) Configures the server connectors.- Parameters:
server
- The serverhttp
- The HTTP connectorhttps
- The HTTPS connector if configured.
-
newServer
@NonNull protected @NonNull org.eclipse.jetty.server.Server newServer(@NonNull @NonNull io.micronaut.context.ApplicationContext applicationContext, @NonNull @NonNull MicronautServletConfiguration configuration) Create a new server instance.- Parameters:
applicationContext
- The application contextconfiguration
- The configuration- Returns:
- The server
-