Class PropertyProvider
java.lang.Object
de.aristaflow.adept2.base.configuration.PropertyProvider
- Direct Known Subclasses:
ConfigurationPropertyProvider
This class provides global properties that are needed for the whole AristaFlow-platform. These
properties are needed for initialising the configuration framework which is why they are parsed
very early when bootstrapping. This also includes global properties (starting with
This interface encapsulates the concrete representation of the global properties. For instance, these may stem from the system properties or from a servlet context, depending on the execution context of the AristaFlow-platform.
arflow.confVar) which will be injected into the configuration framework allowing to
reference this properties in service configurations. This interface encapsulates the concrete representation of the global properties. For instance, these may stem from the system properties or from a servlet context, depending on the execution context of the AristaFlow-platform.
This class may be extended to reflect specific requirements (that is specific global properties) needed by a configuration manager.
This class parses the following properties from the designated map (in parentheses the default value that will apply if the property is not set):
- arflow.logdir (default:
./logs, referring either to the current or user home directory, the one which can be written) - arflow.datadir (default:
./data, referring either to the current or user home directory, the one which can be read) - arflow.libdir (default:
./lib, referring either to the current or user home directory, the one which can be written) - arflow.useSunSecProvider (default:
false) - arflow.totalMemPerthousandStreamThreshold (default:
40) - arflow.skipClosing (default:
false) - arflow.confVar.*
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe property names for retrieving the base directories which are the program/installation directory and the user home/workspace directory.protected final LoggerThe logger for property providers. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPropertyProvider(Map<String, String> properties) Creates a newPropertyProviderand parses all corresponding global properties from the designated map and/or sets the properties appropriately. -
Method Summary
Modifier and TypeMethodDescriptiongetBaseForDefaultDirs(Logger logger) Gets the base directories which are used as parents for the default directories for configuration, logs, libraries and data.
Usually the first one is the directory providing the running application (osgi.install.areaoruser.dir), the second one is a subdirectory of the user home (osgi.instance.areaoruser.home/.<companyname>/<applicationname>).booleanDeprecated, for removal: This API element is subject to removal in a future version.Do only use if absolutely required.Gets an unmodifiable map containing all substitutions (interpolation) that need to be applied to all configurations.intGets the portion (per thousand) of the total memory available for the JVM that is used as threshold to switch between holding (temporary) data in a stream in main memory or storing it in a file.static FileGets the base directory below the user home which is used as default base for the instance area (workspace) and the other default directories.booleanGets whether the Sun providers should be used for the security API.protected voidinitialiseProperties(Map<String, String> properties) Initialises, checks and sets the values of the global properties as well as the substituted variables.static StringresolveConfVar(String confVar, Configuration conf) Gets the value of the designated configuration variable resolved by the designated configuration.
-
Field Details
-
DIRECTORY_PROPERTY_NAMES
The property names for retrieving the base directories which are the program/installation directory and the user home/workspace directory.useris for the directories from the standard system properties,osgiis for the OSGi specific directories. -
logger
The logger for property providers. It is protected for extensibility.
-
-
Constructor Details
-
PropertyProvider
Creates a newPropertyProviderand parses all corresponding global properties from the designated map and/or sets the properties appropriately.- Parameters:
properties- A map providing all required global properties and values for substituted variables.- Throws:
ConfigurationException- If there are problems retrieving a required global property or a substituted variables from the designated map, aConfigurationExceptionwill be thrown.
-
-
Method Details
-
getSubstitutedVariables
Gets an unmodifiable map containing all substitutions (interpolation) that need to be applied to all configurations. If a key of this map is found in a configuration, it will be replaced with the corresponding value from the map. The key needs to have the appropriate prefix in the configuration, for instance,${arflow:key}will be replaced byvalue.- Returns:
- An unmodifiable map containing the keys which will be replaced by the corresponding values from the map if they are found in a configuration.
-
getUseSunSecurityProviders
public boolean getUseSunSecurityProviders()Gets whether the Sun providers should be used for the security API. This prevents using other registered security providers like from Apache or Bouncy Castle.- Returns:
- Whether the Sun providers should be used for the security API. This prevents using other registered security providers like from Apache or Bouncy Castle.
-
getTotalMemPerthousandStreamThreshold
public int getTotalMemPerthousandStreamThreshold()Gets the portion (per thousand) of the total memory available for the JVM that is used as threshold to switch between holding (temporary) data in a stream in main memory or storing it in a file. Data with a size below this threshold is kept in memory, bigger data will be stored in a temporary file.- Returns:
- The portion (per thousand) of the total memory available for the JVM used as threshold to switch between holding stream data in memory or file storage.
-
getSkipClosing
Deprecated, for removal: This API element is subject to removal in a future version.Do only use if absolutely required. This will be removed as soon as closing works reliable.Gets whether to skip closing introduced with 15.0.0. This helps in case of buggy closing, e. early or inappropriate closing.- Returns:
- Whether to skip closing introduced with 15.0.0.
-
initialiseProperties
Initialises, checks and sets the values of the global properties as well as the substituted variables. The following properties are parsed from the designated map (with a default value where appropriate):- arflow.logdir (default:
./logs, referring either to the current or user home directory, the one which can be written) - arflow.datadir (default:
./data, referring either to the current or user home directory, the one which can be read) - arflow.libdir (default:
./lib, referring either to the current or user home directory, the one which can be written) - arflow.useSunSecProvider (default:
false) - arflow.totalMemPerthousandStreamThreshold (default:
40) - arflow.skipClosing (default:
false) - arflow.confVar.*
- arflow.logdir (default:
./logs, referring either to the current or user home directory, the one which can be written) - arflow.datadir (default:
./data, referring either to the current or user home directory, the one which can be read) - arflow.libdir (default:
./lib, referring either to the current or user home directory, the one which can be written)
- Parameters:
properties- The properties which to parse.- Throws:
ConfigurationException- If the user dir for the log dir is not a valid directory or the default data directory could not be created, aConfigurationExceptionwill be thrown.
- arflow.logdir (default:
-
getBaseForDefaultDirs
Gets the base directories which are used as parents for the default directories for configuration, logs, libraries and data.
Usually the first one is the directory providing the running application (osgi.install.areaoruser.dir), the second one is a subdirectory of the user home (osgi.instance.areaoruser.home/.<companyname>/<applicationname>). When running in an Eclipse/OSGi platform, the corresponding directories will be preferred.- Parameters:
logger- The logger to which to log problems when determining the base directories.- Returns:
- The base directories which are used as parents for the default directories for
configuration, logs, libraries and data. The list is unmodifiable and may contain
nullentries.
-
getUserHomeBaseDir
Gets the base directory below the user home which is used as default base for the instance area (workspace) and the other default directories. This is the "user" fall-back used bygetBaseForDefaultDirs(Logger)for the instance area (pos == 1), that isuser.home/.<companyname>/<applicationname>(the company and the product name only being appended if available). It does not take the OSGiosgi.instance.areainto account.- Returns:
- The user home based base directory or
nullifuser.homeis not set.
-
resolveConfVar
Gets the value of the designated configuration variable resolved by the designated configuration. The configuration needs to accept the adding of a temporarily entry. This allows to get globally configured variables like the data directory.- Parameters:
confVar- The value of the configuration variable to which to apply the variable resolution of the designated configuration.
Note that depending on the delimiter of the designated configuration, this value may be subject of list handling. In this case only the first list value will be returned.conf- The configuration to determine the designated configuration variable. This needs to be writable.- Returns:
- The value returned by the designated configuration when reading a property with the
designated value. Usually, this applies the variable resolution part of the designated
configuration. Note that this will be the designated string in case no resolution is
applied to it, or even
nullin case it is replaced completely.
-