Class ConfigGetter<T extends com.yahoo.config.ConfigInstance>


  • public class ConfigGetter<T extends com.yahoo.config.ConfigInstance>
    extends java.lang.Object
    This is a simple config getter that retrieves a config with a given class and configId through a simple method call. No subscription is retained when the config has been returned to the client. This class is mainly targeted to unit tests that do not want the extra complexity incurred by setting up their own subscriber. Another use-case is clients that get config, do a task, and exit, e.g. command-line tools.
    Author:
    gjoranv
    • Constructor Summary

      Constructors 
      Constructor Description
      ConfigGetter​(ConfigSource source, java.lang.Class<T> clazz)
      Creates a ConfigGetter for class clazz with the specified ConfigSource.
      ConfigGetter​(java.lang.Class<T> clazz)
      Creates a ConfigGetter for class clazz
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static <T extends com.yahoo.config.ConfigInstance>
      T
      getConfig​(java.lang.Class<T> c, java.lang.String configId)
      Creates a ConfigGetter instance and returns an instance of the config class c.
      static <T extends com.yahoo.config.ConfigInstance>
      T
      getConfig​(java.lang.Class<T> c, java.lang.String configId, ConfigSource source)
      Creates a ConfigGetter instance and returns an instance of the config class c.
      T getConfig​(java.lang.String configId)
      Returns an instance of the config class specified in the constructor.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ConfigGetter

        public ConfigGetter​(java.lang.Class<T> clazz)
        Creates a ConfigGetter for class clazz
        Parameters:
        clazz - a config class
      • ConfigGetter

        public ConfigGetter​(ConfigSource source,
                            java.lang.Class<T> clazz)
        Creates a ConfigGetter for class clazz with the specified ConfigSource.
        Parameters:
        source - a ConfigSource
        clazz - a config class
    • Method Detail

      • getConfig

        public T getConfig​(java.lang.String configId)
        Returns an instance of the config class specified in the constructor.
        Parameters:
        configId - a config id to use when getting the config
        Returns:
        an instance of a config class
      • getConfig

        public static <T extends com.yahoo.config.ConfigInstance> T getConfig​(java.lang.Class<T> c,
                                                                              java.lang.String configId)
        Creates a ConfigGetter instance and returns an instance of the config class c.
        Parameters:
        c - a config class
        configId - a config id to use when getting the config
        Returns:
        an instance of a config class
      • getConfig

        public static <T extends com.yahoo.config.ConfigInstance> T getConfig​(java.lang.Class<T> c,
                                                                              java.lang.String configId,
                                                                              ConfigSource source)
        Creates a ConfigGetter instance and returns an instance of the config class c.
        Parameters:
        c - a config class
        configId - a config id to use when getting the config
        source - a ConfigSource
        Returns:
        an instance of a config class