public class LaunchConfigBuilder extends Object
LaunchConfig
objects.
The following is the minimum requirement for creating a launch config…
import ratpack.launch.*; import ratpack.handling.*; LaunchConfig launchConfig = LaunchConfigBuilder.baseDir(new File("some/path")).build( new HandlerFactory() { public Handler create(LaunchConfig launchConfig) { return new Handler() { public void handle(Context context) { context.getResponse().send("Hello World!"); } }; } } ); launchConfig.execController.close();
baseDir(java.io.File)
Modifier and Type | Method and Description |
---|---|
LaunchConfigBuilder |
address(InetAddress address)
Sets the address to bind to.
|
static LaunchConfigBuilder |
baseDir(File baseDir)
Create a new builder, using the given file as the base dir.
|
static LaunchConfigBuilder |
baseDir(Path baseDir)
Create a new builder, using the given file as the base dir.
|
LaunchConfigBuilder |
bufferAllocator(ByteBufAllocator byteBufAllocator)
The allocator to use when creating buffers in the application.
|
LaunchConfig |
build()
Builds the launch config, based on the current state and WITHOUT handler factory.
|
LaunchConfig |
build(HandlerFactory handlerFactory)
Builds the launch config, based on the current state and the handler factory.
|
LaunchConfigBuilder |
compressionBlackListMimeTypes(List<String> mimeTypes)
Adds the given values as non-compressible mime types.
|
LaunchConfigBuilder |
compressionBlackListMimeTypes(String... mimeTypes)
Adds the given values as non-compressible mime types.
|
LaunchConfigBuilder |
compressionMinSize(long compressionMinSize)
The minimum size at which responses should be compressed, in bytes.
|
LaunchConfigBuilder |
compressionWhiteListMimeTypes(List<String> mimeTypes)
Adds the given values as compressible mime types.
|
LaunchConfigBuilder |
compressionWhiteListMimeTypes(String... mimeTypes)
Adds the given values as compressible mime types.
|
LaunchConfigBuilder |
compressResponses(boolean compressResponses)
Whether to compress responses.
|
LaunchConfigBuilder |
defaultRegistry(Registry defaultRegistry)
The default registry for the built launch config.
|
LaunchConfigBuilder |
development(boolean development)
Whether or not the application is "development".
|
LaunchConfigBuilder |
indexFiles(List<String> indexFiles)
Adds the given values as potential index file names.
|
LaunchConfigBuilder |
indexFiles(String... indexFiles)
Adds the given values as potential index file names.
|
LaunchConfigBuilder |
maxContentLength(int maxContentLength)
The max number of bytes a request body can be.
|
static LaunchConfigBuilder |
noBaseDir()
Create a new builder, with no base dir.
|
LaunchConfigBuilder |
other(Map<String,String> other)
Add some "other" properties.
|
LaunchConfigBuilder |
other(String key,
String value)
Add an "other" property.
|
LaunchConfigBuilder |
port(int port)
Sets the port to bind to.
|
LaunchConfigBuilder |
publicAddress(URI publicAddress)
The public address of the application.
|
LaunchConfigBuilder |
ssl(SSLContext sslContext)
The SSL context to use if the application serves content over HTTPS.
|
LaunchConfigBuilder |
threads(int threads)
The number of threads to use.
|
LaunchConfigBuilder |
timeResponses(boolean timeResponses)
Whether to time responses.
|
public static LaunchConfigBuilder noBaseDir()
public static LaunchConfigBuilder baseDir(File baseDir)
baseDir
- The base dir of the launch configLaunchConfig.getBaseDir()
public static LaunchConfigBuilder baseDir(Path baseDir)
baseDir
- The base dir of the launch configLaunchConfig.getBaseDir()
public LaunchConfigBuilder port(int port)
Default value is 5050
.
port
- The port to bind toLaunchConfig.getPort()
public LaunchConfigBuilder address(InetAddress address)
Default value is null
.
address
- The address to bind toLaunchConfig.getAddress()
public LaunchConfigBuilder development(boolean development)
Default value is false
.
development
- Whether or not the application is "development".LaunchConfig.isDevelopment()
public LaunchConfigBuilder threads(int threads)
Defaults to LaunchConfig.DEFAULT_THREADS
threads
- the size of the event loop thread poolLaunchConfig.getThreads()
public LaunchConfigBuilder bufferAllocator(ByteBufAllocator byteBufAllocator)
Default value is PooledByteBufAllocator.DEFAULT
.
byteBufAllocator
- The allocator to use when creating buffers in the applicationLaunchConfig.getBufferAllocator()
public LaunchConfigBuilder publicAddress(URI publicAddress)
Default value is null
.
publicAddress
- The public address of the applicationLaunchConfig.getPublicAddress()
public LaunchConfigBuilder maxContentLength(int maxContentLength)
1048576
(1 megabyte).maxContentLength
- The max content length to accept.LaunchConfig.getMaxContentLength()
public LaunchConfigBuilder timeResponses(boolean timeResponses)
false
.timeResponses
- Whether to time responsesLaunchConfig.isTimeResponses()
public LaunchConfigBuilder compressResponses(boolean compressResponses)
false
.compressResponses
- Whether to compress responsesLaunchConfig.isCompressResponses()
public LaunchConfigBuilder compressionMinSize(long compressionMinSize)
compressionMinSize
- The minimum size at which responses should be compressed, in bytesLaunchConfig.getCompressionMinSize()
public LaunchConfigBuilder compressionWhiteListMimeTypes(String... mimeTypes)
mimeTypes
- the compressible mime types.LaunchConfig.getCompressionMimeTypeWhiteList()
public LaunchConfigBuilder compressionWhiteListMimeTypes(List<String> mimeTypes)
mimeTypes
- the compressible mime types.LaunchConfig.getCompressionMimeTypeWhiteList()
public LaunchConfigBuilder compressionBlackListMimeTypes(String... mimeTypes)
mimeTypes
- the non-compressible mime types.LaunchConfig.getCompressionMimeTypeBlackList()
public LaunchConfigBuilder compressionBlackListMimeTypes(List<String> mimeTypes)
mimeTypes
- the non-compressible mime types.LaunchConfig.getCompressionMimeTypeBlackList()
public LaunchConfigBuilder indexFiles(String... indexFiles)
indexFiles
- the potential index file names.LaunchConfig.getIndexFiles()
public LaunchConfigBuilder indexFiles(List<String> indexFiles)
indexFiles
- the potential index file names.LaunchConfig.getIndexFiles()
public LaunchConfigBuilder ssl(SSLContext sslContext)
sslContext
- the SSL context.SSLContexts
,
LaunchConfig.getSSLContext()
public LaunchConfigBuilder other(String key, String value)
key
- The key of the propertyvalue
- The value of the propertyLaunchConfig.getOther(String, String)
public LaunchConfigBuilder other(Map<String,String> other)
other
- A map of properties to add to the launch config other propertiesLaunchConfig.getOther(String, String)
public LaunchConfigBuilder defaultRegistry(Registry defaultRegistry)
defaultRegistry
- the default registrypublic LaunchConfig build(@Nullable HandlerFactory handlerFactory)
Supplying null
for the handlerFactory
will result in a launch config that can't be used to start a server.
This is the same as calling build()
.
handlerFactory
- The handler factory for the applicationLaunchConfig
based on this builder's statepublic LaunchConfig build()
This variant is really only useful for using the resultant launch config for testing purposes.
LaunchConfig
based on this builder's state