public class DefaultChannelGroup extends java.util.AbstractSet<Channel> implements ChannelGroup
ChannelGroup
implementation.构造器和说明 |
---|
DefaultChannelGroup(EventExecutor executor)
Creates a new group with a generated name and the provided
EventExecutor to notify the
ChannelGroupFuture s. |
DefaultChannelGroup(EventExecutor executor,
boolean stayClosed)
Creates a new group with a generated name and the provided
EventExecutor to notify the
ChannelGroupFuture s. |
DefaultChannelGroup(java.lang.String name,
EventExecutor executor)
|
DefaultChannelGroup(java.lang.String name,
EventExecutor executor,
boolean stayClosed)
|
限定符和类型 | 方法和说明 |
---|---|
boolean |
add(Channel channel) |
void |
clear() |
ChannelGroupFuture |
close()
Closes all
Channel s in this group. |
ChannelGroupFuture |
close(ChannelMatcher matcher)
Closes all
Channel s in this group that are matched by the given ChannelMatcher . |
int |
compareTo(ChannelGroup o) |
boolean |
contains(java.lang.Object o) |
ChannelGroupFuture |
deregister() |
ChannelGroupFuture |
deregister(ChannelMatcher matcher) |
ChannelGroupFuture |
disconnect()
Disconnects all
Channel s in this group from their remote peers. |
ChannelGroupFuture |
disconnect(ChannelMatcher matcher)
Disconnects all
Channel s in this group from their remote peers,
that are matched by the given ChannelMatcher . |
boolean |
equals(java.lang.Object o) |
Channel |
find(ChannelId id)
|
ChannelGroup |
flush()
Flush all
Channel s in this
group. |
ChannelGroup |
flush(ChannelMatcher matcher)
Flush all
Channel s in this group that are matched by the given ChannelMatcher . |
ChannelGroupFuture |
flushAndWrite(java.lang.Object message) |
ChannelGroupFuture |
flushAndWrite(java.lang.Object message,
ChannelMatcher matcher) |
int |
hashCode() |
boolean |
isEmpty() |
java.util.Iterator<Channel> |
iterator() |
java.lang.String |
name()
Returns the name of this group.
|
ChannelGroupFuture |
newCloseFuture()
Returns the
ChannelGroupFuture which will be notified when all Channel s that are part of this
ChannelGroup , at the time of calling, are closed. |
ChannelGroupFuture |
newCloseFuture(ChannelMatcher matcher)
Returns the
ChannelGroupFuture which will be notified when all Channel s that are part of this
ChannelGroup , at the time of calling, are closed. |
boolean |
remove(java.lang.Object o) |
int |
size() |
java.lang.Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
java.lang.String |
toString() |
ChannelGroupFuture |
write(java.lang.Object message)
Writes the specified
message to all Channel s in this
group. |
ChannelGroupFuture |
write(java.lang.Object message,
ChannelMatcher matcher)
Writes the specified
message to all Channel s in this
group that are matched by the given ChannelMatcher . |
ChannelGroupFuture |
write(java.lang.Object message,
ChannelMatcher matcher,
boolean voidPromise)
Writes the specified
message to all Channel s in this
group that are matched by the given ChannelMatcher . |
ChannelGroupFuture |
writeAndFlush(java.lang.Object message)
Shortcut for calling
ChannelGroup.write(Object) and ChannelGroup.flush() . |
ChannelGroupFuture |
writeAndFlush(java.lang.Object message,
ChannelMatcher matcher)
Shortcut for calling
ChannelGroup.write(Object) and ChannelGroup.flush() and only act on
Channel s that are matched by the ChannelMatcher . |
ChannelGroupFuture |
writeAndFlush(java.lang.Object message,
ChannelMatcher matcher,
boolean voidPromise)
Shortcut for calling
ChannelGroup.write(Object, ChannelMatcher, boolean) and ChannelGroup.flush() and only act on
Channel s that are matched by the ChannelMatcher . |
public DefaultChannelGroup(EventExecutor executor)
EventExecutor
to notify the
ChannelGroupFuture
s.public DefaultChannelGroup(java.lang.String name, EventExecutor executor)
name
and EventExecutor
to notify the
ChannelGroupFuture
s. Please note that different groups can have the same name, which means no
duplicate check is done against group names.public DefaultChannelGroup(EventExecutor executor, boolean stayClosed)
EventExecutor
to notify the
ChannelGroupFuture
s. stayClosed
defines whether or not, this group can be closed
more than once. Adding channels to a closed group will immediately close them, too. This makes it
easy, to shutdown server and child channels at once.public DefaultChannelGroup(java.lang.String name, EventExecutor executor, boolean stayClosed)
name
and EventExecutor
to notify the
ChannelGroupFuture
s. stayClosed
defines whether or not, this group can be closed
more than once. Adding channels to a closed group will immediately close them, too. This makes it
easy, to shutdown server and child channels at once. Please note that different groups can have
the same name, which means no duplicate check is done against group names.public java.lang.String name()
ChannelGroup
name
在接口中 ChannelGroup
public Channel find(ChannelId id)
ChannelGroup
find
在接口中 ChannelGroup
Channel
if found. null
otherwise.public boolean isEmpty()
public int size()
public boolean contains(java.lang.Object o)
public boolean add(Channel channel)
public boolean remove(java.lang.Object o)
public void clear()
public java.util.Iterator<Channel> iterator()
public java.lang.Object[] toArray()
public <T> T[] toArray(T[] a)
public ChannelGroupFuture close()
ChannelGroup
Channel
s in this group. If the Channel
is
connected to a remote peer or bound to a local address, it is
automatically disconnected and unbound.close
在接口中 ChannelGroup
ChannelGroupFuture
instance that notifies when
the operation is done for all channelspublic ChannelGroupFuture disconnect()
ChannelGroup
Channel
s in this group from their remote peers.disconnect
在接口中 ChannelGroup
ChannelGroupFuture
instance that notifies when
the operation is done for all channelspublic ChannelGroupFuture deregister()
deregister
在接口中 ChannelGroup
ChannelGroupFuture
instance that notifies when
the operation is done for all channelspublic ChannelGroupFuture write(java.lang.Object message)
ChannelGroup
message
to all Channel
s in this
group. If the specified message
is an instance of
ByteBuf
, it is automatically
duplicated to avoid a race
condition. The same is true for ByteBufHolder
. Please note that this operation is asynchronous as
ChannelOutboundInvoker.write(Object)
is.write
在接口中 ChannelGroup
public ChannelGroupFuture write(java.lang.Object message, ChannelMatcher matcher)
ChannelGroup
message
to all Channel
s in this
group that are matched by the given ChannelMatcher
. If the specified message
is an instance of
ByteBuf
, it is automatically
duplicated to avoid a race
condition. The same is true for ByteBufHolder
. Please note that this operation is asynchronous as
ChannelOutboundInvoker.write(Object)
is.write
在接口中 ChannelGroup
ChannelGroupFuture
instance that notifies when
the operation is done for all channelspublic ChannelGroupFuture write(java.lang.Object message, ChannelMatcher matcher, boolean voidPromise)
ChannelGroup
message
to all Channel
s in this
group that are matched by the given ChannelMatcher
. If the specified message
is an instance of
ByteBuf
, it is automatically
duplicated to avoid a race
condition. The same is true for ByteBufHolder
. Please note that this operation is asynchronous as
ChannelOutboundInvoker.write(Object)
is.
If voidPromise
is true
ChannelOutboundInvoker.voidPromise()
is used for the writes and so the same
restrictions to the returned ChannelGroupFuture
apply as to a void promise.write
在接口中 ChannelGroup
ChannelGroupFuture
instance that notifies when
the operation is done for all channelspublic ChannelGroup flush()
ChannelGroup
Channel
s in this
group. If the specified messages
are an instance of
ByteBuf
, it is automatically
duplicated to avoid a race
condition. Please note that this operation is asynchronous as
ChannelOutboundInvoker.write(Object)
is.flush
在接口中 ChannelGroup
ChannelGroupFuture
instance that notifies when
the operation is done for all channelspublic ChannelGroupFuture flushAndWrite(java.lang.Object message)
flushAndWrite
在接口中 ChannelGroup
public ChannelGroupFuture writeAndFlush(java.lang.Object message)
ChannelGroup
ChannelGroup.write(Object)
and ChannelGroup.flush()
.writeAndFlush
在接口中 ChannelGroup
public ChannelGroupFuture disconnect(ChannelMatcher matcher)
ChannelGroup
Channel
s in this group from their remote peers,
that are matched by the given ChannelMatcher
.disconnect
在接口中 ChannelGroup
ChannelGroupFuture
instance that notifies when
the operation is done for all channelspublic ChannelGroupFuture close(ChannelMatcher matcher)
ChannelGroup
Channel
s in this group that are matched by the given ChannelMatcher
.
If the Channel
is connected to a remote peer or bound to a local address, it is
automatically disconnected and unbound.close
在接口中 ChannelGroup
ChannelGroupFuture
instance that notifies when
the operation is done for all channelspublic ChannelGroupFuture deregister(ChannelMatcher matcher)
deregister
在接口中 ChannelGroup
ChannelGroupFuture
instance that notifies when
the operation is done for all channelspublic ChannelGroup flush(ChannelMatcher matcher)
ChannelGroup
Channel
s in this group that are matched by the given ChannelMatcher
.
If the specified messages
are an instance of
ByteBuf
, it is automatically
duplicated to avoid a race
condition. Please note that this operation is asynchronous as
ChannelOutboundInvoker.write(Object)
is.flush
在接口中 ChannelGroup
ChannelGroupFuture
instance that notifies when
the operation is done for all channelspublic ChannelGroupFuture flushAndWrite(java.lang.Object message, ChannelMatcher matcher)
flushAndWrite
在接口中 ChannelGroup
public ChannelGroupFuture writeAndFlush(java.lang.Object message, ChannelMatcher matcher)
ChannelGroup
ChannelGroup.write(Object)
and ChannelGroup.flush()
and only act on
Channel
s that are matched by the ChannelMatcher
.writeAndFlush
在接口中 ChannelGroup
public ChannelGroupFuture writeAndFlush(java.lang.Object message, ChannelMatcher matcher, boolean voidPromise)
ChannelGroup
ChannelGroup.write(Object, ChannelMatcher, boolean)
and ChannelGroup.flush()
and only act on
Channel
s that are matched by the ChannelMatcher
.writeAndFlush
在接口中 ChannelGroup
public ChannelGroupFuture newCloseFuture()
ChannelGroup
ChannelGroupFuture
which will be notified when all Channel
s that are part of this
ChannelGroup
, at the time of calling, are closed.newCloseFuture
在接口中 ChannelGroup
public ChannelGroupFuture newCloseFuture(ChannelMatcher matcher)
ChannelGroup
ChannelGroupFuture
which will be notified when all Channel
s that are part of this
ChannelGroup
, at the time of calling, are closed.newCloseFuture
在接口中 ChannelGroup
public int hashCode()
public boolean equals(java.lang.Object o)
public int compareTo(ChannelGroup o)
compareTo
在接口中 java.lang.Comparable<ChannelGroup>
public java.lang.String toString()
toString
在类中 java.util.AbstractCollection<Channel>