Package dev.getelements.elements.rt
Class SharedAsyncConnectionService<ContextT,SocketT>
java.lang.Object
dev.getelements.elements.rt.SharedAsyncConnectionService<ContextT,SocketT>
- Type Parameters:
ContextT
-SocketT
-
- All Implemented Interfaces:
AsyncConnectionService<ContextT,
SocketT>
public class SharedAsyncConnectionService<ContextT,SocketT>
extends Object
implements AsyncConnectionService<ContextT,SocketT>
A type of
AsyncConnectionService
which uses an internal reference count to ensure that the backed
AsyncConnectionService
is opened and closed properly.
This is mainly intended for testing as production level code should share a single global-instance of
AsyncConnectionService
-
Constructor Summary
ConstructorsConstructorDescription -
Method Summary
Modifier and TypeMethodDescriptionallocatePool
(String name, int minConnections, int maxConnections, Function<ContextT, SocketT> socketSupplier) Allocates an instance ofAsyncConnectionPool
.Returns aAsyncConnectionGroup.Builder
which can be used to build an instance ofAsyncConnectionGroup
for managing closely relatedAsyncConnection
instances.void
start()
Starts theAsyncConnectionService<ContextT,
.SocketT> void
stop()
Stops theAsyncConnectionService<ContextT,
.SocketT> Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface dev.getelements.elements.rt.AsyncConnectionService
allocatePool, group
-
Constructor Details
-
SharedAsyncConnectionService
-
-
Method Details
-
start
public void start()Description copied from interface:AsyncConnectionService
Starts theAsyncConnectionService<ContextT,
.SocketT> - Specified by:
start
in interfaceAsyncConnectionService<ContextT,
SocketT>
-
stop
public void stop()Description copied from interface:AsyncConnectionService
Stops theAsyncConnectionService<ContextT,
.SocketT> - Specified by:
stop
in interfaceAsyncConnectionService<ContextT,
SocketT>
-
group
Description copied from interface:AsyncConnectionService
Returns aAsyncConnectionGroup.Builder
which can be used to build an instance ofAsyncConnectionGroup
for managing closely relatedAsyncConnection
instances.- Specified by:
group
in interfaceAsyncConnectionService<ContextT,
SocketT> - Parameters:
name
- the name of the pool (used for logging and debugging)- Returns:
- the
AsyncConnectionGroup.Builder
-
allocatePool
public AsyncConnectionPool<ContextT,SocketT> allocatePool(String name, int minConnections, int maxConnections, Function<ContextT, SocketT> socketSupplier) Description copied from interface:AsyncConnectionService
Allocates an instance ofAsyncConnectionPool
.- Specified by:
allocatePool
in interfaceAsyncConnectionService<ContextT,
SocketT> - Parameters:
name
-minConnections
-maxConnections
-socketSupplier
-- Returns:
-