public static interface RatpackServer.Definition.Builder
This builder is used by the function given to the RatpackServer.of(Function)
method used to define a server.
The handler(Function)
or handlers(Action)
method “terminates” the build and returns the built definition.
Calling one of these methods is effectively mandatory, while all other methods are optional.
See the documentation of the RatpackServer.of(Function)
method for more detail on how to use this builder.
Modifier and Type | Method and Description |
---|---|
default RatpackServer.Definition |
handler(Class<? extends Handler> handlerType)
Builds the server definition from the given handler type, and state of this builder.
|
RatpackServer.Definition |
handler(Function<? super Registry,? extends Handler> handlerFactory)
Builds the server definition from the given factory, and state of this builder.
|
default RatpackServer.Definition |
handlers(Action<? super Chain> handlers)
Builds the server definition from the given handler chain definition, and state of this builder.
|
RatpackServer.Definition.Builder |
registry(Function<? super Registry,? extends Registry> function)
Specifies the user registry.
|
RatpackServer.Definition.Builder |
registry(Registry registry)
Specifies the user registry.
|
RatpackServer.Definition.Builder |
registryOf(Action<? super RegistrySpec> action)
Specifies the user registry.
|
default RatpackServer.Definition.Builder |
serverConfig(ServerConfig.Builder serverConfigBuilder)
Convenience function that
builds the config from the given builder and delegates to serverConfig(ServerConfig) . |
RatpackServer.Definition.Builder |
serverConfig(ServerConfig serverConfig)
Specifies the server configuration for the application.
|
RatpackServer.Definition.Builder registryOf(Action<? super RegistrySpec> action) throws Exception
Builds a registry from the given spec, and delegates to registry(ratpack.registry.Registry)
.
action
- the definition of the user registrythis
Exception
- any thrown by action
registry(Registry)
RatpackServer.Definition.Builder registry(Registry registry)
This method is not additive. That is, there is only one user registry and subsequent calls to this method override any previous.
registry
- the user registrythis
RatpackServer.Definition.Builder registry(Function<? super Registry,? extends Registry> function)
This method is not additive. That is, there is only one user registry and subsequent calls to this method override any previous.
The given function receives the “base” registry, and must return the “user” registry.
function
- a factory for the user registrythis
RatpackServer.Definition.Builder serverConfig(ServerConfig serverConfig)
Server configs can be created by static methods on the ServerConfig
interface, such as ServerConfig.baseDir(java.nio.file.Path)
.
The server config returned by ServerConfig.noBaseDir()
is used if this method is not called.
This method is not additive. That is, there is only one server config and subsequent calls to this method override any previous.
serverConfig
- the server configurationthis
default RatpackServer.Definition.Builder serverConfig(ServerConfig.Builder serverConfigBuilder)
builds
the config from the given builder and delegates to serverConfig(ServerConfig)
.serverConfigBuilder
- the server configuration (as a builder)this
default RatpackServer.Definition handler(Class<? extends Handler> handlerType)
The handler is retrieved from the registry.
handlerType
- the type of handler to retrieve from the registryRatpackServer.Definition handler(Function<? super Registry,? extends Handler> handlerFactory)
The registry given to this method is not the same registry that is defined by the registry(Registry)
methods (i.e. the user registry).
It also contains additional entries added to all Ratpack applications.
The Handlers
type provides handler implementations that may be of use.
handlerFactory
- a factory function for the root handlerHandlers
,
handlers(Action)
default RatpackServer.Definition handlers(Action<? super Chain> handlers)
The server registry is available during the action via the Chain.getRegistry()
method of the given chain.
handlers
- a handler defining actionChain