Class ContextConfiguration
java.lang.Object
org.jboss.logmanager.configuration.ContextConfiguration
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
PropertyContextConfiguration
A configuration which can be stored on a log context to store information
about the configured error managers, handlers, filters, formatters and objects that might be associated with a
configured object.
The addObject(String, Supplier) can be used to allow objects to be set when configuring error managers,
handlers, filters and formatters.
If the supplier os not already an instance of a ConfigurationResource, then it is
wrapped and considered a lazy resource.
- Author:
- James R. Perkins
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionContextConfiguration(LogContext context) Creates a new context configuration. -
Method Summary
Modifier and TypeMethodDescriptionaddErrorManager(String name, Supplier<ErrorManager> errorManager) Adds an error manager to the context configuration.Adds a filter to the context configuration.addFormatter(String name, Supplier<Formatter> formatter) Adds a formatter to the context configuration.addHandler(String name, Supplier<Handler> handler) Adds a handler to the context configuration.Adds an object that can be used as a configuration property for another configuration type.voidclose()Returns the context for this configuration.getErrorManager(String name) Gets the error manager if it exists.Returns an unmodifiable map of the error managers and the suppliers used to create them.Gets the filter if it exists.Returns an unmodifiable map of the filters and the suppliers used to create them.getFormatter(String name) Gets the formatter if it exists.Returns an unmodifiable map of the formatters and the suppliers used to create them.getHandler(String name) Gets the handler if it exists.Returns an unmodifiable map of the handlers and the suppliers used to create them.Gets the logger if it exists.Returns an unmodifiable set of the configured logger namesGets the configuration object if it exists.Returns an unmodifiable map of the configuration objects and the suppliers used to create them.booleanhasErrorManager(String name) Checks if the error manager exists with the name provided.booleanChecks if the filter exists with the name provided.booleanhasFormatter(String name) Checks if the formatter exists with the name provided.booleanhasHandler(String name) Checks if the handler exists with the name provided.booleanChecks if the logger exists in this context.booleanChecks if the configuration object exists with the name provided.removeErrorManager(String name) Removes the error manager from the context configuration.removeFilter(String name) Removes the filter from the context configuration.removeFormatter(String name) Removes the formatter from the context configuration.removeHandler(String name) Removes the handler from the context configuration.removeObject(String name) Removes the configuration object from the context configuration.
-
Field Details
-
CONTEXT_CONFIGURATION_KEY
-
-
Constructor Details
-
ContextConfiguration
Creates a new context configuration.
-
-
Method Details
-
getContext
Returns the context for this configuration.- Returns:
- the context for this configuration
-
hasLogger
Checks if the logger exists in this context.- Parameters:
name- the logger name- Returns:
trueif the logger exists in this context, otherwisefalse
-
getLogger
Gets the logger if it exists.- Parameters:
name- the name of the logger- Returns:
- the logger or
nullif the logger does not exist
-
getLoggers
Returns an unmodifiable set of the configured logger names- Returns:
- an unmodified set of the logger names
-
addErrorManager
public ConfigurationResource<ErrorManager> addErrorManager(String name, Supplier<ErrorManager> errorManager) Adds an error manager to the context configuration.- Parameters:
name- the name for the error managererrorManager- the error manager to add- Returns:
- the previous error manager associated with the name or
nullif one did not exist
-
removeErrorManager
Removes the error manager from the context configuration.- Parameters:
name- the name of the error manager- Returns:
- the error manager removed or
nullif the error manager did not exist
-
hasErrorManager
Checks if the error manager exists with the name provided.- Parameters:
name- the name for the error manager- Returns:
trueif the error manager exists in this context, otherwisefalse
-
getErrorManager
Gets the error manager if it exists.- Parameters:
name- the name of the error manager- Returns:
- the error manager or
nullif the error manager does not exist
-
getErrorManagers
Returns an unmodifiable map of the error managers and the suppliers used to create them.- Returns:
- an unmodified map of the error managers
-
addHandler
Adds a handler to the context configuration.- Parameters:
name- the name for the handlerhandler- the handler to add- Returns:
- the previous handler associated with the name or
nullif one did not exist
-
removeHandler
Removes the handler from the context configuration.- Parameters:
name- the name of the handler- Returns:
- the handler removed or
nullif the handler did not exist
-
hasHandler
Checks if the handler exists with the name provided.- Parameters:
name- the name for the handler- Returns:
trueif the handler exists in this context, otherwisefalse
-
getHandler
Gets the handler if it exists.- Parameters:
name- the name of the handler- Returns:
- the handler or
nullif the handler does not exist
-
getHandlers
Returns an unmodifiable map of the handlers and the suppliers used to create them.- Returns:
- an unmodified map of the handlers
-
addFormatter
Adds a formatter to the context configuration.- Parameters:
name- the name for the formatterformatter- the formatter to add- Returns:
- the previous formatter associated with the name or
nullif one did not exist
-
removeFormatter
Removes the formatter from the context configuration.- Parameters:
name- the name of the formatter- Returns:
- the formatter removed or
nullif the formatter did not exist
-
hasFormatter
Checks if the formatter exists with the name provided.- Parameters:
name- the name for the formatter- Returns:
trueif the formatter exists in this context, otherwisefalse
-
getFormatter
Gets the formatter if it exists.- Parameters:
name- the name of the formatter- Returns:
- the formatter or
nullif the formatter does not exist
-
getFormatters
Returns an unmodifiable map of the formatters and the suppliers used to create them.- Returns:
- an unmodified map of the formatters
-
addFilter
Adds a filter to the context configuration.- Parameters:
name- the name for the filterfilter- the filter to add- Returns:
- the previous filter associated with the name or
nullif one did not exist
-
removeFilter
Removes the filter from the context configuration.- Parameters:
name- the name of the filter- Returns:
- the filter removed or
nullif the filter did not exist
-
hasFilter
Checks if the filter exists with the name provided.- Parameters:
name- the name for the filter- Returns:
trueif the filter exists in this context, otherwisefalse
-
getFilter
Gets the filter if it exists.- Parameters:
name- the name of the filter- Returns:
- the filer or
nullif the filter does not exist
-
getFilters
Returns an unmodifiable map of the filters and the suppliers used to create them.- Returns:
- an unmodified map of the filters
-
addObject
Adds an object that can be used as a configuration property for another configuration type. This is used for cases when an object cannot simply be converted from a string.- Parameters:
name- the name for the configuration objectobject- the configuration object to add- Returns:
- the previous configuration object associated with the name or
nullif one did not exist
-
removeObject
Removes the configuration object from the context configuration.- Parameters:
name- the name of the configuration object- Returns:
- the configuration object removed or
nullif the configuration object did not exist
-
hasObject
Checks if the configuration object exists with the name provided.- Parameters:
name- the name for the configuration object- Returns:
trueif the configuration object exists in this context, otherwisefalse
-
getObject
Gets the configuration object if it exists.- Parameters:
name- the name of the configuration object- Returns:
- the configuration object or
nullif the configuration object does not exist
-
getObjects
Returns an unmodifiable map of the configuration objects and the suppliers used to create them.- Returns:
- an unmodified map of the configuration objects
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-