Class DefaultSmallJettyConfiguration

java.lang.Object
com.blackrook.small.jetty.DefaultSmallJettyConfiguration
All Implemented Interfaces:
SmallJettyConfiguration, com.blackrook.small.SmallConfiguration

public class DefaultSmallJettyConfiguration extends Object implements SmallJettyConfiguration
Configuration builder for the Jetty bootstrap.

Defaults:

  • serverPort: 8080
  • secureServerPort: null
  • contextPath: "/"
  • tempPath: null
  • servletPaths: ["/*"]
  • applicationPackageRoots: [ ]
  • allowOptions: false
  • allowTrace: false
  • allowWebSockets: true
  • autoParseMultipart: true
  • attributes: NONE
  • maxThreads: 20
  • idleConnectionTimeout: 30000
  • headerCacheSize: 8192
  • outputBufferSize: 32768
  • requestHeaderSize: 8192
  • responseHeaderSize: 8192
  • sendServerVersion: false
  • sendDateHeader: false
  • sendXPoweredBy: false
  • servletContextOptions: 0
  • sslConfiguration: null
  • gzipConfiguration: null
Author:
Matthew Tropiano
  • Method Details

    • configure

      public static DefaultSmallJettyConfiguration configure()
      Returns:
      a new configuration builder.
    • getServerPort

      public int getServerPort()
      Specified by:
      getServerPort in interface com.blackrook.small.SmallConfiguration
    • getSecureServerPort

      public Integer getSecureServerPort()
      Specified by:
      getSecureServerPort in interface com.blackrook.small.SmallConfiguration
    • getContextPath

      public String getContextPath()
      Specified by:
      getContextPath in interface com.blackrook.small.SmallConfiguration
    • getTempPath

      public String getTempPath()
      Specified by:
      getTempPath in interface com.blackrook.small.SmallConfiguration
    • getServletPaths

      public String[] getServletPaths()
      Specified by:
      getServletPaths in interface com.blackrook.small.SmallConfiguration
    • getApplicationPackageRoots

      public String[] getApplicationPackageRoots()
      Specified by:
      getApplicationPackageRoots in interface com.blackrook.small.SmallConfiguration
    • allowOptions

      public boolean allowOptions()
      Specified by:
      allowOptions in interface com.blackrook.small.SmallConfiguration
    • allowTrace

      public boolean allowTrace()
      Specified by:
      allowTrace in interface com.blackrook.small.SmallConfiguration
    • allowWebSockets

      public boolean allowWebSockets()
      Specified by:
      allowWebSockets in interface com.blackrook.small.SmallConfiguration
    • autoParseMultipart

      public boolean autoParseMultipart()
      Specified by:
      autoParseMultipart in interface com.blackrook.small.SmallConfiguration
    • getMaxThreads

      public int getMaxThreads()
      Specified by:
      getMaxThreads in interface SmallJettyConfiguration
      Returns:
      the maximum amount of connector threads.
    • getIdleConnectionTimeout

      public int getIdleConnectionTimeout()
      Specified by:
      getIdleConnectionTimeout in interface SmallJettyConfiguration
      Returns:
      the amount of time in milliseconds before an open HTTP connection times out.
    • getHeaderCacheSize

      public int getHeaderCacheSize()
      Specified by:
      getHeaderCacheSize in interface SmallJettyConfiguration
      Returns:
      the header cache size in bytes.
    • getOutputBufferSize

      public int getOutputBufferSize()
      Specified by:
      getOutputBufferSize in interface SmallJettyConfiguration
      Returns:
      the output buffer cache size in bytes.
    • getRequestHeaderSize

      public int getRequestHeaderSize()
      Specified by:
      getRequestHeaderSize in interface SmallJettyConfiguration
      Returns:
      the request header cache size in bytes.
    • getResponseHeaderSize

      public int getResponseHeaderSize()
      Specified by:
      getResponseHeaderSize in interface SmallJettyConfiguration
      Returns:
      the response header cache size in bytes.
    • getSendServerVersion

      public boolean getSendServerVersion()
      Specified by:
      getSendServerVersion in interface SmallJettyConfiguration
      Returns:
      true if the server version should be sent in headers/default pages, false if not.
    • getSendDateHeader

      public boolean getSendDateHeader()
      Specified by:
      getSendDateHeader in interface SmallJettyConfiguration
      Returns:
      true if the server date should be sent in headers/default pages, false if not.
    • getSendXPoweredBy

      public boolean getSendXPoweredBy()
      Specified by:
      getSendXPoweredBy in interface SmallJettyConfiguration
      Returns:
      true if the server name should be sent in headers/default pages, false if not.
    • getServletContextOptions

      public int getServletContextOptions()
      Specified by:
      getServletContextOptions in interface SmallJettyConfiguration
      Returns:
      the Jetty options to pass to the servlet context handler.
      See Also:
      • ServletContextHandler.SESSIONS
      • ServletContextHandler.SECURITY
      • ServletContextHandler.GZIP
    • getSSLConfiguration

      public SmallJettyConfiguration.SSLConfiguration getSSLConfiguration()
      Specified by:
      getSSLConfiguration in interface SmallJettyConfiguration
      Returns:
      the SSL configuration to use for SSL, or null for no secure socket setup.
    • getGZipCompression

      public SmallJettyConfiguration.GZipConfiguration getGZipCompression()
      Specified by:
      getGZipCompression in interface SmallJettyConfiguration
      Returns:
      the GZip configuration to use, or null for no compression scheme.
    • getAttribute

      public <T> T getAttribute(String attributeName, T def)
      Specified by:
      getAttribute in interface com.blackrook.small.SmallConfiguration
    • setServerPort

      public DefaultSmallJettyConfiguration setServerPort(int value)
      Parameters:
      value - the value to set.
      Returns:
      this builder, for chaining.
      See Also:
    • setSecureServerPort

      public DefaultSmallJettyConfiguration setSecureServerPort(Integer value)
      Parameters:
      value - the value to set.
      Returns:
      this builder, for chaining.
      See Also:
    • setContextPath

      public DefaultSmallJettyConfiguration setContextPath(String value)
      Parameters:
      value - the value to set.
      Returns:
      this builder, for chaining.
      See Also:
    • setTempPath

      public DefaultSmallJettyConfiguration setTempPath(String value)
      Parameters:
      value - the value to set.
      Returns:
      this builder, for chaining.
      See Also:
    • setServletPaths

      public DefaultSmallJettyConfiguration setServletPaths(String... value)
      Parameters:
      value - the value to set.
      Returns:
      this builder, for chaining.
      See Also:
    • setApplicationPackageRoots

      public DefaultSmallJettyConfiguration setApplicationPackageRoots(String... value)
      Parameters:
      value - the value to set.
      Returns:
      this builder, for chaining.
      See Also:
    • setAllowOptions

      public DefaultSmallJettyConfiguration setAllowOptions(boolean value)
      Parameters:
      value - the value to set.
      Returns:
      this builder, for chaining.
      See Also:
    • setAllowTrace

      public DefaultSmallJettyConfiguration setAllowTrace(boolean value)
      Parameters:
      value - the value to set.
      Returns:
      this builder, for chaining.
      See Also:
    • setAllowWebSockets

      public DefaultSmallJettyConfiguration setAllowWebSockets(boolean value)
      Parameters:
      value - the value to set.
      Returns:
      this builder, for chaining.
      See Also:
    • setAutoParseMultipart

      public DefaultSmallJettyConfiguration setAutoParseMultipart(boolean value)
      Parameters:
      value - the value to set.
      Returns:
      this builder, for chaining.
      See Also:
    • setMaxThreads

      public DefaultSmallJettyConfiguration setMaxThreads(int value)
      Parameters:
      value - the value to set.
      Returns:
      this builder, for chaining.
      See Also:
    • setIdleConnectionTimeout

      public DefaultSmallJettyConfiguration setIdleConnectionTimeout(int value)
      Parameters:
      value - the value to set.
      Returns:
      this builder, for chaining.
      See Also:
    • setHeaderCacheSize

      public DefaultSmallJettyConfiguration setHeaderCacheSize(int value)
      Parameters:
      value - the value to set.
      Returns:
      this builder, for chaining.
      See Also:
    • setOutputBufferSize

      public DefaultSmallJettyConfiguration setOutputBufferSize(int value)
      Parameters:
      value - the value to set.
      Returns:
      this builder, for chaining.
      See Also:
    • setRequestHeaderSize

      public DefaultSmallJettyConfiguration setRequestHeaderSize(int value)
      Parameters:
      value - the value to set.
      Returns:
      this builder, for chaining.
      See Also:
    • setResponseHeaderSize

      public DefaultSmallJettyConfiguration setResponseHeaderSize(int value)
      Parameters:
      value - the value to set.
      Returns:
      this builder, for chaining.
      See Also:
    • setSendServerVersion

      public DefaultSmallJettyConfiguration setSendServerVersion(boolean value)
      Parameters:
      value - the value to set.
      Returns:
      this builder, for chaining.
      See Also:
    • setSendDateHeader

      public DefaultSmallJettyConfiguration setSendDateHeader(boolean value)
      Parameters:
      value - the value to set.
      Returns:
      this builder, for chaining.
      See Also:
    • setSendXPoweredBy

      public DefaultSmallJettyConfiguration setSendXPoweredBy(boolean value)
      Parameters:
      value - the value to set.
      Returns:
      this builder, for chaining.
      See Also:
    • setAttribute

      public DefaultSmallJettyConfiguration setAttribute(String attributeName, Object value)
      Parameters:
      attributeName - the attribute name.
      value - the value to set.
      Returns:
      this builder, for chaining.
      See Also:
    • useSSL

      public DefaultSmallJettyConfiguration useSSL(int port, String keyStorePath, String keyStorePassword)
      Sets the HTTPS port and the keystore/truststore file and password. Assumes that the store is in JKS format.
      Parameters:
      port - the secure HTTP server port.
      keyStorePath - the keystore/truststore path.
      keyStorePassword - the keystore/truststore password.
      Returns:
      this builder, for chaining.
      See Also:
    • useSSL

      public DefaultSmallJettyConfiguration useSSL(int port, String keyStoreType, String keyStorePath, String keyStorePassword)
      Sets the HTTPS port and the keystore/truststore file and password.
      Parameters:
      port - the secure HTTP server port.
      keyStoreType - the keystore/truststore type.
      keyStorePath - the keystore/truststore path.
      keyStorePassword - the keystore/truststore password.
      Returns:
      this builder, for chaining.
      See Also:
    • useSSL

      public DefaultSmallJettyConfiguration useSSL(int port, String keyStorePath, String keyStorePassword, String trustStorePath, String trustStorePassword)
      Sets the HTTPS port and the keystore/truststore file and password.
      Parameters:
      port - the secure HTTP server port.
      keyStorePath - the keystore path.
      keyStorePassword - the keystore password.
      trustStorePath - the truststore path.
      trustStorePassword - the truststore password.
      Returns:
      this builder, for chaining.
      See Also:
    • useSSL

      public DefaultSmallJettyConfiguration useSSL(int port, String keyStoreType, String keyStorePath, String keyStorePassword, String trustStoreType, String trustStorePath, String trustStorePassword)
      Sets the HTTPS port and the keystore/truststore file and password.
      Parameters:
      port - the secure HTTP server port.
      keyStoreType - the keystore type.
      keyStorePath - the keystore path.
      keyStorePassword - the keystore password.
      trustStoreType - the truststore type.
      trustStorePath - the truststore path.
      trustStorePassword - the truststore password.
      Returns:
      this builder, for chaining.
      See Also:
    • setGZip

      Sets the GZip handler configuration for this application.
      Parameters:
      gzip - the GZip configuration.
      Returns:
      this builder, for chaining.