Class PluginBuilder
java.lang.Object
org.apache.logging.log4j.core.config.plugins.util.PluginBuilder
Builder class to instantiate and configure a Plugin object using a PluginFactory method or PluginBuilderFactory
builder class.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Class<?>
private Configuration
private static final Field[]
private LogEvent
private static final Logger
private Node
private final PluginType<?>
-
Constructor Summary
ConstructorsConstructorDescriptionPluginBuilder
(PluginType<?> pluginType) Constructs a PluginBuilder for a given PluginType. -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds the plugin object.private void
private static Builder<?>
createBuilder
(Class<?> clazz) private static String[]
extractPluginAliases
(Annotation... parmTypes) private static Method
findFactoryMethod
(Class<?> clazz) forLogEvent
(LogEvent event) Specifies the LogEvent that may be used to provide extra context for string substitutions.private Object[]
generateParameters
(Method factory) private void
injectFields
(Builder<?> builder) private static String
simpleName
(Object object) object.getClass().getSimpleName()
returnsBuilder
, when we wantPatternLayout$Builder
.static boolean
validateFields
(Builder<?> builder, String errorPrefix) private static String
validateFields
(Builder<?> builder, List<Field> fields) private void
verify()
private void
withConfiguration
(Configuration configuration) Specifies the Configuration to use for constructing the plugin instance.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 Details
-
EMPTY_FIELD_ARRAY
-
LOGGER
-
pluginType
-
clazz
-
configuration
-
node
-
event
-
-
Constructor Details
-
PluginBuilder
Constructs a PluginBuilder for a given PluginType.- Parameters:
pluginType
- type of plugin to configure
-
-
Method Details
-
withConfiguration
Specifies the Configuration to use for constructing the plugin instance.- Parameters:
configuration
- the configuration to use.- Returns:
this
-
withConfigurationNode
Specifies the Node corresponding to the plugin object that will be created.- Parameters:
node
- the plugin configuration node to use.- Returns:
this
-
forLogEvent
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
Builds the plugin object. -
verify
private void verify() -
createBuilder
private static Builder<?> createBuilder(Class<?> clazz) throws InvocationTargetException, IllegalAccessException -
injectFields
- Throws:
IllegalAccessException
-
validateFields
private static String validateFields(Builder<?> builder, List<Field> fields) throws IllegalAccessException - Throws:
IllegalAccessException
-
validateFields
-
simpleName
object.getClass().getSimpleName()
returnsBuilder
, when we wantPatternLayout$Builder
. -
findFactoryMethod
-
generateParameters
-
extractPluginAliases
-
checkForRemainingAttributes
private void checkForRemainingAttributes() -
verifyNodeChildrenUsed
private void verifyNodeChildrenUsed()
-