Properties in ActivePivot
The properties defined and used in ActivePivot for configuration purposes are centralized in a single accessor/setter. Those properties are now also defined and documented in a single ActiveViamProperty.java
file.
The new mechanism for property handling in ActivePivot allows the usage of both JVM Arguments, System/Environment properties and External property files.
ActivePivot Properties
Properties in ActivePivot now are defined and documented in the ActiveViamProperty
class. They correspond to the properties used to configure ActivePivot as well as other ActiveViam products.
PropertyRegistry
The The PropertyRegistry
class contains the information about resolved Properties and their current values.
By default, ActivePivot provides the property handling mechanism that can use the following sources for ActivePivot properties :
- System properties (JVM -Dxxx arguments)
- Environment variables
We also provide the following ActiveViamPropertyFromSpringConfig
configuration class, which allows users to use Spring-specific annotations or methods.
Properties defined in the Spring environment through property files or other means are resolved during the Bean initializing phase ONLY IF the ActiveViamPropertyFromSpringConfig
configuration class was imported in the Spring configuration. In that case, the properties resolving order will follow the Spring logic for handling properties (see the Springboot documentation for more information on the matter.)
For example, properties import can be done through Spring annotations :
@Import
annotation declares an import of a Configuration class allowing to logically load beans and/or nested Configurations defined by another.@ContextConfiguration
annotation defines the Configurations classes to load in a Test class. It requires the following annotation to properly work in tests :@RunWith(SpringJUnit4ClassRunner.class)
Once the Registry has been instantiated, it is not possible to dynamically reload properties of the registry from the Sources. Any attempt to programmatically change ActivePivot Properties should be done through the
ActiveViamPropertyRegistry
API.
The ActiveViamPropertyRegistry
provides several methods to handle properties :
- Type-specific accessors with default fallback value:
getString()
,getInteger()
,getLong()
,getBoolean()
,getDouble
- Type-specific accessors with required value:
getRequiredString()
,getRequiredInteger()
,getRequiredLong()
,getRequiredBoolean()
,getRequiredDouble()
. When a requested property is not defined in thePropertyRegistry
while calling these methods, an exception will be thrown. - Generic setter
set()
- Entry deletion method
clear()
Resolving Properties
The properties are resolved in the following order, from the highest priority source to the lowest one :
- Properties defined in the Spring Environment (if
ActiveViamPropertyFromSpringConfig
classes is imported) - System properties (-DXXX arguments)
- Environment variables