@ProviderType
public class AuditContext
extends java.lang.Object
AuditConstants
enumeration, other custom properties can be added by the entry point implementation.Modifier and Type | Class and Description |
---|---|
static class |
AuditContext.Scope
Resents an
AutoCloseable scope that removes the associated AuditContext when closed. |
Constructor and Description |
---|
AuditContext(java.util.Map<java.lang.String,java.lang.String> properties)
Creates a new
AuditContext . |
Modifier and Type | Method and Description |
---|---|
AuditContext |
copy()
Creates a copy of this AuditContext with a new and independent set of properties.
|
static java.util.Optional<AuditContext> |
current()
Returns the
AuditContext associated with the current thread, if any. |
static AuditContext |
currentOrInternal()
Returns the
AuditContext associated with the current thread, if set, or a context with
AuditConstants.KEY_ENTRY_POINT set to AuditConstants.ENTRY_POINT_INTERNAL otherwise. |
java.util.Map<java.lang.String,java.lang.String> |
getProperties()
Returns the properties associated with this context
|
static AuditContext.Scope |
openScope(AuditContext context)
Sets the provided context as the thread local instance and returns a
AuditContext.Scope that can be used for removing
it. |
java.lang.String |
toString() |
public AuditContext(java.util.Map<java.lang.String,java.lang.String> properties)
AuditContext
.properties
- The properties to be associated with this context. It must be a non null mutable map.public java.util.Map<java.lang.String,java.lang.String> getProperties()
public java.lang.String toString()
toString
in class java.lang.Object
public AuditContext copy()
public static AuditContext currentOrInternal()
AuditContext
associated with the current thread, if set, or a context with
AuditConstants.KEY_ENTRY_POINT
set to AuditConstants.ENTRY_POINT_INTERNAL
otherwise.AuditContext
public static java.util.Optional<AuditContext> current()
AuditContext
associated with the current thread, if any.AuditContext
associated with this thread or empty if none is setpublic static AuditContext.Scope openScope(AuditContext context)
AuditContext.Scope
that can be used for removing
it.
Subsequent calls to currentOrInternal()
performed on the same thread will return the
provided
AuditContext
instance until the returned AuditContext.Scope
is closed.context
- the contextAuditContext.Scope
that removes the thread local context when closed.