public class JettyEmbeddedServletContainerFactory extends AbstractEmbeddedServletContainerFactory implements org.springframework.context.ResourceLoaderAware
EmbeddedServletContainerFactory
that can be used to create
JettyEmbeddedServletContainer
s. Can be initialized using Spring's
ServletContextInitializer
s or Jetty Configuration
s.
Unless explicitly configured otherwise this factory will created containers that listens for HTTP requests on port 8080.
AbstractConfigurableEmbeddedServletContainer.setPort(int)
,
setConfigurations(Collection)
,
JettyEmbeddedServletContainer
logger
Constructor and Description |
---|
JettyEmbeddedServletContainerFactory()
Create a new
JettyEmbeddedServletContainerFactory instance. |
JettyEmbeddedServletContainerFactory(int port)
Create a new
JettyEmbeddedServletContainerFactory that listens for requests
using the specified port. |
JettyEmbeddedServletContainerFactory(String contextPath,
int port)
Create a new
JettyEmbeddedServletContainerFactory with the specified
context path and port. |
Modifier and Type | Method and Description |
---|---|
void |
addConfigurations(org.eclipse.jetty.webapp.Configuration... configurations)
Add
Configuration s that will be applied to the WebAppContext before
the server is started. |
protected void |
addDefaultServlet(org.eclipse.jetty.webapp.WebAppContext context)
Add Jetty's
DefaultServlet to the given WebAppContext . |
protected void |
addJspServlet(org.eclipse.jetty.webapp.WebAppContext context)
Add Jetty's
JspServlet to the given WebAppContext . |
void |
addServerCustomizers(JettyServerCustomizer... customizers)
Add
JettyServerCustomizer s that will be applied to the Server
before it is started. |
protected void |
configureSsl(org.eclipse.jetty.util.ssl.SslContextFactory factory,
Ssl ssl)
Configure the SSL connection.
|
protected void |
configureWebAppContext(org.eclipse.jetty.webapp.WebAppContext context,
ServletContextInitializer... initializers)
Configure the given Jetty
WebAppContext for use. |
Collection<org.eclipse.jetty.webapp.Configuration> |
getConfigurations()
Returns a mutable collection of Jetty
Configuration s that will be applied
to the WebAppContext before the server is created. |
EmbeddedServletContainer |
getEmbeddedServletContainer(ServletContextInitializer... initializers)
Gets a new fully configured but paused
EmbeddedServletContainer instance. |
protected JettyEmbeddedServletContainer |
getJettyEmbeddedServletContainer(org.eclipse.jetty.server.Server server)
Factory method called to create the
JettyEmbeddedServletContainer . |
Collection<JettyServerCustomizer> |
getServerCustomizers()
Returns a mutable collection of Jetty
Configuration s that will be applied
to the WebAppContext before the server is created. |
protected org.eclipse.jetty.webapp.Configuration |
getServletContextInitializerConfiguration(org.eclipse.jetty.webapp.WebAppContext webAppContext,
ServletContextInitializer... initializers)
Return a Jetty
Configuration that will invoke the specified
ServletContextInitializer s. |
org.eclipse.jetty.util.thread.ThreadPool |
getThreadPool()
Returns a Jetty
ThreadPool that should be used by the Server . |
protected org.eclipse.jetty.webapp.Configuration[] |
getWebAppContextConfigurations(org.eclipse.jetty.webapp.WebAppContext webAppContext,
ServletContextInitializer... initializers)
Return the Jetty
Configuration s that should be applied to the server. |
protected void |
postProcessWebAppContext(org.eclipse.jetty.webapp.WebAppContext webAppContext)
Post process the Jetty
WebAppContext before it used with the Jetty Server. |
void |
setAcceptors(int acceptors)
Set the number of acceptor threads to use.
|
void |
setConfigurations(Collection<? extends org.eclipse.jetty.webapp.Configuration> configurations)
Sets Jetty
Configuration s that will be applied to the WebAppContext
before the server is created. |
void |
setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader) |
void |
setSelectors(int selectors)
Set the number of selector threads to use.
|
void |
setServerCustomizers(Collection<? extends JettyServerCustomizer> customizers)
Sets
JettyServerCustomizer s that will be applied to the Server
before it is started. |
void |
setThreadPool(org.eclipse.jetty.util.thread.ThreadPool threadPool)
Set a Jetty
ThreadPool that should be used by the Server . |
void |
setUseForwardHeaders(boolean useForwardHeaders)
Set if x-forward-* headers should be processed.
|
createTempDir, getUrlsOfJarsWithMetaInfResources, getValidDocumentRoot, getValidSessionStoreDir, getValidSessionStoreDir
addErrorPages, addInitializers, getAddress, getCompression, getContextPath, getDisplayName, getDocumentRoot, getErrorPages, getJspServlet, getLocaleCharsetMappings, getMimeMappings, getPort, getServerHeader, getSessionStoreDir, getSessionTimeout, getSsl, getSslStoreProvider, isPersistSession, isRegisterDefaultServlet, mergeInitializers, setAddress, setCompression, setContextPath, setDisplayName, setDocumentRoot, setErrorPages, setInitializers, setJspServlet, setLocaleCharsetMappings, setMimeMappings, setPersistSession, setPort, setRegisterDefaultServlet, setServerHeader, setSessionStoreDir, setSessionTimeout, setSessionTimeout, setSsl, setSslStoreProvider, shouldRegisterJspServlet
public JettyEmbeddedServletContainerFactory()
JettyEmbeddedServletContainerFactory
instance.public JettyEmbeddedServletContainerFactory(int port)
JettyEmbeddedServletContainerFactory
that listens for requests
using the specified port.port
- the port to listen onpublic JettyEmbeddedServletContainerFactory(String contextPath, int port)
JettyEmbeddedServletContainerFactory
with the specified
context path and port.contextPath
- the root context pathport
- the port to listen onpublic EmbeddedServletContainer getEmbeddedServletContainer(ServletContextInitializer... initializers)
EmbeddedServletContainerFactory
EmbeddedServletContainer
instance.
Clients should not be able to connect to the returned server until
EmbeddedServletContainer.start()
is called (which happens when the
ApplicationContext
has been fully refreshed).getEmbeddedServletContainer
in interface EmbeddedServletContainerFactory
initializers
- ServletContextInitializer
s that should be applied as
the container startsEmbeddedServletContainer
EmbeddedServletContainer.stop()
protected void configureSsl(org.eclipse.jetty.util.ssl.SslContextFactory factory, Ssl ssl)
factory
- the Jetty SslContextFactory
.ssl
- the ssl details.protected final void configureWebAppContext(org.eclipse.jetty.webapp.WebAppContext context, ServletContextInitializer... initializers)
WebAppContext
for use.context
- the context to configureinitializers
- the set of initializers to applyprotected final void addDefaultServlet(org.eclipse.jetty.webapp.WebAppContext context)
DefaultServlet
to the given WebAppContext
.context
- the jetty WebAppContext
protected final void addJspServlet(org.eclipse.jetty.webapp.WebAppContext context)
JspServlet
to the given WebAppContext
.context
- the jetty WebAppContext
protected org.eclipse.jetty.webapp.Configuration[] getWebAppContextConfigurations(org.eclipse.jetty.webapp.WebAppContext webAppContext, ServletContextInitializer... initializers)
Configuration
s that should be applied to the server.webAppContext
- the Jetty WebAppContext
initializers
- the ServletContextInitializer
s to applyprotected org.eclipse.jetty.webapp.Configuration getServletContextInitializerConfiguration(org.eclipse.jetty.webapp.WebAppContext webAppContext, ServletContextInitializer... initializers)
Configuration
that will invoke the specified
ServletContextInitializer
s. By default this method will return a
ServletContextInitializerConfiguration
.webAppContext
- the Jetty WebAppContext
initializers
- the ServletContextInitializer
s to applyConfiguration
instanceprotected void postProcessWebAppContext(org.eclipse.jetty.webapp.WebAppContext webAppContext)
WebAppContext
before it used with the Jetty Server.
Subclasses can override this method to apply additional processing to the
WebAppContext
.webAppContext
- the Jetty WebAppContext
protected JettyEmbeddedServletContainer getJettyEmbeddedServletContainer(org.eclipse.jetty.server.Server server)
JettyEmbeddedServletContainer
.
Subclasses can override this method to return a different
JettyEmbeddedServletContainer
or apply additional processing to the Jetty
server.server
- the Jetty server.JettyEmbeddedServletContainer
instancepublic void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
setResourceLoader
in interface org.springframework.context.ResourceLoaderAware
public void setUseForwardHeaders(boolean useForwardHeaders)
useForwardHeaders
- if x-forward headers should be usedpublic void setAcceptors(int acceptors)
acceptors
- the number of acceptor threads to usepublic void setSelectors(int selectors)
selectors
- the number of selector threads to usepublic void setServerCustomizers(Collection<? extends JettyServerCustomizer> customizers)
JettyServerCustomizer
s that will be applied to the Server
before it is started. Calling this method will replace any existing configurations.customizers
- the Jetty customizers to applypublic Collection<JettyServerCustomizer> getServerCustomizers()
Configuration
s that will be applied
to the WebAppContext
before the server is created.Configuration
spublic void addServerCustomizers(JettyServerCustomizer... customizers)
JettyServerCustomizer
s that will be applied to the Server
before it is started.customizers
- the customizers to addpublic void setConfigurations(Collection<? extends org.eclipse.jetty.webapp.Configuration> configurations)
Configuration
s that will be applied to the WebAppContext
before the server is created. Calling this method will replace any existing
configurations.configurations
- the Jetty configurations to applypublic Collection<org.eclipse.jetty.webapp.Configuration> getConfigurations()
Configuration
s that will be applied
to the WebAppContext
before the server is created.Configuration
spublic void addConfigurations(org.eclipse.jetty.webapp.Configuration... configurations)
Configuration
s that will be applied to the WebAppContext
before
the server is started.configurations
- the configurations to addpublic org.eclipse.jetty.util.thread.ThreadPool getThreadPool()
ThreadPool
that should be used by the Server
.ThreadPool
or null
public void setThreadPool(org.eclipse.jetty.util.thread.ThreadPool threadPool)
ThreadPool
that should be used by the Server
. If set to
null
(default), the Server
creates a ThreadPool
implicitly.threadPool
- a Jetty ThreadPool to be usedCopyright © 2018 Pivotal Software, Inc.. All rights reserved.