[
https://issues.apache.org/jira/browse/LOG4J2-2803?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Work on LOG4J2-2803 started by Matt Sicker.
-------------------------------------------
> Create standardized scopes and dependency injection API
> -------------------------------------------------------
>
> Key: LOG4J2-2803
> URL: https://issues.apache.org/jira/browse/LOG4J2-2803
> Project: Log4j 2
> Issue Type: Epic
> Components: Configuration, Core, Plugins
> Reporter: Matt Sicker
> Assignee: Matt Sicker
> Priority: Major
> Fix For: 3.0.0
>
>
> In Log4j 2.x, the plugin API provides several {{@Plugin}} annotations which
> are used for performing dependency injection of configuration-scoped data
> (plugin attributes, values) and other configuration-scoped plugins (plugin
> elements). While this API works well enough for a large majority of our use
> cases, the remaining injection points include the {{Node}} and
> {{Configuration}} corresponding to the currently parsed node and
> configuration respectively which are used to perform manual lookups and other
> glue code that would be more appropriately modeled through inversion of
> control with a more complete dependency injection API.
> In Log4j 3.0, this epic introduces a new plugin system API inspired by
> [CDI|https://docs.jboss.org/cdi/api/2.0/],
> [@Inject|https://docs.oracle.com/javaee/6/api/javax/inject/Inject.html], and
> [Guice|https://github.com/google/guice] that maintains full backward
> compatibility with the annotations from 2.x so that plugins do not need to be
> needlessly rewritten for 3.x. This epic was initially developed as a result
> of work done in LOG4J2-2694.
> Beyond the dependency injection API itself, this epic is motivated by the
> following goals:
> * Simplify plugin classes that currently require manual method calls to
> {{Configuration}} or {{Node}}.
> * Unify the various ad hoc dependency injection for configuration-scoped or
> singleton-scoped classes (the latter which are overridden via system
> properties) including:
> ** {{StrSubstitutor}}
> ** {{ConfigurationScheduler}} (or scheduled tasks in general)
> ** {{ScriptManager}}
> ** {{WatchManager}}
> ** {{NanoClock}}
> ** {{ShutdownCallbackRegistry}}
> ** {{Clock}}
> ** {{ContextSelector}}
> ** {{ConfigurationFactory}}{{}}
> ** {{LogEventFactory}}
> ** {{ContextDataFactory}}
> * Make dependencies between classes more explicit via inversion of control
> which allows for easier testing and modularity.
> * Avoid the use of manual configuration handling at the API level of any
> plugins including basic string parsing (as currently supported through the
> {{TypeConverter}} API), class loading from strings, and ad hoc reflection.
> This relates to the changes made in LOG4J2-2621 and LOG4J2-1917.
> * Provide smart initialization logic to continue (or maintain) improvements
> to startup time and avoid loading plugins that aren't referenced in the
> loaded configuration.
> * Provide scopes for other ad hoc scopes/contexts used in various plugins
> such as HTTP request, HTTP session, servlet context, etc.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)