Top Description Fields Constructors Methods
org.jboss.logmanager

public final Class ClassLoaderLogContextSelector

extends Object
implements LogContextSelector
Class Inheritance
All Implemented Interfaces
org.jboss.logmanager.LogContextSelector
Imports
java.security.AccessController, .Permission, .PrivilegedAction, java.util.Collections, .Set, java.util.concurrent.ConcurrentMap, java.util.function.Function

A log context selector which chooses a log context based on the caller's classloader.

Field Summary

Modifier and TypeField and Description
private final boolean
private final ConcurrentMap<ClassLoader, LogContext>
private final LogContextSelector
private static final Permission
private final Set<ClassLoader>
private final PrivilegedAction<LogContext>
private final Function<ClassLoader, LogContext>
private static final Permission
private static final Permission

Constructor Summary

AccessConstructor and Description
public
ClassLoaderLogContextSelector(final LogContextSelector
the selector to consult if no matching log context is found
defaultSelector
)

Construct a new instance.

public
ClassLoaderLogContextSelector(final LogContextSelector
the selector to consult if no matching log context is found
defaultSelector
,
final boolean
true if the log context could not found for the class loader and the parent class loader should be checked
checkParentClassLoaders
)

Construct a new instance.

public
ClassLoaderLogContextSelector()

Construct a new instance.

public
ClassLoaderLogContextSelector(final boolean
true if the log context could not found for the class loader and the parent class loader should be checked
checkParentClassLoaders
)

Construct a new instance.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if this class loader was previously unknown, or false if it was already registered
addLogApiClassLoader
(ClassLoader
the API class loader
apiClassLoader
)

Register a class loader which is a known log API, and thus should be skipped over when searching for the log context to use for the caller class.

public LogContext
getLogContext()

Implements org.jboss.logmanager.LogContextSelector.getLogContext.

Get the current log context.

public void
registerLogContext(ClassLoader
the classloader
classLoader
,
LogContext
the log context
logContext
)

Register a class loader with a log context.

public boolean

Returns:

true if the class loader was removed, or false if it was not known to this selector
removeLogApiClassLoader
(ClassLoader
the API class loader
apiClassLoader
)

Remove a class loader from the known log APIs set.

public boolean

Returns:

true if the association exists and was removed, false otherwise
unregisterLogContext
(ClassLoader
the classloader
classLoader
,
LogContext
the log context
logContext
)

Unregister a class loader/log context association.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

checkParentClassLoadersback to summary
private final boolean checkParentClassLoaders
contextMapback to summary
private final ConcurrentMap<ClassLoader, LogContext> contextMap
defaultSelectorback to summary
private final LogContextSelector defaultSelector
LOG_API_PERMISSIONback to summary
private static final Permission LOG_API_PERMISSION
logApiClassLoadersback to summary
private final Set<ClassLoader> logApiClassLoaders
logContextActionback to summary
private final PrivilegedAction<LogContext> logContextAction
logContextFinderback to summary
private final Function<ClassLoader, LogContext> logContextFinder
REGISTER_LOG_CONTEXT_PERMISSIONback to summary
private static final Permission REGISTER_LOG_CONTEXT_PERMISSION
UNREGISTER_LOG_CONTEXT_PERMISSIONback to summary
private static final Permission UNREGISTER_LOG_CONTEXT_PERMISSION

Constructor Detail

ClassLoaderLogContextSelectorback to summary
public ClassLoaderLogContextSelector(final LogContextSelector defaultSelector)

Construct a new instance. If no matching log context is found, the provided default selector is consulted.

Parameters
defaultSelector:LogContextSelector

the selector to consult if no matching log context is found

ClassLoaderLogContextSelectorback to summary
public ClassLoaderLogContextSelector(final LogContextSelector defaultSelector, final boolean checkParentClassLoaders)

Construct a new instance. If no matching log context is found, the provided default selector is consulted.

If the checkParentClassLoaders is set to true this selector recursively searches the class loader parents until a match is found or a null parent is found.

Parameters
defaultSelector:LogContextSelector

the selector to consult if no matching log context is found

checkParentClassLoaders:boolean

true if the log context could not found for the class loader and the parent class loader should be checked

ClassLoaderLogContextSelectorback to summary
public ClassLoaderLogContextSelector()

Construct a new instance. If no matching log context is found, the system context is used.

ClassLoaderLogContextSelectorback to summary
public ClassLoaderLogContextSelector(final boolean checkParentClassLoaders)

Construct a new instance. If no matching log context is found, the system context is used.

If the checkParentClassLoaders is set to true this selector recursively searches the class loader parents until a match is found or a null parent is found.

Parameters
checkParentClassLoaders:boolean

true if the log context could not found for the class loader and the parent class loader should be checked

Method Detail

addLogApiClassLoaderback to summary
public boolean addLogApiClassLoader(ClassLoader apiClassLoader)

Register a class loader which is a known log API, and thus should be skipped over when searching for the log context to use for the caller class.

Parameters
apiClassLoader:ClassLoader

the API class loader

Returns:boolean

true if this class loader was previously unknown, or false if it was already registered

getLogContextback to summary
public LogContext getLogContext()

Implements org.jboss.logmanager.LogContextSelector.getLogContext.

Doc from org.jboss.logmanager.LogContextSelector.getLogContext.

Get the current log context. This instance will consult the call stack to see if any calling classloader is associated with any log context.

Returns:LogContext

the current log context

registerLogContextback to summary
public void registerLogContext(ClassLoader classLoader, LogContext logContext) throws IllegalArgumentException

Register a class loader with a log context. This method requires the registerLogContext RuntimePermission.

Parameters
classLoader:ClassLoader

the classloader

logContext:LogContext

the log context

Exceptions
IllegalArgumentException:
if the classloader is already associated with a log context
removeLogApiClassLoaderback to summary
public boolean removeLogApiClassLoader(ClassLoader apiClassLoader)

Remove a class loader from the known log APIs set.

Parameters
apiClassLoader:ClassLoader

the API class loader

Returns:boolean

true if the class loader was removed, or false if it was not known to this selector

unregisterLogContextback to summary
public boolean unregisterLogContext(ClassLoader classLoader, LogContext logContext)

Unregister a class loader/log context association. This method requires the unregisterLogContext RuntimePermission.

Parameters
classLoader:ClassLoader

the classloader

logContext:LogContext

the log context

Returns:boolean

true if the association exists and was removed, false otherwise