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!"); } }; } } );
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 |
compressResponses(boolean compressResponses)
Whether to compress responses.
|
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 content length.
|
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 |
reloadable(boolean reloadable)
Whether or not the application is "reloadable".
|
LaunchConfigBuilder |
ssl(SSLContext sslContext)
The SSL context to use if the application serves content over HTTPS.
|
LaunchConfigBuilder |
threads(int threads)
How many request handling 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 reloadable(boolean reloadable)
Default value is false
.
reloadable
- Whether or not the application is "reloadable".LaunchConfig.isReloadable()
public LaunchConfigBuilder threads(int threads)
Default value is 0
.
threads
- the number of threads for handling application requestsLaunchConfig.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)
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 responses()
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 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