Package io.netty.channel.pool
Class AbstractChannelPoolMap<K,P extends ChannelPool>
- java.lang.Object
-
- io.netty.channel.pool.AbstractChannelPoolMap<K,P>
-
- All Implemented Interfaces:
ChannelPoolMap<K,P>,java.io.Closeable,java.lang.AutoCloseable,java.lang.Iterable<java.util.Map.Entry<K,P>>
public abstract class AbstractChannelPoolMap<K,P extends ChannelPool> extends java.lang.Object implements ChannelPoolMap<K,P>, java.lang.Iterable<java.util.Map.Entry<K,P>>, java.io.Closeable
A skeletalChannelPoolMapimplementation. To find the rightChannelPooltheObject.hashCode()andObject.equals(Object)is used.
-
-
Constructor Summary
Constructors Constructor Description AbstractChannelPoolMap()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()booleancontains(K key)Pget(K key)Return theChannelPoolfor thecode.booleanisEmpty()java.util.Iterator<java.util.Map.Entry<K,P>>iterator()protected abstract PnewPool(K key)Called once a newChannelPoolneeds to be created as non exists yet for thekey.booleanremove(K key)Remove theChannelPoolfrom thisAbstractChannelPoolMap.intsize()Returns the number ofChannelPools currently in thisAbstractChannelPoolMap.
-
-
-
Method Detail
-
get
public final P get(K key)
Description copied from interface:ChannelPoolMapReturn theChannelPoolfor thecode. This will never returnnull, but create a newChannelPoolif non exists for they requestedkey. Please note thatnullkeys are not allowed.- Specified by:
getin interfaceChannelPoolMap<K,P extends ChannelPool>
-
remove
public final boolean remove(K key)
Remove theChannelPoolfrom thisAbstractChannelPoolMap. Returnstrueif removed,falseotherwise. If the removed pool extendsSimpleChannelPoolit will be closed asynchronously to avoid blocking in this method. Please note thatnullkeys are not allowed.
-
iterator
public final java.util.Iterator<java.util.Map.Entry<K,P>> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<K>
-
size
public final int size()
Returns the number ofChannelPools currently in thisAbstractChannelPoolMap.
-
isEmpty
public final boolean isEmpty()
-
contains
public final boolean contains(K key)
Description copied from interface:ChannelPoolMap- Specified by:
containsin interfaceChannelPoolMap<K,P extends ChannelPool>
-
newPool
protected abstract P newPool(K key)
Called once a newChannelPoolneeds to be created as non exists yet for thekey.
-
close
public final void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable
-
-