Class ConfigHelper


  • public class ConfigHelper
    extends Object
    • Method Detail

      • retrieveChannelConfiguration

        public static org.eclipse.microprofile.config.Config retrieveChannelConfiguration​(javax.enterprise.inject.Instance<Map<String,​Object>> instances,
                                                                                          org.eclipse.microprofile.config.Config config)
        Computes the channel configuration The channel configuration is extracted from 3 places (from the most important to the less important):
        1. The channel configuration in the application configuration (the mp.messaging.[incoming|outgoing].channel.attr=value
        2. From a bean exposing a Map%lt;String, Object> exposed with @Identifier(channel). The content of this map is generated by the runtime. The name can be configured using the mp.messaging.[incoming|outgoing].channel.kafka-configuration attribute
        3. The default Kafka configuration (generally the kafka.attr=value properties), also exposed as an identified Map%lt;String, Object>.
        Parameters:
        config - the received config
        Returns:
        the computed configuration
      • merge

        public static org.eclipse.microprofile.config.Config merge​(org.eclipse.microprofile.config.Config passedCfg,
                                                                   Map<String,​Object> defaultKafkaCfg)
      • merge

        public static org.eclipse.microprofile.config.Config merge​(org.eclipse.microprofile.config.Config passedCfg,
                                                                   Map<String,​Object> namedConfig,
                                                                   Map<String,​Object> defaultKafkaCfg)
        Returns a Config instance merging the values from the 3 sources (the channel configuration, a map specific to the channel and the global Kafka configuration).
        Parameters:
        passedCfg - the channel configuration (high priority)
        namedConfig - the channel specific configuration (medium priority)
        defaultKafkaCfg - the default Kafka configuration (low priority)
        Returns:
        the computed config.
      • retrieveDefaultKafkaConfig

        public static Map<String,​Object> retrieveDefaultKafkaConfig​(javax.enterprise.inject.Instance<Map<String,​Object>> instances)
        Retrieves the default Kafka configuration if any. It looks for a Map%lt;String, Object&gt; identified by DEFAULT_KAFKA_BROKER.
        Parameters:
        instances - the instances of map exposed as bean
        Returns:
        the map, empty if the lookup fails
      • getChannelSpecificConfig

        public static Map<String,​Object> getChannelSpecificConfig​(javax.enterprise.inject.Instance<Map<String,​Object>> instances,
                                                                        org.eclipse.microprofile.config.Config config)
        Looks for a Map%lt;String, Object&gt; for the given channel. The map is identified using Identifier. The identifier value is either configured in the channel configuration, or is the channel name.
        Parameters:
        instances - the instances of map exposed as bean
        config - the channel configuration
        Returns:
        the map, empty if the lookup fails.
      • lookupForIdentifiedConfiguration

        public static Map<String,​Object> lookupForIdentifiedConfiguration​(javax.enterprise.inject.Instance<Map<String,​Object>> instances,
                                                                                String identifier,
                                                                                boolean optional)
        Looks for a CDI bean of type Map identified using the given named. If the lookup fails and optional is true, an UnsatisfiedResolutionException is thrown. Otherwise, an empty Map is returned.
        Parameters:
        identifier - the identifier
        optional - whether the lookup is optional
        Returns:
        the result