Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-2700

Add support for injecting plugin configuration via builder methods

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.0.0
    • Component/s: Plugins
    • Labels:
      None

      Description

      Prior to this feature, a plugin builder class could only have configuration values injected via fields. While all Log4j plugin builder classes typically include corresponding setFoo or withFoo methods to set values to all those fields, these methods were not used by the plugin system.

      This feature is to expand the support of using @PluginAttribute, @PluginElement, @PluginValue, @PluginNode, @PluginConfiguration, @PluginAliases, and any validation annotations on single-argument methods in a builder class. The default name extracted for these methods should be the "foo" from setFoo or withFoo if named that way, or it should use the name of the method parameter otherwise.

      As with parameters injected via a static factory method, these values should be validated by checking their types as well as validation constraints before being bound. Default values can be specified the same way as well. This allows for each setter or wither method to perform any addition programmatic validation if necessary, and it reduces coupling of implementation details to the public API of a plugin.

        Attachments

          Activity

            People

            • Assignee:
              mattsicker Matt Sicker
              Reporter:
              mattsicker Matt Sicker
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: