Class PluginProcessor
- java.lang.Object
-
- javax.annotation.processing.AbstractProcessor
-
- org.apache.logging.log4j.core.config.plugins.processor.PluginProcessor
-
- All Implemented Interfaces:
javax.annotation.processing.Processor
@SupportedAnnotationTypes("org.apache.logging.log4j.core.config.plugins.Plugin") @SupportedOptions("log4j.plugin.processor.minAllowedMessageKind") public class PluginProcessor extends javax.annotation.processing.AbstractProcessorAnnotation processor for pre-scanning Log4j 2 plugins.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classPluginProcessor.PluginAliasesElementVisitorElementVisitor to scan the PluginAliases annotation.private static classPluginProcessor.PluginElementVisitorElementVisitor to scan the Plugin annotation.
-
Field Summary
Fields Modifier and Type Field Description private static javax.lang.model.element.Element[]EMPTY_ELEMENT_ARRAY(package private) static java.lang.StringMIN_ALLOWED_MESSAGE_KIND_OPTIONAnnotation processor option that controls the minimumDiagnostic.Kindof messages emitted by this processor.private javax.tools.Diagnostic.KindminAllowedMessageKindprivate static java.lang.StringPLUGIN_BUILDER_ATTRIBUTE_ANNOTATIONstatic java.lang.StringPLUGIN_CACHE_FILEThe location of the plugin cache data file.private PluginCachepluginCacheprivate java.util.List<javax.lang.model.element.Element>processedElementsprivate static java.lang.StringSUPPRESS_WARNING_PUBLIC_SETTER_STRING
-
Constructor Summary
Constructors Constructor Description PluginProcessor()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcollectPlugins(java.lang.Iterable<? extends javax.lang.model.element.Element> elements)private static java.lang.StringexpectedFieldNameInASetter(java.lang.String fieldName)Helper method to get the expected Method name in a field.javax.lang.model.SourceVersiongetSupportedSourceVersion()voidinit(javax.annotation.processing.ProcessingEnvironment processingEnv)private voidprintMessage(javax.tools.Diagnostic.Kind kind, java.lang.String message)Prints a message via theMessageronly ifkindis at least as severe as the configuredminimum allowed kind.private voidprintMessage(javax.tools.Diagnostic.Kind kind, java.lang.String message, javax.lang.model.element.Element element)Prints a message via theMessageronly ifkindis at least as severe as the configuredminimum allowed kind.booleanprocess(java.util.Set<? extends javax.lang.model.element.TypeElement> annotations, javax.annotation.processing.RoundEnvironment roundEnv)private voidprocessBuilderAttribute(java.lang.Iterable<? extends javax.lang.model.element.Element> elements)private voidprocessBuilderAttribute(javax.lang.model.element.VariableElement element)private voidwriteCacheFile(javax.lang.model.element.Element... elements)
-
-
-
Field Detail
-
EMPTY_ELEMENT_ARRAY
private static final javax.lang.model.element.Element[] EMPTY_ELEMENT_ARRAY
-
SUPPRESS_WARNING_PUBLIC_SETTER_STRING
private static final java.lang.String SUPPRESS_WARNING_PUBLIC_SETTER_STRING
- See Also:
- Constant Field Values
-
MIN_ALLOWED_MESSAGE_KIND_OPTION
static final java.lang.String MIN_ALLOWED_MESSAGE_KIND_OPTION
Annotation processor option that controls the minimumDiagnostic.Kindof messages emitted by this processor.Some build environments (e.g. Maven with
-Werror) treat compiler notes or warnings as errors. Setting this option toWARNINGorERRORsuppresses informational notes emitted during normal processing.Accepted values (case-insensitive):
NOTE,WARNING,MANDATORY_WARNING,ERROR,OTHER. Defaults toNOTE.- See Also:
- Constant Field Values
-
PLUGIN_CACHE_FILE
public static final java.lang.String PLUGIN_CACHE_FILE
The location of the plugin cache data file. This file is written to by this processor, and read from byPluginManager.- See Also:
- Constant Field Values
-
processedElements
private final java.util.List<javax.lang.model.element.Element> processedElements
-
pluginCache
private final PluginCache pluginCache
-
minAllowedMessageKind
private javax.tools.Diagnostic.Kind minAllowedMessageKind
-
PLUGIN_BUILDER_ATTRIBUTE_ANNOTATION
private static final java.lang.String PLUGIN_BUILDER_ATTRIBUTE_ANNOTATION
- See Also:
- Constant Field Values
-
-
Method Detail
-
init
public void init(javax.annotation.processing.ProcessingEnvironment processingEnv)
- Specified by:
initin interfacejavax.annotation.processing.Processor- Overrides:
initin classjavax.annotation.processing.AbstractProcessor
-
getSupportedSourceVersion
public javax.lang.model.SourceVersion getSupportedSourceVersion()
- Specified by:
getSupportedSourceVersionin interfacejavax.annotation.processing.Processor- Overrides:
getSupportedSourceVersionin classjavax.annotation.processing.AbstractProcessor
-
printMessage
private void printMessage(javax.tools.Diagnostic.Kind kind, java.lang.String message)Prints a message via theMessageronly ifkindis at least as severe as the configuredminimum allowed kind.
-
printMessage
private void printMessage(javax.tools.Diagnostic.Kind kind, java.lang.String message, javax.lang.model.element.Element element)Prints a message via theMessageronly ifkindis at least as severe as the configuredminimum allowed kind.
-
process
public boolean process(java.util.Set<? extends javax.lang.model.element.TypeElement> annotations, javax.annotation.processing.RoundEnvironment roundEnv)- Specified by:
processin interfacejavax.annotation.processing.Processor- Specified by:
processin classjavax.annotation.processing.AbstractProcessor
-
processBuilderAttribute
private void processBuilderAttribute(java.lang.Iterable<? extends javax.lang.model.element.Element> elements)
-
processBuilderAttribute
private void processBuilderAttribute(javax.lang.model.element.VariableElement element)
-
expectedFieldNameInASetter
private static java.lang.String expectedFieldNameInASetter(java.lang.String fieldName)
Helper method to get the expected Method name in a field. For example if the field name is 'isopen', then the expected setter would be 'setOpen' or 'withOpen' This method is supposed to return the capitalized 'Open', fieldName which is expected in the setter.- Parameters:
fieldName- who's setter we are checking.- Returns:
- The expected fieldName that will come after withxxxx or setxxxx
-
collectPlugins
private void collectPlugins(java.lang.Iterable<? extends javax.lang.model.element.Element> elements)
-
writeCacheFile
private void writeCacheFile(javax.lang.model.element.Element... elements) throws java.io.IOException- Throws:
java.io.IOException
-
-