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<?>
clazz
private Configuration
configuration
private static java.lang.reflect.Field[]
EMPTY_FIELD_ARRAY
private LogEvent
event
private static Logger
LOGGER
private Node
node
private 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.Object
build()
Builds the plugin object.private void
checkForRemainingAttributes()
private static Builder<?>
createBuilder(java.lang.Class<?> clazz)
private static java.lang.String[]
extractPluginAliases(java.lang.annotation.Annotation... parmTypes)
private static java.lang.reflect.Method
findFactoryMethod(java.lang.Class<?> clazz)
PluginBuilder
forLogEvent(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 void
injectFields(Builder<?> builder)
private static java.lang.String
simpleName(java.lang.Object object)
object.getClass().getSimpleName()
returnsBuilder
, when we wantPatternLayout$Builder
.static boolean
validateFields(Builder<?> builder, java.lang.String errorPrefix)
private static java.lang.String
validateFields(Builder<?> builder, java.util.List<java.lang.reflect.Field> fields)
private void
verify()
private void
verifyNodeChildrenUsed()
PluginBuilder
withConfiguration(Configuration configuration)
Specifies the Configuration to use for constructing the plugin instance.PluginBuilder
withConfigurationNode(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.InvocationTargetException
java.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()
-
-