Package org.jboss.logmanager
Class ContextClassLoaderLogContextSelector
java.lang.Object
org.jboss.logmanager.ContextClassLoaderLogContextSelector
- All Implemented Interfaces:
LogContextSelector
public final class ContextClassLoaderLogContextSelector
extends Object
implements LogContextSelector
A log context selector which chooses a log context based on the thread context classloader.
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct a new instance.ContextClassLoaderLogContextSelector
(LogContextSelector defaultSelector) Construct a new instance. -
Method Summary
Modifier and TypeMethodDescriptionGet the current log context.void
registerLogContext
(ClassLoader classLoader, LogContext logContext) Register a class loader with a log context.boolean
unregisterLogContext
(ClassLoader classLoader, LogContext logContext) Unregister a class loader/log context association.
-
Constructor Details
-
ContextClassLoaderLogContextSelector
Construct a new instance. If no matching log context is found, the provided default selector is consulted.- Parameters:
defaultSelector
- the selector to consult if no matching log context is found
-
ContextClassLoaderLogContextSelector
public ContextClassLoaderLogContextSelector()Construct a new instance. If no matching log context is found, the system context is used.
-
-
Method Details
-
getLogContext
Description copied from interface:LogContextSelector
Get the current log context.- Specified by:
getLogContext
in interfaceLogContextSelector
- Returns:
- the current log context
-
registerLogContext
public void registerLogContext(ClassLoader classLoader, LogContext logContext) throws IllegalArgumentException Register a class loader with a log context. This method requires theregisterLogContext
RuntimePermission
.- Parameters:
classLoader
- the classloaderlogContext
- the log context- Throws:
IllegalArgumentException
- if the classloader is already associated with a log context
-
unregisterLogContext
Unregister a class loader/log context association. This method requires theunregisterLogContext
RuntimePermission
.- Parameters:
classLoader
- the classloaderlogContext
- the log context- Returns:
true
if the association exists and was removed,false
otherwise
-