Top Description Fields Constructors Methods
org.jboss.logmanager.configuration

public Class ContextConfiguration

extends Object
implements AutoCloseable
Class Inheritance
All Implemented Interfaces
java.lang.AutoCloseable
Known Direct Subclasses
org.jboss.logmanager.configuration.PropertyContextConfiguration
Annotations
@SuppressWarnings:UnusedReturnValue, unused
Imports
java.util.Collections, .Map, .Objects, .Set, java.util.concurrent.ConcurrentHashMap, java.util.function.Supplier, java.util.logging.ErrorManager, .Filter, .Formatter, .Handler, org.jboss.logmanager.LogContext, .Logger

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

Modifier and TypeField and Description
private final LogContext
public static final Logger.AttachmentKey<ContextConfiguration>
private final Map<String, ConfigurationResource<ErrorManager>>
private final Map<String, ConfigurationResource<Filter>>
private final Map<String, ConfigurationResource<Formatter>>
private final Map<String, ConfigurationResource<Handler>>
private final Map<String, ConfigurationResource<Object>>

Constructor Summary

AccessConstructor and Description
public
ContextConfiguration(final LogContext context)

Creates a new context configuration.

Method Summary

Modifier and TypeMethod and Description
public ConfigurationResource<ErrorManager>

Returns:

the previous error manager associated with the name or null if one did not exist
addErrorManager
(final String
the name for the error manager
name
,
final Supplier<ErrorManager>
the error manager to add
errorManager
)

Adds an error manager to the context configuration.

public ConfigurationResource<Filter>

Returns:

the previous filter associated with the name or null if one did not exist
addFilter
(final String
the name for the filter
name
,
final Supplier<Filter>
the filter to add
filter
)

Adds a filter to the context configuration.

public ConfigurationResource<Formatter>

Returns:

the previous formatter associated with the name or null if one did not exist
addFormatter
(final String
the name for the formatter
name
,
final Supplier<Formatter>
the formatter to add
formatter
)

Adds a formatter to the context configuration.

public ConfigurationResource<Handler>

Returns:

the previous handler associated with the name or null if one did not exist
addHandler
(final String
the name for the handler
name
,
final Supplier<Handler>
the handler to add
handler
)

Adds a handler to the context configuration.

public ConfigurationResource<Object>

Returns:

the previous configuration object associated with the name or null if one did not exist
addObject
(final String
the name for the configuration object
name
,
final Supplier<Object>
the configuration object to add
object
)

Adds an object that can be used as a configuration property for another configuration type.

public void
close()

Implements java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources.

private static void
closeResources(final Map<String, ? extends ConfigurationResource<?>> resources)

public LogContext

Returns:

the context for this configuration
getContext
()

Returns the context for this configuration.

public ErrorManager

Returns:

the error manager or null if the error manager does not exist
getErrorManager
(final String
the name of the error manager
name
)

Gets the error manager if it exists.

public Map<String, ConfigurationResource<ErrorManager>>

Returns:

an unmodified map of the error managers
getErrorManagers
()

Returns an unmodifiable map of the error managers and the suppliers used to create them.

public Filter

Returns:

the filer or null if the filter does not exist
getFilter
(final String
the name of the filter
name
)

Gets the filter if it exists.

public Map<String, ConfigurationResource<Filter>>

Returns:

an unmodified map of the filters
getFilters
()

Returns an unmodifiable map of the filters and the suppliers used to create them.

public Formatter

Returns:

the formatter or null if the formatter does not exist
getFormatter
(final String
the name of the formatter
name
)

Gets the formatter if it exists.

public Map<String, Supplier<Formatter>>

Returns:

an unmodified map of the formatters
getFormatters
()

Returns an unmodifiable map of the formatters and the suppliers used to create them.

public Handler

Returns:

the handler or null if the handler does not exist
getHandler
(final String
the name of the handler
name
)

Gets the handler if it exists.

public Map<String, ConfigurationResource<Handler>>

Returns:

an unmodified map of the handlers
getHandlers
()

Returns an unmodifiable map of the handlers and the suppliers used to create them.

public Logger

Returns:

the logger or null if the logger does not exist
getLogger
(final String
the name of the logger
name
)

Gets the logger if it exists.

public Set<String>

Returns:

an unmodified set of the logger names
getLoggers
()

Returns an unmodifiable set of the configured logger names

public Object

Returns:

the configuration object or null if the configuration object does not exist
getObject
(final String
the name of the configuration object
name
)

Gets the configuration object if it exists.

public Map<String, ConfigurationResource<Object>>

Returns:

an unmodified map of the configuration objects
getObjects
()

Returns an unmodifiable map of the configuration objects and the suppliers used to create them.

public boolean

Returns:

true if the error manager exists in this context, otherwise false
hasErrorManager
(final String
the name for the error manager
name
)

Checks if the error manager exists with the name provided.

public boolean

Returns:

