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.Builderwhich can be used to build an instance ofAsyncConnectionGroupfor managing closely relatedAsyncConnectioninstances.voidstart()Starts theAsyncConnectionService<ContextT,.SocketT> voidstop()Stops theAsyncConnectionService<ContextT,.SocketT> Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.getelements.elements.rt.AsyncConnectionService
allocatePool, group
-
Constructor Details
-
SharedAsyncConnectionService
-
-
Method Details
-
start
public void start()Description copied from interface:AsyncConnectionServiceStarts theAsyncConnectionService<ContextT,.SocketT> - Specified by:
startin interfaceAsyncConnectionService<ContextT,SocketT>
-
stop
public void stop()Description copied from interface:AsyncConnectionServiceStops theAsyncConnectionService<ContextT,.SocketT> - Specified by:
stopin interfaceAsyncConnectionService<ContextT,SocketT>
-
group
Description copied from interface:AsyncConnectionServiceReturns aAsyncConnectionGroup.Builderwhich can be used to build an instance ofAsyncConnectionGroupfor managing closely relatedAsyncConnectioninstances.- Specified by:
groupin 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:AsyncConnectionServiceAllocates an instance ofAsyncConnectionPool.- Specified by:
allocatePoolin interfaceAsyncConnectionService<ContextT,SocketT> - Parameters:
name-minConnections-maxConnections-socketSupplier-- Returns:
-