Details
-
New Feature
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
Description
In the 2.x plugin API, we do not have a generic dependency injection mechanism. We do have a similar system in Configuration for injection configuration data into Core plugins. There are other attempts at user configuration injection into other classes through system properties as well.
In the 3.0 API, a more generic and unified dependency injection API should be provided. This should be analogous to how the standard javax.inject API works. This should include a way to specify how a class can be instantiated through either @Inject on the constructor or @Produces on a method. The produces version should replace the existing methods of binding configuration data to the @Plugin(Builder)Factory annotations. Combined with scopes (LOG4J2-2852) and qualifiers (LOG4J2-2853), this will allow for a lot of code in log4j-core to be refactored to remove boilerplate code related to object construction and lifecycle management.