org.springframework.boot.context.embedded.jetty
Class JettyEmbeddedServletContainerFactory

java.lang.Object
  extended by org.springframework.boot.context.embedded.AbstractEmbeddedServletContainerFactory
      extended by org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory
All Implemented Interfaces:
org.springframework.beans.factory.Aware, ConfigurableEmbeddedServletContainerFactory, EmbeddedServletContainerFactory, org.springframework.context.ResourceLoaderAware

public class JettyEmbeddedServletContainerFactory
extends AbstractEmbeddedServletContainerFactory
implements org.springframework.context.ResourceLoaderAware

EmbeddedServletContainerFactory that can be used to create JettyEmbeddedServletContainers. Can be initialized using Spring's ServletContextInitializers or Jetty Configurations.

Unless explicitly configured otherwise this factory will created containers that listens for HTTP requests on port 8080.

Author:
Phillip Webb, Dave Syer
See Also:
AbstractEmbeddedServletContainerFactory.setPort(int), setConfigurations(Collection), JettyEmbeddedServletContainer

Field Summary
 
Fields inherited from class org.springframework.boot.context.embedded.AbstractEmbeddedServletContainerFactory
logger
 
Constructor Summary
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.
 
Method Summary
 void addConfigurations(org.eclipse.jetty.webapp.Configuration... configurations)
          Add Configurations that will be applied to the WebAppContext before the server is started.
 Collection<org.eclipse.jetty.webapp.Configuration> getConfigurations()
          Returns a mutable collection of Jetty Configurations 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.
protected  org.eclipse.jetty.webapp.Configuration getServletContextInitializerConfiguration(org.eclipse.jetty.webapp.WebAppContext webAppContext, ServletContextInitializer... initializers)
          Return a Jetty Configuration that will invoke the specified ServletContextInitializers.
protected  org.eclipse.jetty.webapp.Configuration[] getWebAppContextConfigurations(org.eclipse.jetty.webapp.WebAppContext webAppContext, ServletContextInitializer... initializers)
          Return the Jetty Configurations 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 setConfigurations(Collection<? extends org.eclipse.jetty.webapp.Configuration> configurations)
          Sets Jetty Configurations that will be applied to the WebAppContext before the server is created.
 void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
           
 
Methods inherited from class org.springframework.boot.context.embedded.AbstractEmbeddedServletContainerFactory
addErrorPages, addInitializers, getAddress, getContextPath, getDocumentRoot, getErrorPages, getInitializers, getJspServletClassName, getMimeMappings, getPort, getSessionTimeout, getValidDocumentRoot, isRegisterDefaultServlet, isRegisterJspServlet, mergeInitializers, setAddress, setContextPath, setDocumentRoot, setErrorPages, setInitializers, setJspServletClassName, setMimeMappings, setPort, setRegisterDefaultServlet, setRegisterJspServlet, setSessionTimeout, setSessionTimeout
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JettyEmbeddedServletContainerFactory

public JettyEmbeddedServletContainerFactory()
Create a new JettyEmbeddedServletContainerFactory instance.


JettyEmbeddedServletContainerFactory

public JettyEmbeddedServletContainerFactory(int port)
Create a new JettyEmbeddedServletContainerFactory that listens for requests using the specified port.

Parameters:
port - the port to listen on

JettyEmbeddedServletContainerFactory

public JettyEmbeddedServletContainerFactory(String contextPath,
                                            int port)
Create a new JettyEmbeddedServletContainerFactory with the specified context path and port.

Parameters:
contextPath - root the context path
port - the port to listen on
Method Detail

getEmbeddedServletContainer

public EmbeddedServletContainer getEmbeddedServletContainer(ServletContextInitializer... initializers)
Description copied from interface: EmbeddedServletContainerFactory
Gets a new fully configured but paused 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).

Specified by:
getEmbeddedServletContainer in interface EmbeddedServletContainerFactory
Parameters:
initializers - ServletContextInitializers that should be applied as the container starts
Returns:
a fully configured and started EmbeddedServletContainer
See Also:
EmbeddedServletContainer.stop()

getWebAppContextConfigurations

protected org.eclipse.jetty.webapp.Configuration[] getWebAppContextConfigurations(org.eclipse.jetty.webapp.WebAppContext webAppContext,
                                                                                  ServletContextInitializer... initializers)
Return the Jetty Configurations that should be applied to the server.

Parameters:
webAppContext - the Jetty WebAppContext
initializers - the ServletContextInitializers to apply
Returns:
configurations to apply

getServletContextInitializerConfiguration

protected org.eclipse.jetty.webapp.Configuration getServletContextInitializerConfiguration(org.eclipse.jetty.webapp.WebAppContext webAppContext,
                                                                                           ServletContextInitializer... initializers)
Return a Jetty Configuration that will invoke the specified ServletContextInitializers. By default this method will return a ServletContextInitializerConfiguration.

Parameters:
webAppContext - the Jetty WebAppContext
initializers - the ServletContextInitializers to apply
Returns:
the Configuration instance

postProcessWebAppContext

protected void postProcessWebAppContext(org.eclipse.jetty.webapp.WebAppContext webAppContext)
Post process the Jetty WebAppContext before it used with the Jetty Server. Subclasses can override this method to apply additional processing to the WebAppContext.

Parameters:
webAppContext - the Jetty WebAppContext

getJettyEmbeddedServletContainer

protected JettyEmbeddedServletContainer getJettyEmbeddedServletContainer(org.eclipse.jetty.server.Server server)
Factory method called to create the JettyEmbeddedServletContainer. Subclasses can override this method to return a different JettyEmbeddedServletContainer or apply additional processing to the Jetty server.

Parameters:
server - the Jetty server.
Returns:
a new JettyEmbeddedServletContainer instance

setResourceLoader

public void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
Specified by:
setResourceLoader in interface org.springframework.context.ResourceLoaderAware

setConfigurations

public void setConfigurations(Collection<? extends org.eclipse.jetty.webapp.Configuration> configurations)
Sets Jetty Configurations that will be applied to the WebAppContext before the server is created. Calling this method will replace any existing configurations.

Parameters:
configurations - the Jetty configurations to apply

getConfigurations

public Collection<org.eclipse.jetty.webapp.Configuration> getConfigurations()
Returns a mutable collection of Jetty Configurations that will be applied to the WebAppContext before the server is created.

Returns:
the Jetty Configurations

addConfigurations

public void addConfigurations(org.eclipse.jetty.webapp.Configuration... configurations)
Add Configurations that will be applied to the WebAppContext before the server is started.

Parameters:
configurations - the configurations to add


Copyright © 2013. All Rights Reserved.