Package org.jboss.netty.channel.group
Class DefaultChannelGroup
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<Channel>
-
- org.jboss.netty.channel.group.DefaultChannelGroup
-
- All Implemented Interfaces:
Comparable<ChannelGroup>
,Iterable<Channel>
,Collection<Channel>
,Set<Channel>
,ChannelGroup
public class DefaultChannelGroup extends AbstractSet<Channel> implements ChannelGroup
The defaultChannelGroup
implementation.
-
-
Constructor Summary
Constructors Constructor Description DefaultChannelGroup()
Creates a new group with a generated name.DefaultChannelGroup(String name)
Creates a new group with the specifiedname
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(Channel channel)
void
clear()
ChannelGroupFuture
close()
Closes allChannel
s in this group.int
compareTo(ChannelGroup o)
boolean
contains(Object o)
ChannelGroupFuture
disconnect()
Disconnects allChannel
s in this group from their remote peers.boolean
equals(Object o)
Channel
find(Integer id)
Returns theChannel
whose ID matches the specified integer.String
getName()
Returns the name of this group.int
hashCode()
boolean
isEmpty()
Iterator<Channel>
iterator()
boolean
remove(Object o)
ChannelGroupFuture
setInterestOps(int interestOps)
ChannelGroupFuture
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)
String
toString()
ChannelGroupFuture
unbind()
Unbinds allChannel
s in this group from their local address.ChannelGroupFuture
write(Object message)
Writes the specifiedmessage
to allChannel
s in this group.ChannelGroupFuture
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, toArray
-
Methods inherited from interface java.util.Set
addAll, containsAll, removeAll, retainAll, spliterator
-
-
-
-
Constructor Detail
-
DefaultChannelGroup
public DefaultChannelGroup()
Creates a new group with a generated name.
-
DefaultChannelGroup
public DefaultChannelGroup(String name)
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 Detail
-
getName
public String 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
public Channel find(Integer id)
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
public boolean contains(Object o)
- Specified by:
contains
in interfaceCollection<Channel>
- Specified by:
contains
in interfaceSet<Channel>
- Overrides:
contains
in classAbstractCollection<Channel>
-
add
public boolean add(Channel channel)
- Specified by:
add
in interfaceCollection<Channel>
- Specified by:
add
in interfaceSet<Channel>
- Overrides:
add
in classAbstractCollection<Channel>
-
remove
public boolean remove(Object o)
- 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>
-
toArray
public Object[] 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
public ChannelGroupFuture 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
public ChannelGroupFuture 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
public ChannelGroupFuture setInterestOps(int interestOps)
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
public ChannelGroupFuture setReadable(boolean readable)
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
public ChannelGroupFuture 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
public ChannelGroupFuture write(Object message)
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
public ChannelGroupFuture write(Object message, SocketAddress remoteAddress)
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
public boolean equals(Object o)
- Specified by:
equals
in interfaceCollection<Channel>
- Specified by:
equals
in interfaceSet<Channel>
- Overrides:
equals
in classAbstractSet<Channel>
-
compareTo
public int compareTo(ChannelGroup o)
- Specified by:
compareTo
in interfaceComparable<ChannelGroup>
-
toString
public String toString()
- Overrides:
toString
in classAbstractCollection<Channel>
-
-