Package org.jboss.netty.channel.group
Class DefaultChannelGroup
- All Implemented Interfaces:
Comparable<ChannelGroup>,Iterable<Channel>,Collection<Channel>,Set<Channel>,ChannelGroup
The default
ChannelGroup implementation.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Stringprivate static final AtomicIntegerprivate final ConcurrentMap<Integer, Channel> private final ChannelFutureListenerprivate final ConcurrentMap<Integer, Channel> -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new group with a generated name.DefaultChannelGroup(String name) Creates a new group with the specifiedname. -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidclear()close()Closes allChannels in this group.intbooleanDisconnects allChannels in this group from their remote peers.booleanReturns theChannelwhose ID matches the specified integer.getName()Returns the name of this group.inthashCode()booleanisEmpty()iterator()booleansetInterestOps(int interestOps) setReadable(boolean readable) CallsChannel.setReadable(boolean)for allChannels in this group with the specified boolean flag.intsize()Object[]toArray()<T> T[]toArray(T[] a) toString()unbind()Unbinds allChannels in this group from their local address.Writes the specifiedmessageto allChannels in this group.write(Object message, SocketAddress remoteAddress) Methods inherited from class java.util.AbstractSet
removeAllMethods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAllMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, streamMethods inherited from interface java.util.Set
addAll, containsAll, removeAll, retainAll, spliterator
-
Field Details
-
nextId
-
name
-
serverChannels
-
nonServerChannels
-
remover
-
-
Constructor Details
-
DefaultChannelGroup
public DefaultChannelGroup()Creates a new group with a generated name. -
DefaultChannelGroup
Creates a new group with the specifiedname. Please note that different groups can have the same name, which means no duplicate check is done against group names.
-
-
Method Details
-
getName
Description copied from interface:ChannelGroupReturns the name of this group. A group name is purely for helping you to distinguish one group from others.- Specified by:
getNamein interfaceChannelGroup
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<Channel>- Specified by:
isEmptyin interfaceSet<Channel>- Overrides:
isEmptyin classAbstractCollection<Channel>
-
size
public int size()- Specified by:
sizein interfaceCollection<Channel>- Specified by:
sizein interfaceSet<Channel>- Specified by:
sizein classAbstractCollection<Channel>
-
find
Description copied from interface:ChannelGroupReturns theChannelwhose ID matches the specified integer.- Specified by:
findin interfaceChannelGroup- Returns:
- the matching
Channelif found.nullotherwise.
-
contains
- Specified by:
containsin interfaceCollection<Channel>- Specified by:
containsin interfaceSet<Channel>- Overrides:
containsin classAbstractCollection<Channel>
-
add
- Specified by:
addin interfaceCollection<Channel>- Specified by:
addin interfaceSet<Channel>- Overrides:
addin classAbstractCollection<Channel>
-
remove
- Specified by:
removein interfaceCollection<Channel>- Specified by:
removein interfaceSet<Channel>- Overrides:
removein classAbstractCollection<Channel>
-
clear
public void clear()- Specified by:
clearin interfaceCollection<Channel>- Specified by:
clearin interfaceSet<Channel>- Overrides:
clearin classAbstractCollection<Channel>
-
iterator
-
toArray
- Specified by:
toArrayin interfaceCollection<Channel>- Specified by:
toArrayin interfaceSet<Channel>- Overrides:
toArrayin classAbstractCollection<Channel>
-
toArray
public <T> T[] toArray(T[] a) - Specified by:
toArrayin interfaceCollection<Channel>- Specified by:
toArrayin interfaceSet<Channel>- Overrides:
toArrayin classAbstractCollection<Channel>
-
close
Description copied from interface:ChannelGroupCloses allChannels in this group. If theChannelis connected to a remote peer or bound to a local address, it is automatically disconnected and unbound.- Specified by:
closein interfaceChannelGroup- Returns:
- the
ChannelGroupFutureinstance that notifies when the operation is done for all channels
-
disconnect
Description copied from interface:ChannelGroupDisconnects allChannels in this group from their remote peers.- Specified by:
disconnectin interfaceChannelGroup- Returns:
- the
ChannelGroupFutureinstance that notifies when the operation is done for all channels
-
setInterestOps
Description copied from interface:ChannelGroupCallsChannel.setInterestOps(int)for allChannels in this group with the specifiedinterestOps. Please note that this operation is asynchronous asChannel.setInterestOps(int)is.- Specified by:
setInterestOpsin interfaceChannelGroup- Returns:
- the
ChannelGroupFutureinstance that notifies when the operation is done for all channels
-
setReadable
Description copied from interface:ChannelGroupCallsChannel.setReadable(boolean)for allChannels in this group with the specified boolean flag. Please note that this operation is asynchronous asChannel.setReadable(boolean)is.- Specified by:
setReadablein interfaceChannelGroup- Returns:
- the
ChannelGroupFutureinstance that notifies when the operation is done for all channels
-
unbind
Description copied from interface:ChannelGroupUnbinds allChannels in this group from their local address.- Specified by:
unbindin interfaceChannelGroup- Returns:
- the
ChannelGroupFutureinstance that notifies when the operation is done for all channels
-
write
Description copied from interface:ChannelGroupWrites the specifiedmessageto allChannels in this group. If the specifiedmessageis an instance ofChannelBuffer, it is automatically duplicated to avoid a race condition. Please note that this operation is asynchronous asChannel.write(Object)is.- Specified by:
writein interfaceChannelGroup- Returns:
- the
ChannelGroupFutureinstance that notifies when the operation is done for all channels
-
write
Description copied from interface:ChannelGroupWrites the specifiedmessagewith the specifiedremoteAddressto allChannels in this group. If the specifiedmessageis an instance ofChannelBuffer, it is automatically duplicated to avoid a race condition. Please note that this operation is asynchronous asChannel.write(Object, SocketAddress)is.- Specified by:
writein interfaceChannelGroup- Returns:
- the
ChannelGroupFutureinstance that notifies when the operation is done for all channels
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceCollection<Channel>- Specified by:
hashCodein interfaceSet<Channel>- Overrides:
hashCodein classAbstractSet<Channel>
-
equals
- Specified by:
equalsin interfaceCollection<Channel>- Specified by:
equalsin interfaceSet<Channel>- Overrides:
equalsin classAbstractSet<Channel>
-
compareTo
- Specified by:
compareToin interfaceComparable<ChannelGroup>
-
toString
- Overrides:
toStringin classAbstractCollection<Channel>
-