Package io.smallrye.context.storage.spi
Interface StorageManager
-
- All Known Implementing Classes:
DefaultStorageManager
public interface StorageManagerAllows libraries to obtain custom-generated ThreadLocal instances for their storage.
-
-
Method Summary
Modifier and Type Method Description <T extends StorageDeclaration<X>,X>
ThreadLocal<X>getThreadLocal(Class<T> storageDeclarationClass)Obtains a ThreadLocal suitable for the given registered StorageDeclaration.static StorageManagerinstance()Returns the currently registered StorageManagerstatic <T extends StorageDeclaration<X>,X>
ThreadLocal<X>threadLocal(Class<T> storageDeclarationClass)Obtains a ThreadLocal suitable for the given registered StorageDeclaration.
-
-
-
Method Detail
-
instance
static StorageManager instance()
Returns the currently registered StorageManager- Returns:
- the currently registered StorageManager
-
getThreadLocal
<T extends StorageDeclaration<X>,X> ThreadLocal<X> getThreadLocal(Class<T> storageDeclarationClass)
Obtains a ThreadLocal suitable for the given registered StorageDeclaration. The ThreadLocal may be a regular ThreadLocal, or one that this StorageManager manufactured for special dedicated storage. The returned ThreadLocal is cached and all subsequent calls to this method with the same storage declaration will always return the same ThreadLocal instance.- Type Parameters:
T- The StorageDeclaration typeX- The type of data we store in that ThreadLocal- Parameters:
storageDeclarationClass- the declaration class which defines the type of item we want to store in the required ThreadLocal- Returns:
- the ThreadLocal, memoized
-
threadLocal
static <T extends StorageDeclaration<X>,X> ThreadLocal<X> threadLocal(Class<T> storageDeclarationClass)
Obtains a ThreadLocal suitable for the given registered StorageDeclaration. The ThreadLocal may be a regular ThreadLocal, or one that this StorageManager manufactured for special dedicated storage. The returned ThreadLocal is cached and all subsequent calls to this method with the same storage declaration will always return the same ThreadLocal instance.- Type Parameters:
T- The StorageDeclaration typeX- The type of data we store in that ThreadLocal- Parameters:
storageDeclarationClass- the declaration class which defines the type of item we want to store in the required ThreadLocal- Returns:
- the ThreadLocal, memoized
-
-