T
- The BuiltConfiguration type.public class DefaultConfigurationBuilder<T extends BuiltConfiguration> extends java.lang.Object implements ConfigurationBuilder<T>
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
advertiser |
private Component |
appenders |
private java.lang.Class<T> |
clazz |
private Component |
customLevels |
private java.lang.String |
destination |
private static java.lang.String |
EOL |
private Component |
filters |
private static java.lang.String |
INDENT |
private Level |
level |
private LoggerContext |
loggerContext |
private Component |
loggers |
private int |
monitorInterval |
private java.lang.String |
name |
private java.lang.String |
packages |
private Component |
properties |
private Component |
root |
private Component |
scripts |
private java.lang.String |
shutdownFlag |
private long |
shutdownTimeoutMillis |
private ConfigurationSource |
source |
private java.lang.String |
verbosity |
Constructor and Description |
---|
DefaultConfigurationBuilder() |
DefaultConfigurationBuilder(java.lang.Class<T> clazz) |
Modifier and Type | Method and Description |
---|---|
ConfigurationBuilder<T> |
add(AppenderComponentBuilder builder)
Adds an AppenderComponent.
|
protected ConfigurationBuilder<T> |
add(Component parent,
ComponentBuilder<?> builder) |
ConfigurationBuilder<T> |
add(CustomLevelComponentBuilder builder)
Adds a CustomLevel component.
|
ConfigurationBuilder<T> |
add(FilterComponentBuilder builder)
Adds a Filter component.
|
ConfigurationBuilder<T> |
add(LoggerComponentBuilder builder)
Adds a Logger component.
|
ConfigurationBuilder<T> |
add(RootLoggerComponentBuilder builder)
Adds the root Logger component.
|
ConfigurationBuilder<T> |
add(ScriptComponentBuilder builder)
Adds a ScriptComponent.
|
ConfigurationBuilder<T> |
add(ScriptFileComponentBuilder builder)
Adds a ScriptFileComponent.
|
ConfigurationBuilder<T> |
addProperty(java.lang.String key,
java.lang.String value)
Adds a Property key and value.
|
ConfigurationBuilder<T> |
addRootProperty(java.lang.String key,
java.lang.String value)
Add the properties for the root node.
|
T |
build()
Builds the object after all configuration has been set.
|
T |
build(boolean initialize)
Build the configuration and optionally initialize it.
|
AppenderComponentBuilder |
newAppender(java.lang.String name,
java.lang.String type)
Returns a builder for creating Appenders.
|
AppenderRefComponentBuilder |
newAppenderRef(java.lang.String ref)
Returns a builder for creating AppenderRefs.
|
LoggerComponentBuilder |
newAsyncLogger(java.lang.String name,
Level level)
Returns a builder for creating Async Loggers.
|
LoggerComponentBuilder |
newAsyncLogger(java.lang.String name,
Level level,
boolean includeLocation)
Returns a builder for creating Async Loggers.
|
LoggerComponentBuilder |
newAsyncLogger(java.lang.String name,
java.lang.String level)
Returns a builder for creating Async Loggers.
|
LoggerComponentBuilder |
newAsyncLogger(java.lang.String name,
java.lang.String level,
boolean includeLocation)
Returns a builder for creating Async Loggers.
|
RootLoggerComponentBuilder |
newAsyncRootLogger(Level level)
Returns a builder for creating the async root Logger.
|
RootLoggerComponentBuilder |
newAsyncRootLogger(Level level,
boolean includeLocation)
Returns a builder for creating the async root Logger.
|
RootLoggerComponentBuilder |
newAsyncRootLogger(java.lang.String level)
Returns a builder for creating the async root Logger.
|
RootLoggerComponentBuilder |
newAsyncRootLogger(java.lang.String level,
boolean includeLocation)
Returns a builder for creating the async root Logger.
|
<B extends ComponentBuilder<B>> |
newComponent(java.lang.String type)
Returns a builder for creating generic components.
|
<B extends ComponentBuilder<B>> |
newComponent(java.lang.String name,
java.lang.String type)
Returns a builder for creating generic components.
|
<B extends ComponentBuilder<B>> |
newComponent(java.lang.String name,
java.lang.String type,
java.lang.String value)
Returns a builder for creating generic components.
|
CustomLevelComponentBuilder |
newCustomLevel(java.lang.String name,
int level)
Returns a builder for creating CustomLevels
|
FilterComponentBuilder |
newFilter(java.lang.String type,
Filter.Result onMatch,
Filter.Result onMisMatch)
Returns a builder for creating Filters.
|
FilterComponentBuilder |
newFilter(java.lang.String type,
java.lang.String onMatch,
java.lang.String onMisMatch)
Returns a builder for creating Filters.
|
LayoutComponentBuilder |
newLayout(java.lang.String type)
Returns a builder for creating Layouts.
|
LoggerComponentBuilder |
newLogger(java.lang.String name,
Level level)
Returns a builder for creating Loggers.
|
LoggerComponentBuilder |
newLogger(java.lang.String name,
Level level,
boolean includeLocation)
Returns a builder for creating Loggers.
|
LoggerComponentBuilder |
newLogger(java.lang.String name,
java.lang.String level)
Returns a builder for creating Loggers.
|
LoggerComponentBuilder |
newLogger(java.lang.String name,
java.lang.String level,
boolean includeLocation)
Returns a builder for creating Loggers.
|
RootLoggerComponentBuilder |
newRootLogger(Level level)
Returns a builder for creating the root Logger.
|
RootLoggerComponentBuilder |
newRootLogger(Level level,
boolean includeLocation)
Returns a builder for creating the root Logger.
|
RootLoggerComponentBuilder |
newRootLogger(java.lang.String level)
Returns a builder for creating the root Logger.
|
RootLoggerComponentBuilder |
newRootLogger(java.lang.String level,
boolean includeLocation)
Returns a builder for creating the root Logger.
|
ScriptComponentBuilder |
newScript(java.lang.String name,
java.lang.String language,
java.lang.String text)
Returns a builder for creating Async Loggers.
|
ScriptFileComponentBuilder |
newScriptFile(java.lang.String path)
Returns a builder for creating Async Loggers.
|
ScriptFileComponentBuilder |
newScriptFile(java.lang.String name,
java.lang.String path)
Returns a builder for creating Async Loggers.
|
ConfigurationBuilder<T> |
setAdvertiser(java.lang.String advertiser)
Set the Advertiser Plugin name.
|
ConfigurationBuilder<T> |
setConfigurationName(java.lang.String name)
Set the name of the configuration.
|
ConfigurationBuilder<T> |
setConfigurationSource(ConfigurationSource configurationSource)
Set the ConfigurationSource.
|
ConfigurationBuilder<T> |
setDestination(java.lang.String destination)
Specifies the destination for StatusLogger events.
|
void |
setLoggerContext(LoggerContext loggerContext)
Sets the logger context.
|
ConfigurationBuilder<T> |
setMonitorInterval(java.lang.String intervalSeconds)
Sets the interval at which the configuration file should be checked for changes.
|
ConfigurationBuilder<T> |
setPackages(java.lang.String packages)
Sets the list of packages to search for plugins.
|
ConfigurationBuilder<T> |
setShutdownHook(java.lang.String flag)
Sets whether the shutdown hook should be disabled.
|
ConfigurationBuilder<T> |
setShutdownTimeout(long timeout,
java.util.concurrent.TimeUnit timeUnit)
How long appenders and background tasks will get to shutdown when the JVM shuts down.
|
ConfigurationBuilder<T> |
setStatusLevel(Level level)
Sets the level of the StatusLogger.
|
ConfigurationBuilder<T> |
setVerbosity(java.lang.String verbosity)
Sets whether the logging should include constructing Plugins.
|
java.lang.String |
toXmlConfiguration()
Constructs an XML configuration from this builder.
|
private void |
writeXmlAttributes(javax.xml.stream.XMLStreamWriter xmlWriter,
Component component) |
private void |
writeXmlComponent(javax.xml.stream.XMLStreamWriter xmlWriter,
Component component,
int nesting) |
void |
writeXmlConfiguration(java.io.OutputStream output)
Constructs an XML configuration from this builder.
|
private void |
writeXmlConfiguration(javax.xml.stream.XMLStreamWriter xmlWriter) |
private void |
writeXmlIndent(javax.xml.stream.XMLStreamWriter xmlWriter,
int nesting) |
private void |
writeXmlSection(javax.xml.stream.XMLStreamWriter xmlWriter,
Component component) |
private static final java.lang.String INDENT
private static final java.lang.String EOL
private final Component root
private Component loggers
private Component appenders
private Component filters
private Component properties
private Component customLevels
private Component scripts
private final java.lang.Class<T extends BuiltConfiguration> clazz
private ConfigurationSource source
private int monitorInterval
private Level level
private java.lang.String verbosity
private java.lang.String destination
private java.lang.String packages
private java.lang.String shutdownFlag
private long shutdownTimeoutMillis
private java.lang.String advertiser
private LoggerContext loggerContext
private java.lang.String name
public DefaultConfigurationBuilder()
public DefaultConfigurationBuilder(java.lang.Class<T> clazz)
protected ConfigurationBuilder<T> add(Component parent, ComponentBuilder<?> builder)
public ConfigurationBuilder<T> add(AppenderComponentBuilder builder)
ConfigurationBuilder
add
in interface ConfigurationBuilder<T extends BuiltConfiguration>
builder
- The AppenderComponentBuilder with all of its attributes and sub components set.public ConfigurationBuilder<T> add(CustomLevelComponentBuilder builder)
ConfigurationBuilder
add
in interface ConfigurationBuilder<T extends BuiltConfiguration>
builder
- The CustomLevelComponentBuilder with all of its attributes set.public ConfigurationBuilder<T> add(FilterComponentBuilder builder)
ConfigurationBuilder
add
in interface ConfigurationBuilder<T extends BuiltConfiguration>
builder
- the FilterComponentBuilder with all of its attributes and sub components set.public ConfigurationBuilder<T> add(ScriptComponentBuilder builder)
ConfigurationBuilder
add
in interface ConfigurationBuilder<T extends BuiltConfiguration>
builder
- The ScriptComponentBuilder with all of its attributes and sub components set.public ConfigurationBuilder<T> add(ScriptFileComponentBuilder builder)
ConfigurationBuilder
add
in interface ConfigurationBuilder<T extends BuiltConfiguration>
builder
- The ScriptFileComponentBuilder with all of its attributes and sub components set.public ConfigurationBuilder<T> add(LoggerComponentBuilder builder)
ConfigurationBuilder
add
in interface ConfigurationBuilder<T extends BuiltConfiguration>
builder
- The LoggerComponentBuilder with all of its attributes and sub components set.public ConfigurationBuilder<T> add(RootLoggerComponentBuilder builder)
ConfigurationBuilder
add
in interface ConfigurationBuilder<T extends BuiltConfiguration>
builder
- The RootLoggerComponentBuilder with all of its attributes and sub components set.public ConfigurationBuilder<T> addProperty(java.lang.String key, java.lang.String value)
ConfigurationBuilder
addProperty
in interface ConfigurationBuilder<T extends BuiltConfiguration>
key
- The property key.value
- The property value.public T build()
Builder
build
in interface Builder<T extends BuiltConfiguration>
public T build(boolean initialize)
ConfigurationBuilder
build
in interface ConfigurationBuilder<T extends BuiltConfiguration>
initialize
- true if the configuration should be initialized, false otherwise. Generally, Configurations
should not be initialized when they are constructed.public void writeXmlConfiguration(java.io.OutputStream output) throws java.io.IOException
ConfigurationBuilder
writeXmlConfiguration
in interface ConfigurationBuilder<T extends BuiltConfiguration>
output
- OutputStream to write to, will not be closedjava.io.IOException
public java.lang.String toXmlConfiguration()
ConfigurationBuilder
toXmlConfiguration
in interface ConfigurationBuilder<T extends BuiltConfiguration>
private void writeXmlConfiguration(javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
private void writeXmlSection(javax.xml.stream.XMLStreamWriter xmlWriter, Component component) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
private void writeXmlComponent(javax.xml.stream.XMLStreamWriter xmlWriter, Component component, int nesting) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
private void writeXmlIndent(javax.xml.stream.XMLStreamWriter xmlWriter, int nesting) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
private void writeXmlAttributes(javax.xml.stream.XMLStreamWriter xmlWriter, Component component) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public ScriptComponentBuilder newScript(java.lang.String name, java.lang.String language, java.lang.String text)
ConfigurationBuilder
newScript
in interface ConfigurationBuilder<T extends BuiltConfiguration>
name
- The name of the Logger.language
- The script languagetext
- The script to execute.public ScriptFileComponentBuilder newScriptFile(java.lang.String path)
ConfigurationBuilder
newScriptFile
in interface ConfigurationBuilder<T extends BuiltConfiguration>
path
- The location of the script file.public ScriptFileComponentBuilder newScriptFile(java.lang.String name, java.lang.String path)
ConfigurationBuilder
newScriptFile
in interface ConfigurationBuilder<T extends BuiltConfiguration>
name
- The name of the script file.path
- The location of the script file.public AppenderComponentBuilder newAppender(java.lang.String name, java.lang.String type)
ConfigurationBuilder
newAppender
in interface ConfigurationBuilder<T extends BuiltConfiguration>
name
- The name of the Appender.type
- The Plugin type of the Appender.public AppenderRefComponentBuilder newAppenderRef(java.lang.String ref)
ConfigurationBuilder
newAppenderRef
in interface ConfigurationBuilder<T extends BuiltConfiguration>
ref
- The name of the Appender being referenced.public LoggerComponentBuilder newAsyncLogger(java.lang.String name, Level level)
ConfigurationBuilder
newAsyncLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
name
- The name of the Logger.level
- The logging Level to be assigned to the Logger.public LoggerComponentBuilder newAsyncLogger(java.lang.String name, Level level, boolean includeLocation)
ConfigurationBuilder
newAsyncLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
name
- The name of the Logger.level
- The logging Level to be assigned to the Logger.includeLocation
- If true include location information.public LoggerComponentBuilder newAsyncLogger(java.lang.String name, java.lang.String level)
ConfigurationBuilder
newAsyncLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
name
- The name of the Logger.level
- The logging Level to be assigned to the Logger.public LoggerComponentBuilder newAsyncLogger(java.lang.String name, java.lang.String level, boolean includeLocation)
ConfigurationBuilder
newAsyncLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
name
- The name of the Logger.level
- The logging Level to be assigned to the Logger.includeLocation
- If true include location information.public RootLoggerComponentBuilder newAsyncRootLogger(Level level)
ConfigurationBuilder
newAsyncRootLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
level
- The logging Level to be assigned to the root Logger.public RootLoggerComponentBuilder newAsyncRootLogger(Level level, boolean includeLocation)
ConfigurationBuilder
newAsyncRootLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
level
- The logging Level to be assigned to the root Logger.includeLocation
- If true include location information.public RootLoggerComponentBuilder newAsyncRootLogger(java.lang.String level)
ConfigurationBuilder
newAsyncRootLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
level
- The logging Level to be assigned to the root Logger.public RootLoggerComponentBuilder newAsyncRootLogger(java.lang.String level, boolean includeLocation)
ConfigurationBuilder
newAsyncRootLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
level
- The logging Level to be assigned to the root Logger.includeLocation
- If true include location information.public <B extends ComponentBuilder<B>> ComponentBuilder<B> newComponent(java.lang.String type)
ConfigurationBuilder
newComponent
in interface ConfigurationBuilder<T extends BuiltConfiguration>
B
- ComponentBuilder target typetype
- The Plugin type of the component.public <B extends ComponentBuilder<B>> ComponentBuilder<B> newComponent(java.lang.String name, java.lang.String type)
ConfigurationBuilder
newComponent
in interface ConfigurationBuilder<T extends BuiltConfiguration>
B
- ComponentBuilder target typename
- The name of the component (may be null).type
- The Plugin type of the component.public <B extends ComponentBuilder<B>> ComponentBuilder<B> newComponent(java.lang.String name, java.lang.String type, java.lang.String value)
ConfigurationBuilder
newComponent
in interface ConfigurationBuilder<T extends BuiltConfiguration>
B
- ComponentBuilder target typename
- The name of the component (may be null).type
- The Plugin type of the component.value
- The value of the component.public CustomLevelComponentBuilder newCustomLevel(java.lang.String name, int level)
ConfigurationBuilder
newCustomLevel
in interface ConfigurationBuilder<T extends BuiltConfiguration>
name
- The name of the custom level.level
- The integer value to be assigned to the level.public FilterComponentBuilder newFilter(java.lang.String type, Filter.Result onMatch, Filter.Result onMisMatch)
ConfigurationBuilder
newFilter
in interface ConfigurationBuilder<T extends BuiltConfiguration>
type
- The Plugin type of the Filter.onMatch
- "ACCEPT", "DENY", or "NEUTRAL"onMisMatch
- "ACCEPT", "DENY", or "NEUTRAL"public FilterComponentBuilder newFilter(java.lang.String type, java.lang.String onMatch, java.lang.String onMisMatch)
ConfigurationBuilder
newFilter
in interface ConfigurationBuilder<T extends BuiltConfiguration>
type
- The Plugin type of the Filter.onMatch
- "ACCEPT", "DENY", or "NEUTRAL"onMisMatch
- "ACCEPT", "DENY", or "NEUTRAL"public LayoutComponentBuilder newLayout(java.lang.String type)
ConfigurationBuilder
newLayout
in interface ConfigurationBuilder<T extends BuiltConfiguration>
type
- The Plugin type of the Layout.public LoggerComponentBuilder newLogger(java.lang.String name, Level level)
ConfigurationBuilder
newLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
name
- The name of the Logger.level
- The logging Level to be assigned to the Logger.public LoggerComponentBuilder newLogger(java.lang.String name, Level level, boolean includeLocation)
ConfigurationBuilder
newLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
name
- The name of the Logger.level
- The logging Level to be assigned to the Logger.includeLocation
- If true include location information.public LoggerComponentBuilder newLogger(java.lang.String name, java.lang.String level)
ConfigurationBuilder
newLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
name
- The name of the Logger.level
- The logging Level to be assigned to the Logger.public LoggerComponentBuilder newLogger(java.lang.String name, java.lang.String level, boolean includeLocation)
ConfigurationBuilder
newLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
name
- The name of the Logger.level
- The logging Level to be assigned to the Logger.includeLocation
- If true include location information.public RootLoggerComponentBuilder newRootLogger(Level level)
ConfigurationBuilder
newRootLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
level
- The logging Level to be assigned to the root Logger.public RootLoggerComponentBuilder newRootLogger(Level level, boolean includeLocation)
ConfigurationBuilder
newRootLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
level
- The logging Level to be assigned to the root Logger.includeLocation
- If true include location information.public RootLoggerComponentBuilder newRootLogger(java.lang.String level)
ConfigurationBuilder
newRootLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
level
- The logging Level to be assigned to the root Logger.public RootLoggerComponentBuilder newRootLogger(java.lang.String level, boolean includeLocation)
ConfigurationBuilder
newRootLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
level
- The logging Level to be assigned to the root Logger.public ConfigurationBuilder<T> setAdvertiser(java.lang.String advertiser)
ConfigurationBuilder
setAdvertiser
in interface ConfigurationBuilder<T extends BuiltConfiguration>
advertiser
- The Advertiser Plugin name.public ConfigurationBuilder<T> setConfigurationName(java.lang.String name)
setConfigurationName
in interface ConfigurationBuilder<T extends BuiltConfiguration>
name
- the name of the Configuration
. By default is "Assembled"
.public ConfigurationBuilder<T> setConfigurationSource(ConfigurationSource configurationSource)
setConfigurationSource
in interface ConfigurationBuilder<T extends BuiltConfiguration>
configurationSource
- the ConfigurationSource
public ConfigurationBuilder<T> setMonitorInterval(java.lang.String intervalSeconds)
ConfigurationBuilder
setMonitorInterval
in interface ConfigurationBuilder<T extends BuiltConfiguration>
intervalSeconds
- The number of seconds that should pass between checks of the configuration file.public ConfigurationBuilder<T> setPackages(java.lang.String packages)
ConfigurationBuilder
setPackages
in interface ConfigurationBuilder<T extends BuiltConfiguration>
packages
- The comma separated list of packages.public ConfigurationBuilder<T> setShutdownHook(java.lang.String flag)
ConfigurationBuilder
setShutdownHook
in interface ConfigurationBuilder<T extends BuiltConfiguration>
flag
- "disable" will prevent the shutdown hook from being set.public ConfigurationBuilder<T> setShutdownTimeout(long timeout, java.util.concurrent.TimeUnit timeUnit)
ConfigurationBuilder
ConfigurationBuilder.setShutdownHook(String)
is set to "disable".)setShutdownTimeout
in interface ConfigurationBuilder<T extends BuiltConfiguration>
LoggerContext.stop(long, TimeUnit)
public ConfigurationBuilder<T> setStatusLevel(Level level)
ConfigurationBuilder
setStatusLevel
in interface ConfigurationBuilder<T extends BuiltConfiguration>
level
- The logging level.public ConfigurationBuilder<T> setVerbosity(java.lang.String verbosity)
ConfigurationBuilder
setVerbosity
in interface ConfigurationBuilder<T extends BuiltConfiguration>
verbosity
- "disable" will hide messages from plugin construction.public ConfigurationBuilder<T> setDestination(java.lang.String destination)
ConfigurationBuilder
out
(default) for using
standard out
, err
for using standard error
, or a file URI to
which log events will be written. If the provided URI is invalid, then the default destination of standard
out will be used.setDestination
in interface ConfigurationBuilder<T extends BuiltConfiguration>
destination
- where status log messages should be output.public void setLoggerContext(LoggerContext loggerContext)
ConfigurationBuilder
setLoggerContext
in interface ConfigurationBuilder<T extends BuiltConfiguration>
loggerContext
- the logger context.public ConfigurationBuilder<T> addRootProperty(java.lang.String key, java.lang.String value)
ConfigurationBuilder
addRootProperty
in interface ConfigurationBuilder<T extends BuiltConfiguration>
key
- The property key.value
- The property value.