Beispiel #1
0
  /**
   * Default constructor. Tries to load the profile from the file %lt;profile>.properties, falling
   * back on defaults if is not successful.
   *
   * @param profile
   * @throws InvalidProfileConfigurationException if the profile contains invalid values
   */
  public Profile(String profile) {
    properties = new Properties(defaultProperties);
    if (profile != null) {
      try {
        final InputStream propFileStream =
            getClass().getResourceAsStream("/" + profile + ".properties");
        if (propFileStream != null) {
          properties.load(propFileStream);
          LOGGER.info("Loaded profile %s", profile.toUpperCase());
        } else {
          LOGGER.error(
              "Could not load properties for profile %s, running with default profile", profile);
        }

      } catch (Exception e) {
        LOGGER.error(
            "Could not load properties for profile %s, running with default profile", profile);
      }
    }
    LOGGER.info(
        "Configured profile (%s):\n%s ",
        profile == null ? "DEFAULT" : profile.toUpperCase(), getPropertiesAsString());
    validate();
  }