Class Config
java.lang.Object
com.amazonaws.secretsmanager.util.Config
A class for accessing configuration information from a properties file or from the System properties. Properties defined in the file will override the properties set in the System properties. The properties file should be located somewhere on the class path for the class loader used to load this class.
The default file that properties will be fetched from is referred to by Config.CONFIG_FILE_NAME.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe name of the properties file used for configuration; "secretsmanager.properties". -
Method Summary
Modifier and TypeMethodDescriptionfullPropertyName(String propertyName) Extends a property name to be the full version written in the configuration file.Class<?>getClassPropertyWithDefault(String propertyName, Class<?> defaultValue) Returns aClassproperty or a default value if the property is not set.intgetIntPropertyWithDefault(String propertyName, int defaultValue) Returns aintproperty or a default value if the property is not set.longgetLongPropertyWithDefault(String propertyName, long defaultValue) Returns alongproperty or a default value if the property is not set.Class<?>getRequiredClassProperty(String propertyName) Returns aClassproperty or throws aNoSuchElementExceptionif the property is not set.intgetRequiredIntProperty(String propertyName) Returns aintproperty or throws aNoSuchElementExceptionif the property is not set.longgetRequiredLongProperty(String propertyName) Returns alongproperty or throws aNoSuchElementExceptionif the property is not set.getRequiredStringProperty(String propertyName) Returns aStringproperty or throws aNoSuchElementExceptionif the property is not set.getStringPropertyWithDefault(String propertyName, String defaultValue) Returns aStringproperty or a default value if the property is not set.getSubconfig(String subprefix) Extracts all of the properties for a given subprefix into its ownConfigobject.static ConfigloadConfigFrom(String resourceName) Loads a configuration from a specific configuration file.static ConfigLoads a configuration fromCONFIG_FILE_NAME.
-
Field Details
-
CONFIG_FILE_NAME
The name of the properties file used for configuration; "secretsmanager.properties".- See Also:
-
-
Method Details
-
loadConfigFrom
Loads a configuration from a specific configuration file. Will use the System properties as defaults.- Parameters:
resourceName- The name of the config file to load from.- Returns:
- Config A new
Configwith the properties from the file and the system properties as defaults.
-
loadMainConfig
Loads a configuration fromCONFIG_FILE_NAME. Will use the System properties as defaults.- Returns:
- Config A new
Configwith the properties from theCONFIG_FILE_NAMEfile and the system properties as defaults.
-
getSubconfig
Extracts all of the properties for a given subprefix into its ownConfigobject. The property names will be changed to no longer have the subprefix.- Parameters:
subprefix- The subprefix to get all of the properties for.- Returns:
- Config Configuration properties for the subprefix
-
fullPropertyName
Extends a property name to be the full version written in the configuration file. This full name is not necessarily the name that the property is indexed with in thisConfigobject.- Parameters:
propertyName- The property name to extend.- Returns:
- String The full property name as written in the configuration file.
-
getStringPropertyWithDefault
Returns aStringproperty or a default value if the property is not set.- Parameters:
propertyName- The name of the property to retrieve.defaultValue- The default value to use.- Returns:
- String The
Stringproperty or a default value if the property is not set.
-
getIntPropertyWithDefault
Returns aintproperty or a default value if the property is not set.- Parameters:
propertyName- The name of the property to retrieve.defaultValue- The default value to use.- Returns:
- int The
intproperty or a default value if the property is not set. - Throws:
PropertyException- If the property value is not a decimalint.
-
getLongPropertyWithDefault
Returns alongproperty or a default value if the property is not set.- Parameters:
propertyName- The name of the property to retrieve.defaultValue- The default value to use.- Returns:
- long The
longproperty or a default value if the property is not set. - Throws:
PropertyException- If the property value is not a decimallong.
-
getClassPropertyWithDefault
Returns aClassproperty or a default value if the property is not set.- Parameters:
propertyName- The name of the property to retrieve.defaultValue- The default value to use.- Returns:
- Class The
Classproperty or a default value if the property is not set. - Throws:
PropertyException- If the class name does not exist in this class loader.
-
getRequiredStringProperty
Returns aStringproperty or throws aNoSuchElementExceptionif the property is not set.- Parameters:
propertyName- The name of the property to retrieve.- Returns:
- String The
Stringproperty or a default value if the property is not set. - Throws:
NoSuchElementException- If the property is not set.
-
getRequiredIntProperty
Returns aintproperty or throws aNoSuchElementExceptionif the property is not set.- Parameters:
propertyName- The name of the property to retrieve.- Returns:
- int The
intproperty or a default value if the property is not set. - Throws:
PropertyException- If the property value is not a decimalint.NoSuchElementException- If the property is not set.
-
getRequiredLongProperty
Returns alongproperty or throws aNoSuchElementExceptionif the property is not set.- Parameters:
propertyName- The name of the property to retrieve.- Returns:
- long The
longproperty or a default value if the property is not set. - Throws:
PropertyException- If the property value is not a decimallong.NoSuchElementException- If the property is not set.
-
getRequiredClassProperty
Returns aClassproperty or throws aNoSuchElementExceptionif the property is not set.- Parameters:
propertyName- The name of the property to retrieve.- Returns:
- Class The
Classproperty or a default value if the property is not set. - Throws:
PropertyException- If the class name does not exist in this class loader.NoSuchElementException- If the property is not set.
-