true if the filter exists in this context, otherwise false
hasFilter
(final String
the name for the filter
name
)

Checks if the filter exists with the name provided.

public boolean

Returns:

true if the formatter exists in this context, otherwise false
hasFormatter
(final String
the name for the formatter
name
)

Checks if the formatter exists with the name provided.

public boolean

Returns:

true if the handler exists in this context, otherwise false
hasHandler
(final String
the name for the handler
name
)

Checks if the handler exists with the name provided.

public boolean

Returns:

true if the logger exists in this context, otherwise false
hasLogger
(final String
the logger name
name
)

Checks if the logger exists in this context.

public boolean

Returns:

true if the configuration object exists in this context, otherwise false
hasObject
(final String
the name for the configuration object
name
)

Checks if the configuration object exists with the name provided.

public ConfigurationResource<ErrorManager>

Returns:

the error manager removed or null if the error manager did not exist
removeErrorManager
(final String
the name of the error manager
name
)

Removes the error manager from the context configuration.

public ConfigurationResource<Filter>

Returns:

the filter removed or null if the filter did not exist
removeFilter
(final String
the name of the filter
name
)

Removes the filter from the context configuration.

public ConfigurationResource<Formatter>

Returns:

the formatter removed or null if the formatter did not exist
removeFormatter
(final String
the name of the formatter
name
)

Removes the formatter from the context configuration.

public ConfigurationResource<Handler>

Returns:

the handler removed or null if the handler did not exist
removeHandler
(final String
the name of the handler
name
)

Removes the handler from the context configuration.

public ConfigurationResource<Object>

Returns:

the configuration object removed or null if the configuration object did not exist
removeObject
(final String
the name of the configuration object
name
)

Removes the configuration object from the context configuration.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

contextback to summary
private final LogContext context
CONTEXT_CONFIGURATION_KEYback to summary
public static final Logger.AttachmentKey<ContextConfiguration> CONTEXT_CONFIGURATION_KEY
errorManagersback to summary
private final Map<String, ConfigurationResource<ErrorManager>> errorManagers
filtersback to summary
private final Map<String, ConfigurationResource<Filter>> filters
formattersback to summary
private final Map<String, ConfigurationResource<Formatter>> formatters
handlersback to summary
private final Map<String, ConfigurationResource<Handler>> handlers
objectsback to summary
private final Map<String, ConfigurationResource<Object>> objects

Constructor Detail

ContextConfigurationback to summary
public ContextConfiguration(final LogContext context)

Creates a new context configuration.

Method Detail

addErrorManagerback to summary
public ConfigurationResource<ErrorManager> addErrorManager(final String name, final Supplier<ErrorManager> errorManager)

Adds an error manager to the context configuration.

Parameters
name:String

the name for the error manager

errorManager:Supplier<ErrorManager>

the error manager to add

Returns:ConfigurationResource<ErrorManager>

the previous error manager associated with the name or null if one did not exist

addFilterback to summary
public ConfigurationResource<Filter> addFilter(final String name, final Supplier<Filter> filter)

Adds a filter to the context configuration.

Parameters
name:String

the name for the filter

filter:Supplier<Filter>

the filter to add

Returns:ConfigurationResource<Filter>

the previous filter associated with the name or null if one did not exist

addFormatterback to summary
public ConfigurationResource<Formatter> addFormatter(final String name, final Supplier<Formatter> formatter)

Adds a formatter to the context configuration.

Parameters
name:String

the name for the formatter

formatter:Supplier<Formatter>

the formatter to add

Returns:ConfigurationResource<Formatter>

the previous formatter associated with the name or null if one did not exist

addHandlerback to summary
public ConfigurationResource<Handler> addHandler(final String name, final Supplier<Handler> handler)

Adds a handler to the context configuration.

Parameters
name:String

the name for the handler

handler:Supplier<Handler>

the handler to add

Returns:ConfigurationResource<Handler>

the previous handler associated with the name or null if one did not exist

addObjectback to summary
public ConfigurationResource<Object> addObject(final String name, final Supplier<Object> object)

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:String

the name for the configuration object

object:Supplier<Object>

the configuration object to add

Returns:ConfigurationResource<Object>

the previous configuration object associated with the name or null if one did not exist

closeback to summary
public void close() throws Exception

Implements java.lang.AutoCloseable.close.

Doc from java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources. This method is invoked automatically on objects managed by the try-with-resources statement.

Annotations
@Override
Exceptions
Exception:
if this resource cannot be closed
closeResourcesback to summary
private static void closeResources(final Map<String, ? extends ConfigurationResource<?>> resources)
getContextback to summary
public LogContext getContext()

Returns the context for this configuration.

Returns:LogContext

the context for this configuration

getErrorManagerback to summary
public ErrorManager getErrorManager(final String name)

Gets the error manager if it exists.

Parameters
name:String

the name of the error manager

Returns:ErrorManager

the error manager or null if the error manager does not exist

