Streamline system initialization refactor
DRAFT pending #1589 , on which this PR builds.
- Tickets addressed: N/A
- Review: By commit
- Merge strategy: Merge (no squash)
Description
Refactors the initialization of streamline to an explicit call to StreamlineSystem.init. This new method is responsible for building all the singletons used by streamline, rather than putting that responsibility on the Registrar. This promotes a better separation of concerns, especially as we add more singleton-type functionality to initialize.
This also standardizes re-initialization behavior. Re-initializing an already-initialized system will simply rebuild all the singletons. While this would be wasteful if abused in production, it supports testing scenarios where multiple models may be built and re-built as tests are run.
Finally, after merging in #1589, this adds a globally-visible absolute clock, and relatedly the StreamlineSystem.currentInstant() method to get the current time as an Instant.
Verification
Existing unit tests were updated to call StreamlineSystem.init, and they continue to function properly. The streamline-demo model was also updated to call this method, and was tested manually in a local aerie deployment. It continues to function correctly as well.
Documentation
IMPORTANT: This is a breaking change! All projects that use streamline should change
var registrar = new Registrar(aerieRegistrar, errorBehavior);
into
StreamlineSystem.init(InitArgs.builder()
.baseRegistrar(aerieRegistrar)
.errorBehavior(errorBehavior)
.planStart(planStart)
.build());
var registrar = Registration.REGISTRAR;
when constructing their model. This will properly initialize the full streamline system.
Additionally, currentTime() has moved from Resources to StreamlineSystem.
Finally, while not a breaking change, this does expose StreamlineSystem.currentInstant(), which returns the current absolute time as an Instant. This is something I expect many might find useful.
Future work
N/A
Quality Gate passed
Issues
36 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code