Properties in ActivePivot
The configuration properties defined and used in ActivePivot are centralized in a single accessor/setter. These 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 JVM arguments, system/environment properties, and external property files.
ActivePivot Properties
Properties in ActivePivot are now 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 you 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 follows the Spring logic for handling properties (see the Springboot documentation)
For example, you can import properties through Spring annotations :
@Import
annotation declares an import of a Configuration class allowing you to logically load either or both of the following:- beans
- nested Configurations defined by another
@ContextConfiguration
annotation defines the Configurations classes to load in a Test class. To work properly in tests, it requires the following annotation:@RunWith(SpringJUnit4ClassRunner.class)
Once the Registry has been instantiated, you cannot dynamically reload registry properties from the Sources. To programmatically change ActivePivot Properties you must use 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 is 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:
- Properties defined in the Spring Environment (if
ActiveViamPropertyFromSpringConfig
class is imported) - System properties (-DXXX arguments)
- Environment variables