getErrorManagersback to summary
public Map<String, ConfigurationResource<ErrorManager>> getErrorManagers()

Returns an unmodifiable map of the error managers and the suppliers used to create them.

Returns:Map<String, ConfigurationResource<ErrorManager>>

an unmodified map of the error managers

getFilterback to summary
public Filter getFilter(final String name)

Gets the filter if it exists.

Parameters
name:String

the name of the filter

Returns:Filter

the filer or null if the filter does not exist

getFiltersback to summary
public Map<String, ConfigurationResource<Filter>> getFilters()

Returns an unmodifiable map of the filters and the suppliers used to create them.

Returns:Map<String, ConfigurationResource<Filter>>

an unmodified map of the filters

getFormatterback to summary
public Formatter getFormatter(final String name)

Gets the formatter if it exists.

Parameters
name:String

the name of the formatter

Returns:Formatter

the formatter or null if the formatter does not exist

getFormattersback to summary
public Map<String, Supplier<Formatter>> getFormatters()

Returns an unmodifiable map of the formatters and the suppliers used to create them.

Returns:Map<String, Supplier<Formatter>>

an unmodified map of the formatters

getHandlerback to summary
public Handler getHandler(final String name)

Gets the handler if it exists.

Parameters
name:String

the name of the handler

Returns:Handler

the handler or null if the handler does not exist

getHandlersback to summary
public Map<String, ConfigurationResource<Handler>> getHandlers()

Returns an unmodifiable map of the handlers and the suppliers used to create them.

Returns:Map<String, ConfigurationResource<Handler>>

an unmodified map of the handlers

getLoggerback to summary
public Logger getLogger(final String name)

Gets the logger if it exists.

Parameters
name:String

the name of the logger

Returns:Logger

the logger or null if the logger does not exist

getLoggersback to summary
public Set<String> getLoggers()

Returns an unmodifiable set of the configured logger names

Returns:Set<String>

an unmodified set of the logger names

getObjectback to summary
public Object getObject(final String name)

Gets the configuration object if it exists.

Parameters
name:String

the name of the configuration object

Returns:Object

the configuration object or null if the configuration object does not exist

getObjectsback to summary
public Map<String, ConfigurationResource<Object>> getObjects()

Returns an unmodifiable map of the configuration objects and the suppliers used to create them.

Returns:Map<String, ConfigurationResource<Object>>

an unmodified map of the configuration objects

hasErrorManagerback to summary
public boolean hasErrorManager(final String name)

Checks if the error manager exists with the name provided.

Parameters
name:String

the name for the error manager

Returns:boolean

true if the error manager exists in this context, otherwise false

hasFilterback to summary
public boolean hasFilter(final String name)

Checks if the filter exists with the name provided.

Parameters
name:String

the name for the filter

Returns:boolean

true if the filter exists in this context, otherwise false

hasFormatterback to summary
public boolean hasFormatter(final String name)

Checks if the formatter exists with the name provided.

Parameters
name:String

the name for the formatter

Returns:boolean

true if the formatter exists in this context, otherwise false

hasHandlerback to summary
public boolean hasHandler(final String name)

Checks if the handler exists with the name provided.

Parameters
name:String

the name for the handler

Returns:boolean

true if the handler exists in this context, otherwise false

hasLoggerback to summary
public boolean hasLogger(final String name)

Checks if the logger exists in this context.

Parameters
name:String

the logger name

Returns:boolean

true if the logger exists in this context, otherwise false

hasObjectback to summary
public boolean hasObject(final String name)

Checks if the configuration object exists with the name provided.

Parameters
name:String

the name for the configuration object

Returns:boolean

true if the configuration object exists in this context, otherwise false

removeErrorManagerback to summary
public ConfigurationResource<ErrorManager> removeErrorManager(final String name)

Removes the error manager from the context configuration.

Parameters
name:String

the name of the error manager

Returns:ConfigurationResource<ErrorManager>

the error manager removed or null if the error manager did not exist

removeFilterback to summary
public ConfigurationResource<Filter> removeFilter(final String name)

Removes the filter from the context configuration.

Parameters
name:String

the name of the filter

Returns:ConfigurationResource<Filter>

the filter removed or null if the filter did not exist

removeFormatterback to summary
public ConfigurationResource<Formatter> removeFormatter(final String name)

Removes the formatter from the context configuration.

Parameters
name:String

the name of the formatter

Returns:ConfigurationResource<Formatter>

the formatter removed or null if the formatter did not exist

removeHandlerback to summary
public ConfigurationResource<Handler> removeHandler(final String name)

Removes the handler from the context configuration.

Parameters
name:String

the name of the handler

Returns:ConfigurationResource<Handler>

the handler removed or null if the handler did not exist

removeObjectback to summary
public ConfigurationResource<Object> removeObject(final String name)

Removes the configuration object from the context configuration.

Parameters
name:String

the name of the configuration object

Returns:ConfigurationResource<Object>

the configuration object removed or null if the configuration object did not exist