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 String
private static final AtomicInteger
private final ConcurrentMap<Integer,
Channel> private final ChannelFutureListener
private 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 TypeMethodDescriptionboolean
void
clear()
close()
Closes allChannel
s in this group.int
boolean
Disconnects allChannel
s in this group from their remote peers.boolean
Returns theChannel
whose ID matches the specified integer.getName()
Returns the name of this group.int
hashCode()
boolean
isEmpty()
iterator()
boolean
setInterestOps
(int interestOps) setReadable
(boolean readable) CallsChannel.setReadable(boolean)
for allChannel
s in this group with the specified boolean flag.int
size()
Object[]
toArray()
<T> T[]
toArray
(T[] a) toString()
unbind()
Unbinds allChannel
s in this group from their local address.Writes the specifiedmessage
to allChannel
s in this group.write
(Object message, SocketAddress remoteAddress) Methods inherited from class java.util.AbstractSet
removeAll
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream
Methods 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:ChannelGroup
Returns the name of this group. A group name is purely for helping you to distinguish one group from others.- Specified by:
getName
in interfaceChannelGroup
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCollection<Channel>
- Specified by:
isEmpty
in interfaceSet<Channel>
- Overrides:
isEmpty
in classAbstractCollection<Channel>
-
size
public int size()- Specified by:
size
in interfaceCollection<Channel>
- Specified by:
size
in interfaceSet<Channel>
- Specified by:
size
in classAbstractCollection<Channel>
-
find
Description copied from interface:ChannelGroup
Returns theChannel
whose ID matches the specified integer.- Specified by:
find
in interfaceChannelGroup
- Returns:
- the matching
Channel
if found.null
otherwise.
-
contains
- Specified by:
contains
in interfaceCollection<Channel>
- Specified by:
contains
in interfaceSet<Channel>
- Overrides:
contains
in classAbstractCollection<Channel>
-
add
- Specified by:
add
in interfaceCollection<Channel>
- Specified by:
add
in interfaceSet<Channel>
- Overrides:
add
in classAbstractCollection<Channel>
-
remove
- Specified by:
remove
in interfaceCollection<Channel>
- Specified by:
remove
in interfaceSet<Channel>
- Overrides:
remove
in classAbstractCollection<Channel>
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<Channel>
- Specified by:
clear
in interfaceSet<Channel>
- Overrides:
clear
in classAbstractCollection<Channel>
-
iterator
-
toArray
- Specified by:
toArray
in interfaceCollection<Channel>
- Specified by:
toArray
in interfaceSet<Channel>
- Overrides:
toArray
in classAbstractCollection<Channel>
-
toArray
public <T> T[] toArray(T[] a) - Specified by:
toArray
in interfaceCollection<Channel>
- Specified by:
toArray
in interfaceSet<Channel>
- Overrides:
toArray
in classAbstractCollection<Channel>
-
close
Description copied from interface:ChannelGroup
Closes allChannel
s in this group. If theChannel
is connected to a remote peer or bound to a local address, it is automatically disconnected and unbound.- Specified by:
close
in interfaceChannelGroup
- Returns:
- the
ChannelGroupFuture
instance that notifies when the operation is done for all channels
-
disconnect
Description copied from interface:ChannelGroup
Disconnects allChannel
s in this group from their remote peers.- Specified by:
disconnect
in interfaceChannelGroup
- Returns:
- the
ChannelGroupFuture
instance that notifies when the operation is done for all channels
-
setInterestOps
Description copied from interface:ChannelGroup
CallsChannel.setInterestOps(int)
for allChannel
s in this group with the specifiedinterestOps
. Please note that this operation is asynchronous asChannel.setInterestOps(int)
is.- Specified by:
setInterestOps
in interfaceChannelGroup
- Returns:
- the
ChannelGroupFuture
instance that notifies when the operation is done for all channels
-
setReadable
Description copied from interface:ChannelGroup
CallsChannel.setReadable(boolean)
for allChannel
s in this group with the specified boolean flag. Please note that this operation is asynchronous asChannel.setReadable(boolean)
is.- Specified by:
setReadable
in interfaceChannelGroup
- Returns:
- the
ChannelGroupFuture
instance that notifies when the operation is done for all channels
-
unbind
Description copied from interface:ChannelGroup
Unbinds allChannel
s in this group from their local address.- Specified by:
unbind
in interfaceChannelGroup
- Returns:
- the
ChannelGroupFuture
instance that notifies when the operation is done for all channels
-
write
Description copied from interface:ChannelGroup
Writes the specifiedmessage
to allChannel
s in this group. If the specifiedmessage
is 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:
write
in interfaceChannelGroup
- Returns:
- the
ChannelGroupFuture
instance that notifies when the operation is done for all channels
-
write
Description copied from interface:ChannelGroup
Writes the specifiedmessage
with the specifiedremoteAddress
to allChannel
s in this group. If the specifiedmessage
is 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:
write
in interfaceChannelGroup
- Returns:
- the
ChannelGroupFuture
instance that notifies when the operation is done for all channels
-
hashCode
public int hashCode()- Specified by:
hashCode
in interfaceCollection<Channel>
- Specified by:
hashCode
in interfaceSet<Channel>
- Overrides:
hashCode
in classAbstractSet<Channel>
-
equals
- Specified by:
equals
in interfaceCollection<Channel>
- Specified by:
equals
in interfaceSet<Channel>
- Overrides:
equals
in classAbstractSet<Channel>
-
compareTo
- Specified by:
compareTo
in interfaceComparable<ChannelGroup>
-
toString
- Overrides:
toString
in classAbstractCollection<Channel>
-