public final class ServerEnvironment implements AutoCloseable

The server conditions and configuration under which the application operates.


Some parts of the ServerEnvironment can be customized based on the EnvironmentType. To do so, one of the overloads of the use method can be called. Two environment types exist out of the box: Tests and Production. For example:


A custom environment type may also be used:

    final class StagingEnvironment extends EnvironmentType {

If Staging is enabled, the specified value is going to be returned on storageFactory.


Link copied to clipboard
public interface Fn<R> implements Function<T, R>
A function which accepts a class of EnvironmentType and returns a value configured in a ServerEnvironment.
Link copied to clipboard
public class TypeConfigurator
Allows to configure values used by the ServerEnvironment for the given type.


Link copied to clipboard
void close()
Releases resources associated with this instance.
Link copied to clipboard
void configureDeployment(Supplier<DeploymentType> supplier)
Makes the deploymentType return the values from the provided supplier.
Link copied to clipboard
synchronized Delivery delivery()
Returns the delivery mechanism specific to this environment.
Link copied to clipboard
DeploymentType deploymentType()
The type of the environment application is deployed to.
Link copied to clipboard
static ServerEnvironment instance()
Returns a singleton instance.
Link copied to clipboard
CommandScheduler newCommandScheduler()
Obtains command scheduling mechanism used by CommandBus in this environment.
Link copied to clipboard
NodeId nodeId()
Obtains the identifier of the server node, on which this code is running at the moment.
Link copied to clipboard
Optional<StorageFactory> optionalStorageFactory()
Returns a storage factory for the current environment, or an empty Optional if it was not configured.
Link copied to clipboard
void reset()
This is test-only method required for cleaning of the server environment instance in tests.
Link copied to clipboard
void scheduleCommandsUsing(Supplier<CommandScheduler> commandScheduler)
Assigns command scheduling mechanism used at this environment by all CommandBus instances.
Link copied to clipboard
StorageFactory storageFactory()
Obtains the storage factory for the current environment.
Link copied to clipboard
Optional<TracerFactory> tracing()
Obtains the TracerFactory associated with the current environment, if it was set.
Link copied to clipboard
TransportFactory transportFactory()
Obtains the transport factory for the current environment.
Link copied to clipboard
Class<? extends EnvironmentType> type()
Obtains the type of the current server environment.
Link copied to clipboard
static ServerEnvironment.TypeConfigurator when(Class<? extends EnvironmentType> type)
Starts flowing API chain for configuring ServerEnvironment for the passed type.