public class ThreadLocalRequestContextSupplier extends Object implements Supplier<RequestContext>
Supplier for RequestContext that manages an instance
per thread.
Notes:
ThreadLocalRequestContextSupplier will have separate instances of
ThreadLocal.
TransactionalExternalCaches. So bewarned.
get(), the method initThread(String) must
have been called, unless a lenient supplier is created.
initThread(String) and clearThread() are not re-entrant.
Each call to initThread(String) must be paired with a subsequent call to clearThread().
| Modifier and Type | Method and Description |
|---|---|
void |
clearThread()
Clears the thread's
RequestContext. |
RequestContext |
get() |
void |
initThread(String partitionId)
Initialises the thread's
RequestContext. |
static ThreadLocalRequestContextSupplier |
lenientSupplier(Supplier<String> partitionIdSupplier)
Returns a lenient supplier, which will break
TransactionalExternalCaches. |
static ThreadLocalRequestContextSupplier |
strictSupplier()
Returns a strict supplier.
|
public static ThreadLocalRequestContextSupplier strictSupplier()
public static ThreadLocalRequestContextSupplier lenientSupplier(Supplier<String> partitionIdSupplier)
TransactionalExternalCaches.partitionIdSupplier - the supplier of partitionId's.public RequestContext get()
get in interface Supplier<RequestContext>public void initThread(String partitionId)
RequestContext.partitionId - the identifier for the partition. Will be validated using
NameValidator.requireValidPartitionIdentifier(String).public void clearThread()
RequestContext.Copyright © 2016 Atlassian. All rights reserved.