Package kos.core

Class 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 Detail

      • defaultSerializer

        public static final Serializer defaultSerializer
        Default Serializer for 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
        Default Serializer for 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
      • defaultVertx

        public static final Supplier<io.vertx.core.Vertx> defaultVertx
        Default reference to a Vertx instance.
      • config

        public static final Lang.Lazy<io.vertx.core.json.JsonObject> config
        Default configuration. It is lazily loaded by the ConfigRetriever found 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.
    • Constructor Detail

      • Kos

        public Kos()
    • Method Detail

      • 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 by LoggerFactory.LOGGER_DELEGATE_FACTORY_CLASS_NAME. Despite of its new mechanism, it tries its best to propagate the found LogDelegateFactory and make it available for other logs that relies on LoggerFactory.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 from LoggerFactory.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 different ConfigStore and computes the final configuration.
        Parameters:
        handler - handler receiving the computed configuration
        Throws:
        KosException - if couldn't read the configuration