class ConfigProperties {

    public static int retrieveConfigSetting(String property, int defaultValue) {

        int settingValue;
        try {
            String propValue = System.getProperty(property);
            if (propValue == null) {
                return defaultValue;
            }

            settingValue = Integer.parseInt(propValue);

            if (settingValue <= 0) {
                LOGGER.error("Invalid {} value: {}, defaulting to {}", property, propValue, defaultValue);
                settingValue = defaultValue;
            }
        } catch (Exception ex) {
            LOGGER.error("Invalid {} value, defaulting to {}: {}", property, defaultValue, ex.getMessage());
            settingValue = defaultValue;
        }

        return settingValue;
    }

}