public class Log4jCorrelationService extends Object implements CorrelationService
| Modifier and Type | Field and Description |
|---|---|
static String |
MDC_CORRELATION_CONTEXT_KEY |
PROTOCOL_HEADER| Constructor and Description |
|---|
Log4jCorrelationService() |
| Modifier and Type | Method and Description |
|---|---|
void |
attachContext(CorrelationContext context)
Sets the current attached correlation context.
|
CorrelationContext |
attachExternalizedContext(byte[] externalizedContext)
Attaches the externalized correlation context
|
CorrelationContext |
createContext()
Creates a new correlation context.
|
CorrelationContext |
detachContext()
Detaches the existing attached context if any.
|
byte[] |
detachExternalizedContext()
Detaches the existing attached correlation context and returns it in externalized form.
|
<T> T |
execute(CorrelationContext context,
Callable<T> callable)
Executes the callable within the provided correlation context.
|
CorrelationContext |
getContext()
Returns the current attached correlation context if any.
|
byte[] |
getExternalizedContext()
Returns externalized correlation context without detaching it from execution scope.
|
CorrelationContext |
readExternalizedContext(byte[] externalizedContext)
Restores correlation context from externalized form.
|
public static final String MDC_CORRELATION_CONTEXT_KEY
public CorrelationContext createContext()
CorrelationServicecreateContext in interface CorrelationServicepublic CorrelationContext getContext()
CorrelationServicegetContext in interface CorrelationServicepublic void attachContext(CorrelationContext context)
CorrelationServiceattachContext in interface CorrelationServicecontext - The correlation context to attach.public CorrelationContext detachContext()
CorrelationServicedetachContext in interface CorrelationServicepublic <T> T execute(CorrelationContext context, Callable<T> callable) throws Exception
CorrelationServiceexecute in interface CorrelationServiceT - Type of callablecontext - The correlation context to establish around the invocation of the callable. May not be null.callable - The callable to invoke after establishing the correlation context. May not be null.Exception - Thrown if thrown by the callable's call method.public CorrelationContext attachExternalizedContext(byte[] externalizedContext)
CorrelationServiceattachExternalizedContext in interface CorrelationServiceexternalizedContext - The externalized correlation contextpublic byte[] detachExternalizedContext()
CorrelationServicedetachExternalizedContext in interface CorrelationServicepublic CorrelationContext readExternalizedContext(byte[] externalizedContext)
CorrelationServicereadExternalizedContext in interface CorrelationServiceexternalizedContext - The externalized correlation context. May not be null.public byte[] getExternalizedContext()
CorrelationServicegetExternalizedContext in interface CorrelationServiceCopyright © 2022 The Apache Software Foundation. All rights reserved.