Package org.jboss.logmanager
Class ContextClassLoaderLogContextSelector
- java.lang.Object
-
- org.jboss.logmanager.ContextClassLoaderLogContextSelector
-
- All Implemented Interfaces:
LogContextSelector
public final class ContextClassLoaderLogContextSelector extends java.lang.Object implements LogContextSelector
A log context selector which chooses a log context based on the thread context classloader.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.ConcurrentMap<java.lang.ClassLoader,LogContext>contextMapprivate LogContextSelectordefaultSelectorprivate java.security.PrivilegedAction<LogContext>logContextActionprivate static java.security.PermissionREGISTER_LOG_CONTEXT_PERMISSIONprivate static java.security.PermissionUNREGISTER_LOG_CONTEXT_PERMISSION
-
Constructor Summary
Constructors Constructor Description ContextClassLoaderLogContextSelector()Construct a new instance.ContextClassLoaderLogContextSelector(LogContextSelector defaultSelector)Construct a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LogContextgetLogContext()Get the current log context.voidregisterLogContext(java.lang.ClassLoader classLoader, LogContext logContext)Register a class loader with a log context.booleanunregisterLogContext(java.lang.ClassLoader classLoader, LogContext logContext)Unregister a class loader/log context association.
-
-
-
Field Detail
-
REGISTER_LOG_CONTEXT_PERMISSION
private static final java.security.Permission REGISTER_LOG_CONTEXT_PERMISSION
-
UNREGISTER_LOG_CONTEXT_PERMISSION
private static final java.security.Permission UNREGISTER_LOG_CONTEXT_PERMISSION
-
defaultSelector
private final LogContextSelector defaultSelector
-
contextMap
private final java.util.concurrent.ConcurrentMap<java.lang.ClassLoader,LogContext> contextMap
-
logContextAction
private final java.security.PrivilegedAction<LogContext> logContextAction
-
-
Constructor Detail
-
ContextClassLoaderLogContextSelector
public ContextClassLoaderLogContextSelector(LogContextSelector defaultSelector)
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 Detail
-
getLogContext
public LogContext getLogContext()
Description copied from interface:LogContextSelectorGet the current log context.- Specified by:
getLogContextin interfaceLogContextSelector- Returns:
- the current log context
-
registerLogContext
public void registerLogContext(java.lang.ClassLoader classLoader, LogContext logContext) throws java.lang.IllegalArgumentExceptionRegister a class loader with a log context. This method requires theregisterLogContextRuntimePermission.- Parameters:
classLoader- the classloaderlogContext- the log context- Throws:
java.lang.IllegalArgumentException- if the classloader is already associated with a log context
-
unregisterLogContext
public boolean unregisterLogContext(java.lang.ClassLoader classLoader, LogContext logContext)Unregister a class loader/log context association. This method requires theunregisterLogContextRuntimePermission.- Parameters:
classLoader- the classloaderlogContext- the log context- Returns:
trueif the association exists and was removed,falseotherwise
-
-