Package kos.core
Class Kos
- java.lang.Object
-
- kos.core.Kos
-
public final class Kos extends Object
Singleton class that holds kos context. This class was designed to store important configurable pieces from Vert.x, and a few internal kos configuration. Developers are encouraged to use this class only before the server is started, as changes made after that will not be automatically propagated.
-
-
Field Summary
Fields Modifier and Type Field Description static Lang.Lazy<io.vertx.core.json.JsonObject>configDefault configuration.private static Lang.Lazy<io.vertx.config.ConfigRetriever>configRetrieverstatic kos.core.client.SerializerdefaultRestClientSerializerDefaultSerializerfor Rest Clients.static SerializerdefaultSerializerDefaultSerializerfor http requests.static intdefaultStatusForEmptyResponsesDefines the default status code to sent when either no response body is defined or the response body is empty.static Supplier<io.vertx.core.Vertx>defaultVertxDefault reference to aVertxinstance.static Lang.Lazy<ExceptionHandler>exceptionHandlerDefaultExceptionHandler.static ImplementationLoaderimplementationLoaderThe configuredImplementationLoader.private static io.vertx.core.spi.logging.LogDelegateFactorylogFactoryprivate static ConcurrentMap<String,io.vertx.core.logging.Logger>loggersstatic PayloadSerializationStrategypayloadSerializationStrategySerialization strategy used to serialize/deserialize objects.static Map<String,kos.core.client.Serializer>restClientSerializersFound serializers for Rest Clients.static Map<String,Serializer>serializersFound serializers for Http Requests.private static ImplementationLoaderspistatic Lang.Lazy<StringConverter>stringConverterDefaultStringConverter.static Lang.Lazy<io.vertx.ext.web.client.WebClient>webClientDefault WebClient.
-
Constructor Summary
Constructors Constructor Description Kos()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static io.vertx.config.ConfigRetrieverloadConfigRetriever()private static io.vertx.core.VertxloadDefaultVertX()private static io.vertx.core.spi.logging.LogDelegateFactoryloadLogDelegateFactory()Alternative log loader that uses SPI to load the log configuration but will otherwise honour the property defined byLoggerFactory.LOGGER_DELEGATE_FACTORY_CLASS_NAME.private static io.vertx.core.spi.logging.LogDelegateFactoryloadLogDelegateFactory(String canonicalName)Reads the LogDelegateFactory by reflection.private static Map<String,kos.core.client.Serializer>loadRestClientSerializers()private static Map<String,Serializer>loadSerializers()static io.vertx.core.logging.Loggerlogger(Class type)Returns a Logger for a given class.static voidreadConfig(io.vertx.core.Handler<io.vertx.core.json.JsonObject> handler)Reads the configuration from the differentConfigStoreand computes the final configuration.
-
-
-
Field Detail
-
spi
private static final ImplementationLoader spi
-
serializers
public static final Map<String,Serializer> serializers
Found serializers for Http Requests.- See Also:
Serializer,defaultSerializer
-
defaultSerializer
public static final Serializer defaultSerializer
DefaultSerializerfor http requests. If not otherwise configured, this will be used to deserialize payloads from incoming requests or to automatically serialize response objects.
-
restClientSerializers
public static final Map<String,kos.core.client.Serializer> restClientSerializers
Found serializers for Rest Clients.- See Also:
Serializer,defaultRestClientSerializer
-
defaultRestClientSerializer
public static kos.core.client.Serializer defaultRestClientSerializer
DefaultSerializerfor Rest Clients. If not otherwise configured, this will be used to deserialize payloads received as a request response or to automatically serialize objects used as request payload.
-
payloadSerializationStrategy
public static PayloadSerializationStrategy payloadSerializationStrategy
Serialization strategy used to serialize/deserialize objects.
-
defaultStatusForEmptyResponses
public static final int defaultStatusForEmptyResponses
Defines the default status code to sent when either no response body is defined or the response body is empty. Defaults to 204, following the semantics suggested by HTTP RFC.See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204
- See Also:
- Constant Field Values
-
logFactory
private static final io.vertx.core.spi.logging.LogDelegateFactory logFactory
-
loggers
private static final ConcurrentMap<String,io.vertx.core.logging.Logger> loggers
-
implementationLoader
public static final ImplementationLoader implementationLoader
The configuredImplementationLoader.
-
defaultVertx
public static final Supplier<io.vertx.core.Vertx> defaultVertx
Default reference to aVertxinstance.
-
stringConverter
public static final Lang.Lazy<StringConverter> stringConverter
DefaultStringConverter.
-
exceptionHandler
public static final Lang.Lazy<ExceptionHandler> exceptionHandler
DefaultExceptionHandler.
-
config
public static final Lang.Lazy<io.vertx.core.json.JsonObject> config
Default configuration. It is lazily loaded by theConfigRetrieverfound in the classpath.
-
configRetriever
private static final Lang.Lazy<io.vertx.config.ConfigRetriever> configRetriever
-
webClient
public static final Lang.Lazy<io.vertx.ext.web.client.WebClient> webClient
Default WebClient.
-
-
Method Detail
-
loadSerializers
private static Map<String,Serializer> loadSerializers()
-
loadRestClientSerializers
private static Map<String,kos.core.client.Serializer> loadRestClientSerializers()
-
loadLogDelegateFactory
private static io.vertx.core.spi.logging.LogDelegateFactory loadLogDelegateFactory()
Alternative log loader that uses SPI to load the log configuration but will otherwise honour the property defined byLoggerFactory.LOGGER_DELEGATE_FACTORY_CLASS_NAME. Despite of its new mechanism, it tries its best to propagate the foundLogDelegateFactoryand make it available for other logs that relies onLoggerFactory.getLogger(Class).- Returns:
- the found
LogDelegateFactory.
-
loadLogDelegateFactory
private static io.vertx.core.spi.logging.LogDelegateFactory loadLogDelegateFactory(String canonicalName)
Reads the LogDelegateFactory by reflection. Originally copied fromLoggerFactory.getLogger(String).- See Also:
LoggerFactory
-
logger
public static io.vertx.core.logging.Logger logger(Class type)
Returns a Logger for a given class.
-
loadDefaultVertX
private static io.vertx.core.Vertx loadDefaultVertX()
-
loadConfigRetriever
private static io.vertx.config.ConfigRetriever loadConfigRetriever()
-
readConfig
public static void readConfig(io.vertx.core.Handler<io.vertx.core.json.JsonObject> handler)
Reads the configuration from the differentConfigStoreand computes the final configuration.- Parameters:
handler- handler receiving the computed configuration- Throws:
KosException- if couldn't read the configuration
-
-