Features
1. Configuration arrays with auto typization -
(DONE)
The idea is automatic configuration of properties defined as arrays of primitive java types (e.g. String[], long[], boolean[]).
The configuration syntax should be native (if supported) for the particular configuration file format or comma separated values string (CSVS).
Configuration syntax proposition
JSON
Native:
Code Block |
---|
arrayProperty:[val1,val2,val3]
|
CSVS:
Code Block |
---|
arrayProperty:"val1,val2,val3"
|
NOTE: CSVS is partly supported for String arrays
XML
Native:
Code Block |
---|
|
<arrayProperty>
<value>val1</value>
<value>val2</value>
<value>val3</value>
</arrayProperty>
|
CSVS:
Code Block |
---|
|
<arrayProperty>val1,val2,val3</arrayProperty>
|
Properties File
Native:
Not supported
CSVS:
Code Block |
---|
arrayProperty=val1,val2,val3
|
Examples
Code Block |
---|
title | Configurable object - DistributionConfig.java |
---|
|
@ConfigreMe(name="distribution.json")
DistributionConfig{
....
/**
* Defines distributed parts
*/
@Configure private String[] parts;
/**
* Defines distribution as calls ratio to each instance
*/
@Configure private int[] ratio;
....
}
|
Code Block |
---|
title | JSON configuration - distribution.json |
---|
|
{
ratio:["part1","part2","part3","part4"],
ratio:[1,7,3,5]
}
|