Package com.mastfrog.acteur.server
Class ServerBuilder
java.lang.Object
com.mastfrog.acteur.server.ServerBuilder
Hides the complexity of initializing Guice and Settings to start a server
simply.
- Author:
- Tim Boudreau
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a ServerBuilder with Namespace.DEFAULT as its namespace.ServerBuilder(com.mastfrog.giulius.scope.ReentrantScope scope) ServerBuilder(String namespace) Create a ServerBuilder with the passed namespace as its namespace.ServerBuilder(String namespace, com.mastfrog.giulius.scope.ReentrantScope scope) -
Method Summary
Modifier and TypeMethodDescriptionadd(com.google.inject.Module module) Add a module which should be used for Guice bindingsadd(com.mastfrog.settings.Settings settings) Explicitly add a Settings which should be used for resolving @Named bindings, in addition to any bound to the namespace (i.e.Add a module type which will be instantiated.applicationClass(Class<? extends Application> type) Set the class of the application.com.mastfrog.acteur.util.Serverbuild()Build a Server object which can be started with its start() method (call await() on the resulting ServerControl object to keep it running).disableBindings(com.mastfrog.giulius.SettingsBindings... bindings) Disable binding of settings to some types if you know they will not be used, to save (minimal) memory.enableOnlyBindingsFor(com.mastfrog.giulius.SettingsBindings... bindings) Explicitly set the list of types that are bound to settings to save (minimal) memory.If true, do not actually use the namespace feature of Dependencies - there is only one namespace - it is just not named "default".com.mastfrog.giulius.scope.ReentrantScopescope()ssl()sslConfig(io.netty.handler.ssl.SslContext context) com.mastfrog.giulius.DependenciesBuilderAdd a type which will be bound.
-
Constructor Details
-
ServerBuilder
public ServerBuilder(com.mastfrog.giulius.scope.ReentrantScope scope) -
ServerBuilder
-
ServerBuilder
public ServerBuilder()Create a ServerBuilder with Namespace.DEFAULT as its namespace. That means settings will be read from /etc/defaults.properties, ~/defaults.properties and ./defaults.properties -
ServerBuilder
Create a ServerBuilder with the passed namespace as its namespace. That means settings will be read from /etc/$NAMESPACE.properties, ~/$NAMESPACE.properties and ./$NAMESPACE.properties- Parameters:
namespace- A namespace - must be a legal file name, no path separators
-
-
Method Details
-
mergeNamespaces
If true, do not actually use the namespace feature of Dependencies - there is only one namespace - it is just not named "default". This is the common case, but for compatibility reasons is not currently the default. This reduces memory footprint overhead when looking up bound settings, since reflection is not needed and there is only one place to look.- Returns:
-
applicationClass
Set the class of the application. If not set, assumes GenericApplication- Parameters:
type- The application class- Returns:
- this
-
sslConfig
-
ssl
-
add
Explicitly add a Settings which should be used for resolving @Named bindings, in addition to any bound to the namespace (i.e. /etc/$NAMESPACE.properties)- Parameters:
settings- A settings- Returns:
- this
-
add
Add a module which should be used for Guice bindings- Parameters:
module- A module- Returns:
- this
-
add
Add a module type which will be instantiated. The constructor may be a default constructor, or may take a Settings object, or a Settings and a ReentrantScope.- Parameters:
module- The module type- Returns:
- this
-
withType
Add a type which will be bound. Use this to add your classes to the Guice injector if they will be passed between Acteurs. The rule is: If you accept it in an Acteur constructor and it is not part of the framework, you need to pass it here.- Parameters:
types- Some classes- Returns:
- this
-
scope
public com.mastfrog.giulius.scope.ReentrantScope scope() -
enableHelp
-
disableHelp
-
enableCORS
-
disableCORS
-
disableBindings
Disable binding of settings to some types if you know they will not be used, to save (minimal) memory. This is only significant if you are running in < 20Mb heap.- Parameters:
bindings- The bindings to remove- Returns:
- this
-
enableOnlyBindingsFor
Explicitly set the list of types that are bound to settings to save (minimal) memory.- Parameters:
bindings- The types of bindings to set up- Returns:
- this
-
build
Build a Server object which can be started with its start() method (call await() on the resulting ServerControl object to keep it running).- Returns:
- A server, not yet started
- Throws:
IOException- if something goes wrong
-
withShutdownHookWaitMillis
-
toDependenciesBuilder
- Throws:
IOException
-