public interface ServerConfig extends ConfigData
This object represents the basic information needed to bootstrap the server (e.g. getPort()
),
but also provides access to any externalised config objects to be used by the application via ConfigData.get(String, Class)
(see also: getRequiredConfig()
).
A server config object is-a ConfigData
object.
Server config objects are programmatically built via a ServerConfig.Builder
, which can be obtained via
static methods of this type such as findBaseDir()
, noBaseDir()
, embedded()
etc.
Modifier and Type | Interface and Description |
---|---|
static interface |
ServerConfig.Builder |
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_MAX_CONTENT_LENGTH
The default max content length.
|
static int |
DEFAULT_PORT
The default port for Ratpack applications, 5050.
|
static int |
DEFAULT_THREADS
The default number of threads an application should use.
|
Modifier and Type | Method and Description |
---|---|
static ServerConfig.Builder |
baseDir(File baseDir)
Create a new builder, using the given file as the base dir.
|
static ServerConfig.Builder |
baseDir(Path baseDir)
Create a new builder, using the given file as the base dir.
|
static ServerConfig.Builder |
embedded()
Creates a builder configured to use no base dir, development mode and an ephemeral port.
|
static ServerConfig.Builder |
embedded(Path baseDir)
Creates a builder configured to use the given base dir, development mode and an ephemeral port.
|
static ServerConfig.Builder |
findBaseDir()
Creates a server config builder with the
base dir as the “directory” on the classpath that contains a file called .ratpack . |
static ServerConfig.Builder |
findBaseDir(String markerFilePath)
Creates a server config builder with the
base dir as the “directory” on the classpath that contains the marker file at the given path. |
InetAddress |
getAddress()
The address of the interface that the application should bind to.
|
FileSystemBinding |
getBaseDir()
The base dir of the application, which is also the initial
FileSystemBinding . |
int |
getMaxContentLength()
The max content length to use for the HttpObjectAggregator.
|
int |
getPort()
The port that the application should listen to requests on.
|
URI |
getPublicAddress()
The public address of the site used for redirects.
|
ImmutableSet<ConfigObject<?>> |
getRequiredConfig()
The config objects that were declared as required when this server config was built.
|
SSLContext |
getSSLContext()
The SSL context to use if the application will serve content over HTTPS.
|
int |
getThreads()
The number of threads for handling application requests.
|
boolean |
isDevelopment()
Whether or not the server is in "development" mode.
|
boolean |
isHasBaseDir()
Whether or not the base dir of the application has been set.
|
static ServerConfig.Builder |
noBaseDir()
Creates a builder configured to use no base dir.
|
get, get, getAsConfigObject, of, of, of, of, of, of
shouldReload, toString
static final int DEFAULT_PORT
static final int DEFAULT_MAX_CONTENT_LENGTH
static final int DEFAULT_THREADS
Runtime.getRuntime().availableProcessors() * 2
.static ServerConfig.Builder embedded()
static ServerConfig.Builder embedded(Path baseDir)
baseDir
- the server base dirstatic ServerConfig.Builder noBaseDir()
static ServerConfig.Builder findBaseDir()
base dir
as the “directory” on the classpath that contains a file called .ratpack
.
Calling this method is equivalent to calling findBaseDir(".ratpack")
.
findBaseDir(String)
static ServerConfig.Builder findBaseDir(String markerFilePath)
base dir
as the “directory” on the classpath that contains the marker file at the given path.
The classpath search is performed using ClassLoader.getResource(String)
using the current thread's context class loader
.
If the resource is not found, an IllegalStateException
will be thrown.
If the resource is found, the enclosing directory of the resource will be converted to a Path
and set as the base dir.
This allows a directory within side a JAR (that is on the classpath) to be used as the base dir potentially.
markerFilePath
- the path to the marker file on the classpathstatic ServerConfig.Builder baseDir(Path baseDir)
baseDir
- The base dir of the launch configstatic ServerConfig.Builder baseDir(File baseDir)
baseDir
- The base dir of the launch configint getPort()
Defaults to 5050.
@Nullable InetAddress getAddress()
A value of null causes all interfaces to be bound. Defaults to null.
ImmutableSet<ConfigObject<?>> getRequiredConfig()
Required config is declared via the ServerConfig.Builder.require(String, Class)
when building.
All required config is made part of the base registry (which the server registry joins with),
which automatically makes the config objects available to the server registry.
ServerConfig.Builder.require(String, Class)
boolean isDevelopment()
A flag for indicating to Ratpack internals that the app is under development; diagnostics and reloading are more important than performance and security.
In development mode Ratpack will leak internal information through diagnostics and stacktraces by sending them to the response.
true
if the server is in "development" modeint getThreads()
If the value is greater than 0, a thread pool (of this size) will be created for servicing requests and doing computation.
If the value is 0 (default) or less, a thread pool of size Runtime.availableProcessors()
* 2
will be used.
This effectively sizes the ExecController.getExecutor()
thread pool size.
URI getPublicAddress()
@Nullable SSLContext getSSLContext()
null
if the application does not use SSL.int getMaxContentLength()
boolean isHasBaseDir()
FileSystemBinding getBaseDir() throws NoBaseDirException
FileSystemBinding
.NoBaseDirException
- if this launch config has no base dir set.