The Concern Separation Aspect Registrar (Csar /zɑːr/) provides access to some concern (usually cross-cutting) that may configured globally or locally to some section of the program. Csar acts like a global service locator that provides flexible, transparent local configuration. Like a czar
in American politics, Csar governs configuration and access to program concerns.
Quick Start
1. Include Csar Dependency
Include the appropriate Csar dependency from Maven.
2. Make a Concern
Implement Concern
to represent one of your program's concerns for Csar to register.
3. Set the Default Concern
Indicate a fallback concern using Csar.setDefaultConcerns(Concern... concerns)
to be accessible by default in any context that has no specific concern configured.
4. Csar Provides a Concern Configuration
Any code at any time may ask Csar for a concern using Csar.getConcern(Class<C> concernType)
, indicating the desired type of concern.
If you run code in the context of a specially configured concern using Csar.run(Concern concern, Runnable runnable)
, Csar.getConcern(Class<C> concernType)
will return the locally configured concern; otherwise, it will return the default, fallback concern configuration.
Learn More
You can access an in-depth introduction to Csar.