Class PluginBuilder
- java.lang.Object
-
- org.apache.logging.log4j.core.config.plugins.util.PluginBuilder
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Class<?>clazzprivate Configurationconfigurationprivate static java.lang.reflect.Field[]EMPTY_FIELD_ARRAYprivate LogEventeventprivate static LoggerLOGGERprivate Nodenodeprivate PluginType<?>pluginType
-
Constructor Summary
Constructors Constructor Description PluginBuilder(PluginType<?> pluginType)Constructs a PluginBuilder for a given PluginType.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectbuild()Builds the plugin object.private voidcheckForRemainingAttributes()private static Builder<?>createBuilder(java.lang.Class<?> clazz)private static java.lang.String[]extractPluginAliases(java.lang.annotation.Annotation... parmTypes)private static java.lang.reflect.MethodfindFactoryMethod(java.lang.Class<?> clazz)PluginBuilderforLogEvent(LogEvent event)Specifies the LogEvent that may be used to provide extra context for string substitutions.private java.lang.Object[]generateParameters(java.lang.reflect.Method factory)private voidinjectFields(Builder<?> builder)private static java.lang.StringsimpleName(java.lang.Object object)object.getClass().getSimpleName()returnsBuilder, when we wantPatternLayout$Builder.static booleanvalidateFields(Builder<?> builder, java.lang.String errorPrefix)private static java.lang.StringvalidateFields(Builder<?> builder, java.util.List<java.lang.reflect.Field> fields)private voidverify()private voidverifyNodeChildrenUsed()PluginBuilderwithConfiguration(Configuration configuration)Specifies the Configuration to use for constructing the plugin instance.PluginBuilderwithConfigurationNode(Node node)Specifies the Node corresponding to the plugin object that will be created.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.logging.log4j.core.util.Builder
getErrorPrefix, isValid
-
-
-
-
Field Detail
-
EMPTY_FIELD_ARRAY
private static final java.lang.reflect.Field[] EMPTY_FIELD_ARRAY
-
LOGGER
private static final Logger LOGGER
-
pluginType
private final PluginType<?> pluginType
-
clazz
private final java.lang.Class<?> clazz
-
configuration
private Configuration configuration
-
node
private Node node
-
event
private LogEvent event
-
-
Constructor Detail
-
PluginBuilder
public PluginBuilder(PluginType<?> pluginType)
Constructs a PluginBuilder for a given PluginType.- Parameters:
pluginType- type of plugin to configure
-
-
Method Detail
-
withConfiguration
public PluginBuilder withConfiguration(Configuration configuration)
Specifies the Configuration to use for constructing the plugin instance.- Parameters:
configuration- the configuration to use.- Returns:
this
-
withConfigurationNode
public PluginBuilder withConfigurationNode(Node node)
Specifies the Node corresponding to the plugin object that will be created.- Parameters:
node- the plugin configuration node to use.- Returns:
this
-
forLogEvent
public PluginBuilder forLogEvent(LogEvent event)
Specifies the LogEvent that may be used to provide extra context for string substitutions.- Parameters:
event- the event to use for extra information.- Returns:
this
-
build
public java.lang.Object build()
Builds the plugin object.
-
verify
private void verify()
-
createBuilder
private static Builder<?> createBuilder(java.lang.Class<?> clazz) throws java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException
- Throws:
java.lang.reflect.InvocationTargetExceptionjava.lang.IllegalAccessException
-
injectFields
private void injectFields(Builder<?> builder) throws java.lang.IllegalAccessException
- Throws:
java.lang.IllegalAccessException
-
validateFields
private static java.lang.String validateFields(Builder<?> builder, java.util.List<java.lang.reflect.Field> fields) throws java.lang.IllegalAccessException
- Throws:
java.lang.IllegalAccessException
-
validateFields
public static boolean validateFields(Builder<?> builder, java.lang.String errorPrefix)
-
simpleName
private static java.lang.String simpleName(java.lang.Object object)
object.getClass().getSimpleName()returnsBuilder, when we wantPatternLayout$Builder.
-
findFactoryMethod
private static java.lang.reflect.Method findFactoryMethod(java.lang.Class<?> clazz)
-
generateParameters
private java.lang.Object[] generateParameters(java.lang.reflect.Method factory)
-
extractPluginAliases
private static java.lang.String[] extractPluginAliases(java.lang.annotation.Annotation... parmTypes)
-
checkForRemainingAttributes
private void checkForRemainingAttributes()
-
verifyNodeChildrenUsed
private void verifyNodeChildrenUsed()
-
-