ResolvedAddress - The type of a resolved address that can be used for connecting.C - The type of connections created by this factory.public final class LimitingConnectionFactoryFilter<ResolvedAddress,C extends ListenableAsyncCloseable> extends java.lang.Object implements ConnectionFactoryFilter<ResolvedAddress,C>
ConnectionFactory that limits the total number of active connections created using this
ConnectionFactory. A connection is considered active if ListenableAsyncCloseable.onClose() has
not yet terminated.| Modifier and Type | Class and Description |
|---|---|
static interface |
LimitingConnectionFactoryFilter.ConnectionLimiter<ResolvedAddress,C extends ListenableAsyncCloseable>
A contract to limit number of connections created by
LimitingConnectionFactoryFilter. |
| Modifier and Type | Method and Description |
|---|---|
ConnectionFactory<ResolvedAddress,C> |
create(ConnectionFactory<ResolvedAddress,C> original)
Decorates the passed
original ConnectionFactory to add the filtering logic. |
static <A,C extends ListenableAsyncCloseable> |
with(LimitingConnectionFactoryFilter.ConnectionLimiter<A,C> limiter)
Create a new
ConnectionFactory that limits the created connections using the passed
LimitingConnectionFactoryFilter.ConnectionLimiter. |
static <A,C extends ListenableAsyncCloseable> |
withMax(int maxConnections)
Create a new
ConnectionFactory that only creates a maximum of maxConnections active connections. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitappend, identitypublic static <A,C extends ListenableAsyncCloseable> ConnectionFactoryFilter<A,C> withMax(int maxConnections)
ConnectionFactory that only creates a maximum of maxConnections active connections.A - The type of a resolved address that can be used for connecting.C - The type of connections created by the returned factory.maxConnections - Maximum number of active connections to create.ConnectionFactory that limits the number of active connections.public static <A,C extends ListenableAsyncCloseable> ConnectionFactoryFilter<A,C> with(LimitingConnectionFactoryFilter.ConnectionLimiter<A,C> limiter)
ConnectionFactory that limits the created connections using the passed
LimitingConnectionFactoryFilter.ConnectionLimiter.A - The type of a resolved address that can be used for connecting.C - The type of connections created by the returned factory.limiter - LimitingConnectionFactoryFilter.ConnectionLimiter to use.ConnectionFactory that limits the number of active connections.public ConnectionFactory<ResolvedAddress,C> create(ConnectionFactory<ResolvedAddress,C> original)
ConnectionFactoryFilteroriginal ConnectionFactory to add the filtering logic.create in interface ConnectionFactoryFilter<ResolvedAddress,C extends ListenableAsyncCloseable>original - ConnectionFactory to filter.ConnectionFactory that contains the filtering logic.