Enhancement
This enhancement introduces the possibility to set up agents' configurations, such as name, interval, and type via JSON file.
So, for every annotated agent, the system shall search for an optional XML and JSON configuration, which will always have more precedence than the annotation configuration.
In other words, the XML configuration, if available, will overwrite the original annotation parameters. And the JSON configuration, if available, will overwrite either the annotation or the XML configuration parameters.
An example of a valid JSON file with two agents specified:
{
"agents": [
{
"class": "com.mycompany.agents.Agent1",
"type": "timer",
"interval": "30s"
},
{
"class": "com.mycompany.agents.Agent2",
"type": "cron",
"interval": "0 0 * * SUN"
}
]
}
Configuration source precedence (for each and every agent): annotation < XML file < JSON file
Notes:
- Both XML and JSON files are optional
- If the JSON file is found (only one file allowed), then not all annotated agents need to be present in that file
- If an annotated agent is found in the JSON file (matched by the class name), then the system shall use only configuration data from the JSON (in other words, no configuration from any other less-precedence source shall be used)
- For every agent which configuration is overwritten using JSON, the system shall log the configuration source as being "JSON"
- In case of exceptions parsing an agent via JSON, a WARNING log shall be generated, but the loading shall continue normally, considering the immediately lower-precedence configuration source (XML or annotation, as fallback)
- The code shall be designed for extensibility, given the future enhancements in the roadmap (e.g.: allowing configuration via YAML too).
Additional details
- The code shall be developed in the
issue/0004
branch.
Quality criteria
The following criteria will be observed during the Code Review:
Code coverage
- The produced code shall be secured by unit tests.
- Test coverage shall remain the same or increase.
Documentation
- All methods shall be documented with Javadoc, providing examples of usage.
- Javadoc pages shall be compilable with no errors or warnings
- README.md shall be updated if applicable