public class PoolConnectionContextServiceImpl extends java.lang.Object implements ConnectionContextService
| Modifier and Type | Field and Description |
|---|---|
protected static java.util.Map<java.lang.Class<? extends ConnectionContext>,ContextPool> |
contextPoolMap |
protected static boolean |
DEFAULT_LAZY_INITIALIZATION |
protected static int |
DEFAULT_MAX_IDLE_COUNT |
protected static java.util.Map<java.lang.Class<? extends ConnectionContext>,java.util.function.Supplier<ConnectionContext>> |
defaultSuppliers |
protected static java.lang.String |
LAZY_INIT_PROPERTY |
protected boolean |
lazyInitialization |
protected static java.lang.String |
MAX_IDLE_COUNT_PROPERTY |
protected int |
maxIdleCount |
| Constructor and Description |
|---|
PoolConnectionContextServiceImpl() |
| Modifier and Type | Method and Description |
|---|---|
<T extends ConnectionContext> |
acquire(java.lang.Class<T> contextClass)
Acquire a connection context.
|
<T extends ConnectionContext> |
acquire(java.lang.Class<T> contextClass,
@Nullable java.util.function.Consumer<T> initializer)
Acquire a connection context with optional initialization.
|
static void |
clear() |
boolean |
release(ConnectionContext context)
Release a connection context.
|
protected static final java.util.Map<java.lang.Class<? extends ConnectionContext>,java.util.function.Supplier<ConnectionContext>> defaultSuppliers
protected static final int DEFAULT_MAX_IDLE_COUNT
protected static final boolean DEFAULT_LAZY_INITIALIZATION
protected static final java.lang.String MAX_IDLE_COUNT_PROPERTY
protected static final java.lang.String LAZY_INIT_PROPERTY
protected static final java.util.Map<java.lang.Class<? extends ConnectionContext>,ContextPool> contextPoolMap
protected final int maxIdleCount
protected final boolean lazyInitialization
public <T extends ConnectionContext> T acquire(@NotNull java.lang.Class<T> contextClass)
ConnectionContextServiceacquire in interface ConnectionContextServiceT - the type of connection contextcontextClass - the class type of the connection context to acquirepublic <T extends ConnectionContext> T acquire(@NotNull java.lang.Class<T> contextClass, @Nullable java.util.function.Consumer<T> initializer)
ConnectionContextServiceacquire in interface ConnectionContextServiceT - the type of connection contextcontextClass - the class type of the connection context to acquireinitializer - optional consumer to initialize the context before use; may be nullpublic boolean release(ConnectionContext context)
ConnectionContextServicerelease in interface ConnectionContextServicecontext - the context to releasepublic static void clear()