public interface ConnectionContextService
Implementing classes may choose to use pooling to reduce memory allocation overhead, or may create new context instances on each acquire call (non-pooled). The choice of implementation affects memory usage and allocation patterns:
The Host Monitoring Plugins use a pooled connection context service by default.
PoolConnectionContextServiceImpl| Modifier and Type | Method and Description |
|---|---|
<T extends ConnectionContext> |
acquire(@NonNull java.lang.Class<T> contextClass)
Acquire a connection context.
|
<T extends ConnectionContext> |
acquire(@NonNull java.lang.Class<T> contextClass,
@Nullable java.util.function.Consumer<T> initializer)
Acquire a connection context with optional initialization.
|
boolean |
release(ConnectionContext context)
Release a connection context.
|
<T extends ConnectionContext> T acquire(@NonNull java.lang.Class<T> contextClass)
T - the type of connection contextcontextClass - the class type of the connection context to acquire<T extends ConnectionContext> T acquire(@NonNull java.lang.Class<T> contextClass, @Nullable java.util.function.Consumer<T> initializer)
T - the type of connection contextcontextClass - the class type of the connection context to acquireinitializer - optional consumer to initialize the context before use; may be nullboolean release(ConnectionContext context)
context - the context to release