All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.rollbar.notifier.config.ConfigProviderHelper Maven / Gradle / Ivy

Go to download

For connecting your applications built on the JVM to Rollbar for Error Reporting

There is a newer version: 2.0.0-alpha.1
Show newest version
package com.rollbar.notifier.config;

import java.lang.reflect.Constructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Static helper for the ConfigProvider class.
 */
public class ConfigProviderHelper {

  private static final Logger thisLogger = LoggerFactory.getLogger("ConfigProviderHelper");

  /**
   * Instantiate a ConfigProvider object based on the class name given as parameter.
   * @param configProviderClassName the string name of the config provider class
   */
  public static ConfigProvider getConfigProvider(String configProviderClassName) {
    ConfigProvider configProvider = null;

    if (configProviderClassName != null && !"".equals(configProviderClassName)) {
      Class userConfigProviderClass = null;
      try {
        userConfigProviderClass = Class.forName(configProviderClassName);
      } catch (Exception e) {
        thisLogger.error("Could not get the config provider class: {}.",
                configProviderClassName, e.getMessage());
      }
      if (userConfigProviderClass != null) {
        try {
          Constructor constructor = userConfigProviderClass.getConstructor();
          configProvider = constructor.newInstance();
        } catch (Exception e) {
          thisLogger.error("Could not create the config provider.", e);
        }
      }
    }
    return configProvider;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy