* Added JavaDoc for Channels
* Improved the diagram in ChannelPipeline
This commit is contained in:
parent
78075ad7fc
commit
b06323011d
|
@ -59,40 +59,40 @@ import org.jboss.netty.handler.ssl.SslHandler;
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
*
|
*
|
||||||
* I/O Request
|
* I/O Request
|
||||||
* via {@link Channel} or
|
* via {@link Channel} or
|
||||||
* {@link ChannelHandlerContext}
|
* {@link ChannelHandlerContext}
|
||||||
* |
|
* |
|
||||||
* +-----------------------------------------+----------------+
|
* +---------------------------------------------+----------------+
|
||||||
* | ChannelPipeline | |
|
* | ChannelPipeline | |
|
||||||
* | \|/ |
|
* | \|/ |
|
||||||
* | +----------------------+ +-----------+------------+ |
|
* | +----------------------+ +-----------+------------+ |
|
||||||
* | | Upstream Handler N | | Downstream Handler 1 | |
|
* | LAST | Upstream Handler N | | Downstream Handler M | |
|
||||||
* | +----------+-----------+ +-----------+------------+ |
|
* | . +----------+-----------+ +-----------+------------+ |
|
||||||
* | /|\ | |
|
* | . /|\ | |
|
||||||
* | | \|/ |
|
* | . | \|/ |
|
||||||
* | +----------+-----------+ +-----------+------------+ |
|
* | . +----------+-----------+ +-----------+------------+ |
|
||||||
* | | Upstream Handler N-1 | | Downstream Handler 2 | |
|
* | . | Upstream Handler N-1 | | Downstream Handler M-1 | |
|
||||||
* | +----------+-----------+ +-----------+------------+ |
|
* | . +----------+-----------+ +-----------+------------+ |
|
||||||
* | /|\ . |
|
* | . /|\ . |
|
||||||
* | . . |
|
* | . . . |
|
||||||
* | [ Going Upstream ] [ Going Downstream ] |
|
* | . [ Going UPSTREAM ] [ Going DOWNSTREAM ] |
|
||||||
* | . . |
|
* | . . . |
|
||||||
* | . \|/ |
|
* | . . \|/ |
|
||||||
* | +----------+-----------+ +-----------+------------+ |
|
* | . +----------+-----------+ +-----------+------------+ |
|
||||||
* | | Upstream Handler 2 | | Downstream Handler M-1 | |
|
* | . | Upstream Handler 2 | | Downstream Handler 2 | |
|
||||||
* | +----------+-----------+ +-----------+------------+ |
|
* | . +----------+-----------+ +-----------+------------+ |
|
||||||
* | /|\ | |
|
* | . /|\ | |
|
||||||
* | | \|/ |
|
* | . | \|/ |
|
||||||
* | +----------+-----------+ +-----------+------------+ |
|
* | . +----------+-----------+ +-----------+------------+ |
|
||||||
* | | Upstream Handler 1 | | Downstream Handler M | |
|
* | FIRST | Upstream Handler 1 | | Downstream Handler 1 | |
|
||||||
* | +----------+-----------+ +-----------+------------+ |
|
* | +----------+-----------+ +-----------+------------+ |
|
||||||
* | /|\ | |
|
* | /|\ | |
|
||||||
* +--------------+--------------------------+----------------+
|
* +------------------+--------------------------+----------------+
|
||||||
* | \|/
|
* | \|/
|
||||||
* +--------------+--------------------------+----------------+
|
* +------------------+--------------------------+----------------+
|
||||||
* | I/O Threads (Transport Implementation) |
|
* | I/O Threads (Transport Implementation) |
|
||||||
* +----------------------------------------------------------+
|
* +--------------------------------------------------------------+
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* <h3>Building a pipeline</h3>
|
* <h3>Building a pipeline</h3>
|
||||||
|
|
|
@ -179,9 +179,10 @@ public class Channels {
|
||||||
// event emission methods
|
// event emission methods
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires a {@link ChannelUpstreamHandler channelOpen} event to the specified
|
* Fires a {@code "channelOpen"} event to the first
|
||||||
* {@link Channel}. If the specified channel has a parent, a
|
* {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} of
|
||||||
* {@link ChannelUpstreamHandler childChannelOpen} event will be fired too.
|
* the specified {@link Channel}. If the specified channel has a parent,
|
||||||
|
* a {@code "childChannelOpen"} event will be fired, too.
|
||||||
*/
|
*/
|
||||||
public static void fireChannelOpen(Channel channel) {
|
public static void fireChannelOpen(Channel channel) {
|
||||||
if (channel.getParent() != null) {
|
if (channel.getParent() != null) {
|
||||||
|
@ -194,9 +195,10 @@ public class Channels {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires a {@link ChannelUpstreamHandler channelOpen} event to the specified
|
* Fires a {@code "channelOpen"} event to the next
|
||||||
* {@link ChannelHandlerContext}. Please note that this method doesn't
|
* {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} where
|
||||||
* fire a {@link ChannelUpstreamHandler childChannelOpen} event unlike
|
* the specified {@link ChannelHandlerContext} belongs. Please note that
|
||||||
|
* this method doesn't fire a {@code "childChannelOpen"} event unlike
|
||||||
* {@link #fireChannelOpen(Channel)} method.
|
* {@link #fireChannelOpen(Channel)} method.
|
||||||
*/
|
*/
|
||||||
public static void fireChannelOpen(
|
public static void fireChannelOpen(
|
||||||
|
@ -208,8 +210,9 @@ public class Channels {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires a {@link ChannelUpstreamHandler channelBound} event to the specified
|
* Fires a {@code "channelBound"} event to the first
|
||||||
* {@link Channel}.
|
* {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} of
|
||||||
|
* the specified {@link Channel}.
|
||||||
*
|
*
|
||||||
* @param localAddress
|
* @param localAddress
|
||||||
* the local address where the specified channel is bound
|
* the local address where the specified channel is bound
|
||||||
|
@ -222,8 +225,9 @@ public class Channels {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires a {@link ChannelUpstreamHandler channelBound} event to the specified
|
* Fires a {@code "channelBound"} event to the next
|
||||||
* {@link Channel}.
|
* {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} where
|
||||||
|
* the specified {@link ChannelHandlerContext} belongs.
|
||||||
*
|
*
|
||||||
* @param localAddress
|
* @param localAddress
|
||||||
* the local address where the specified channel is bound
|
* the local address where the specified channel is bound
|
||||||
|
@ -237,8 +241,9 @@ public class Channels {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires a {@link ChannelUpstreamHandler channelConnected} event to the
|
* Fires a {@code "channelConnected"} event to the first
|
||||||
* specified {@link Channel}.
|
* {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} of
|
||||||
|
* the specified {@link Channel}.
|
||||||
*
|
*
|
||||||
* @param remoteAddress
|
* @param remoteAddress
|
||||||
* the remote address where the specified channel is connected
|
* the remote address where the specified channel is connected
|
||||||
|
@ -251,8 +256,9 @@ public class Channels {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires a {@link ChannelUpstreamHandler channelConnected} event to the
|
* Fires a {@code "channelConnected"} event to the next
|
||||||
* specified {@link ChannelHandlerContext}.
|
* {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} where
|
||||||
|
* the specified {@link ChannelHandlerContext} belongs.
|
||||||
*
|
*
|
||||||
* @param remoteAddress
|
* @param remoteAddress
|
||||||
* the remote address where the specified channel is connected
|
* the remote address where the specified channel is connected
|
||||||
|
@ -266,8 +272,9 @@ public class Channels {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires a {@link ChannelUpstreamHandler messageReceived} event to the
|
* Fires a {@code "messageReceived"} event to the first
|
||||||
* specified {@link Channel}.
|
* {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} of
|
||||||
|
* the specified {@link Channel}.
|
||||||
*
|
*
|
||||||
* @param message the received message
|
* @param message the received message
|
||||||
*/
|
*/
|
||||||
|
@ -276,8 +283,9 @@ public class Channels {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires a {@link ChannelUpstreamHandler messageReceived} event to the
|
* Fires a {@code "messageReceived"} event to the first
|
||||||
* specified {@link Channel}.
|
* {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} of
|
||||||
|
* the specified {@link Channel} belongs.
|
||||||
*
|
*
|
||||||
* @param message the received message
|
* @param message the received message
|
||||||
* @param remoteAddress the remote address where the received message
|
* @param remoteAddress the remote address where the received message
|
||||||
|
@ -291,8 +299,9 @@ public class Channels {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires a {@link ChannelUpstreamHandler messageReceived} event to the
|
* Fires a {@code "messageReceived"} event to the next
|
||||||
* specified {@link ChannelHandlerContext}.
|
* {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} where
|
||||||
|
* the specified {@link ChannelHandlerContext} belongs.
|
||||||
*
|
*
|
||||||
* @param message the received message
|
* @param message the received message
|
||||||
*/
|
*/
|
||||||
|
@ -303,8 +312,9 @@ public class Channels {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires a {@link ChannelUpstreamHandler messageReceived} event to the
|
* Fires a {@code "messageReceived"} event to the next
|
||||||
* specified {@link ChannelHandlerContext}.
|
* {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} where
|
||||||
|
* the specified {@link ChannelHandlerContext} belongs.
|
||||||
*
|
*
|
||||||
* @param message the received message
|
* @param message the received message
|
||||||
* @param remoteAddress the remote address where the received message
|
* @param remoteAddress the remote address where the received message
|
||||||
|
@ -318,8 +328,9 @@ public class Channels {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires a {@link ChannelUpstreamHandler channelInterestChanged} event to the
|
* Fires a {@code "channelInterestChanged"} event to the first
|
||||||
* specified {@link Channel}.
|
* {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} of
|
||||||
|
* the specified {@link Channel}.
|
||||||
*
|
*
|
||||||
* @param interestOps the new interestOps
|
* @param interestOps the new interestOps
|
||||||
*/
|
*/
|
||||||
|
@ -332,8 +343,9 @@ public class Channels {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires a {@link ChannelUpstreamHandler channelInterestChanged} event to the
|
* Fires a {@code "channelInterestChanged"} event to the next
|
||||||
* specified {@link ChannelHandlerContext}.
|
* {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} where
|
||||||
|
* the specified {@link ChannelHandlerContext} belongs.
|
||||||
*
|
*
|
||||||
* @param interestOps the new interestOps
|
* @param interestOps the new interestOps
|
||||||
*/
|
*/
|
||||||
|
@ -348,8 +360,9 @@ public class Channels {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires a {@link ChannelUpstreamHandler channelDisconnected} event to the
|
* Fires a {@code "channelDisconnected"} event to the first
|
||||||
* specified {@link Channel}.
|
* {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} of
|
||||||
|
* the specified {@link Channel}.
|
||||||
*/
|
*/
|
||||||
public static void fireChannelDisconnected(Channel channel) {
|
public static void fireChannelDisconnected(Channel channel) {
|
||||||
channel.getPipeline().sendUpstream(
|
channel.getPipeline().sendUpstream(
|
||||||
|
@ -359,8 +372,9 @@ public class Channels {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires a {@link ChannelUpstreamHandler channelDisconnected} event to the
|
* Fires a {@code "channelDisconnected"} event to the next
|
||||||
* specified {@link ChannelHandlerContext}.
|
* {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} where
|
||||||
|
* the specified {@link ChannelHandlerContext} belongs.
|
||||||
*/
|
*/
|
||||||
public static void fireChannelDisconnected(
|
public static void fireChannelDisconnected(
|
||||||
ChannelHandlerContext ctx, Channel channel) {
|
ChannelHandlerContext ctx, Channel channel) {
|
||||||
|
@ -369,11 +383,21 @@ public class Channels {
|
||||||
ChannelState.CONNECTED, null));
|
ChannelState.CONNECTED, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fires a {@code "channelUnbound"} event to the first
|
||||||
|
* {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} of
|
||||||
|
* the specified {@link Channel}.
|
||||||
|
*/
|
||||||
public static void fireChannelUnbound(Channel channel) {
|
public static void fireChannelUnbound(Channel channel) {
|
||||||
channel.getPipeline().sendUpstream(new DefaultChannelStateEvent(
|
channel.getPipeline().sendUpstream(new DefaultChannelStateEvent(
|
||||||
channel, succeededFuture(channel), ChannelState.BOUND, null));
|
channel, succeededFuture(channel), ChannelState.BOUND, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fires a {@code "channelUnbound"} event to the next
|
||||||
|
* {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} where
|
||||||
|
* the specified {@link ChannelHandlerContext} belongs.
|
||||||
|
*/
|
||||||
public static void fireChannelUnbound(
|
public static void fireChannelUnbound(
|
||||||
ChannelHandlerContext ctx, Channel channel) {
|
ChannelHandlerContext ctx, Channel channel) {
|
||||||
|
|
||||||
|
@ -381,6 +405,11 @@ public class Channels {
|
||||||
channel, succeededFuture(channel), ChannelState.BOUND, null));
|
channel, succeededFuture(channel), ChannelState.BOUND, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fires a {@code "channelClosed"} event to the first
|
||||||
|
* {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} of
|
||||||
|
* the specified {@link Channel}.
|
||||||
|
*/
|
||||||
public static void fireChannelClosed(Channel channel) {
|
public static void fireChannelClosed(Channel channel) {
|
||||||
channel.getPipeline().sendUpstream(
|
channel.getPipeline().sendUpstream(
|
||||||
new DefaultChannelStateEvent(
|
new DefaultChannelStateEvent(
|
||||||
|
@ -391,6 +420,11 @@ public class Channels {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fires a {@code "channelClosed"} event to the next
|
||||||
|
* {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} where
|
||||||
|
* the specified {@link ChannelHandlerContext} belongs.
|
||||||
|
*/
|
||||||
public static void fireChannelClosed(
|
public static void fireChannelClosed(
|
||||||
ChannelHandlerContext ctx, Channel channel) {
|
ChannelHandlerContext ctx, Channel channel) {
|
||||||
ctx.sendUpstream(
|
ctx.sendUpstream(
|
||||||
|
@ -399,12 +433,22 @@ public class Channels {
|
||||||
ChannelState.OPEN, Boolean.FALSE));
|
ChannelState.OPEN, Boolean.FALSE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fires a {@code "exceptionCaught"} event to the first
|
||||||
|
* {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} of
|
||||||
|
* the specified {@link Channel}.
|
||||||
|
*/
|
||||||
public static void fireExceptionCaught(Channel channel, Throwable cause) {
|
public static void fireExceptionCaught(Channel channel, Throwable cause) {
|
||||||
channel.getPipeline().sendUpstream(
|
channel.getPipeline().sendUpstream(
|
||||||
new DefaultExceptionEvent(
|
new DefaultExceptionEvent(
|
||||||
channel, succeededFuture(channel), cause));
|
channel, succeededFuture(channel), cause));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fires a {@code "exceptionCaught"} event to the next
|
||||||
|
* {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} where
|
||||||
|
* the specified {@link ChannelHandlerContext} belongs.
|
||||||
|
*/
|
||||||
public static void fireExceptionCaught(
|
public static void fireExceptionCaught(
|
||||||
ChannelHandlerContext ctx, Channel channel, Throwable cause) {
|
ChannelHandlerContext ctx, Channel channel, Throwable cause) {
|
||||||
ctx.sendUpstream(new DefaultExceptionEvent(
|
ctx.sendUpstream(new DefaultExceptionEvent(
|
||||||
|
@ -418,6 +462,17 @@ public class Channels {
|
||||||
channel, succeededFuture(channel), childChannel));
|
channel, succeededFuture(channel), childChannel));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a {@code "bind"} request to the last
|
||||||
|
* {@link ChannelDownstreamHandler} in the {@link ChannelPipeline} of
|
||||||
|
* the specified {@link Channel}.
|
||||||
|
*
|
||||||
|
* @param channel the channel to bind
|
||||||
|
* @param localAddress the local address to bind to
|
||||||
|
*
|
||||||
|
* @return the {@link ChannelFuture} which will be notified when the
|
||||||
|
* bind operation is done
|
||||||
|
*/
|
||||||
public static ChannelFuture bind(Channel channel, SocketAddress localAddress) {
|
public static ChannelFuture bind(Channel channel, SocketAddress localAddress) {
|
||||||
if (localAddress == null) {
|
if (localAddress == null) {
|
||||||
throw new NullPointerException("localAddress");
|
throw new NullPointerException("localAddress");
|
||||||
|
@ -428,6 +483,17 @@ public class Channels {
|
||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a {@code "bind"} request to the previous
|
||||||
|
* {@link ChannelDownstreamHandler} in the {@link ChannelPipeline} where
|
||||||
|
* the specified {@link ChannelHandlerContext} belongs.
|
||||||
|
*
|
||||||
|
* @param ctx the context
|
||||||
|
* @param channel the channel to bind
|
||||||
|
* @param future the future which will be notified when the bind
|
||||||
|
* operation is done
|
||||||
|
* @param localAddress the local address to bind to
|
||||||
|
*/
|
||||||
public static void bind(
|
public static void bind(
|
||||||
ChannelHandlerContext ctx, Channel channel,
|
ChannelHandlerContext ctx, Channel channel,
|
||||||
ChannelFuture future, SocketAddress localAddress) {
|
ChannelFuture future, SocketAddress localAddress) {
|
||||||
|
@ -438,6 +504,17 @@ public class Channels {
|
||||||
channel, future, ChannelState.BOUND, localAddress));
|
channel, future, ChannelState.BOUND, localAddress));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a {@code "connect"} request to the last
|
||||||
|
* {@link ChannelDownstreamHandler} in the {@link ChannelPipeline} of
|
||||||
|
* the specified {@link Channel}.
|
||||||
|
*
|
||||||
|
* @param channel the channel to attempt a connection
|
||||||
|
* @param remoteAddress the remote address to connect to
|
||||||
|
*
|
||||||
|
* @return the {@link ChannelFuture} which will be notified when the
|
||||||
|
* connection attempt is done
|
||||||
|
*/
|
||||||
public static ChannelFuture connect(Channel channel, SocketAddress remoteAddress) {
|
public static ChannelFuture connect(Channel channel, SocketAddress remoteAddress) {
|
||||||
if (remoteAddress == null) {
|
if (remoteAddress == null) {
|
||||||
throw new NullPointerException("remoteAddress");
|
throw new NullPointerException("remoteAddress");
|
||||||
|
@ -448,6 +525,17 @@ public class Channels {
|
||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a {@code "connect"} request to the previous
|
||||||
|
* {@link ChannelDownstreamHandler} in the {@link ChannelPipeline} where
|
||||||
|
* the specified {@link ChannelHandlerContext} belongs.
|
||||||
|
*
|
||||||
|
* @param ctx the context
|
||||||
|
* @param channel the channel to attempt a connection
|
||||||
|
* @param future the future which will be notified when the connection
|
||||||
|
* attempt is done
|
||||||
|
* @param remoteAddress the remote address to connect to
|
||||||
|
*/
|
||||||
public static void connect(
|
public static void connect(
|
||||||
ChannelHandlerContext ctx, Channel channel,
|
ChannelHandlerContext ctx, Channel channel,
|
||||||
ChannelFuture future, SocketAddress remoteAddress) {
|
ChannelFuture future, SocketAddress remoteAddress) {
|
||||||
|
@ -458,16 +546,50 @@ public class Channels {
|
||||||
channel, future, ChannelState.CONNECTED, remoteAddress));
|
channel, future, ChannelState.CONNECTED, remoteAddress));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a {@code "write"} request to the last
|
||||||
|
* {@link ChannelDownstreamHandler} in the {@link ChannelPipeline} of
|
||||||
|
* the specified {@link Channel}.
|
||||||
|
*
|
||||||
|
* @param channel the channel to write a message
|
||||||
|
* @param message the message to write to the channel
|
||||||
|
*
|
||||||
|
* @return the {@link ChannelFuture} which will be notified when the
|
||||||
|
* write operation is done
|
||||||
|
*/
|
||||||
public static ChannelFuture write(Channel channel, Object message) {
|
public static ChannelFuture write(Channel channel, Object message) {
|
||||||
return write(channel, message, null);
|
return write(channel, message, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a {@code "write"} request to the previous
|
||||||
|
* {@link ChannelDownstreamHandler} in the {@link ChannelPipeline} where
|
||||||
|
* the specified {@link ChannelHandlerContext} belongs.
|
||||||
|
*
|
||||||
|
* @param ctx the context
|
||||||
|
* @param channel the channel to write a message
|
||||||
|
* @param future the future which will be notified when the write
|
||||||
|
* operation is done
|
||||||
|
*/
|
||||||
public static void write(
|
public static void write(
|
||||||
ChannelHandlerContext ctx, Channel channel,
|
ChannelHandlerContext ctx, Channel channel,
|
||||||
ChannelFuture future, Object message) {
|
ChannelFuture future, Object message) {
|
||||||
write(ctx, channel, future, message, null);
|
write(ctx, channel, future, message, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a {@code "write"} request to the last
|
||||||
|
* {@link ChannelDownstreamHandler} in the {@link ChannelPipeline} of
|
||||||
|
* the specified {@link Channel}.
|
||||||
|
*
|
||||||
|
* @param channel the channel to write a message
|
||||||
|
* @param message the message to write to the channel
|
||||||
|
* @param remoteAddress the destination of the message.
|
||||||
|
* {@code null} to use the default remote address
|
||||||
|
*
|
||||||
|
* @return the {@link ChannelFuture} which will be notified when the
|
||||||
|
* write operation is done
|
||||||
|
*/
|
||||||
public static ChannelFuture write(Channel channel, Object message, SocketAddress remoteAddress) {
|
public static ChannelFuture write(Channel channel, Object message, SocketAddress remoteAddress) {
|
||||||
ChannelFuture future = future(channel);
|
ChannelFuture future = future(channel);
|
||||||
channel.getPipeline().sendDownstream(
|
channel.getPipeline().sendDownstream(
|
||||||
|
@ -475,6 +597,19 @@ public class Channels {
|
||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a {@code "write"} request to the previous
|
||||||
|
* {@link ChannelDownstreamHandler} in the {@link ChannelPipeline} where
|
||||||
|
* the specified {@link ChannelHandlerContext} belongs.
|
||||||
|
*
|
||||||
|
* @param ctx the context
|
||||||
|
* @param channel the channel to write a message
|
||||||
|
* @param future the future which will be notified when the write
|
||||||
|
* operation is done
|
||||||
|
* @param message the message to write to the channel
|
||||||
|
* @param remoteAddress the destination of the message.
|
||||||
|
* {@code null} to use the default remote address.
|
||||||
|
*/
|
||||||
public static void write(
|
public static void write(
|
||||||
ChannelHandlerContext ctx, Channel channel,
|
ChannelHandlerContext ctx, Channel channel,
|
||||||
ChannelFuture future, Object message, SocketAddress remoteAddress) {
|
ChannelFuture future, Object message, SocketAddress remoteAddress) {
|
||||||
|
@ -482,6 +617,17 @@ public class Channels {
|
||||||
new DefaultMessageEvent(channel, future, message, remoteAddress));
|
new DefaultMessageEvent(channel, future, message, remoteAddress));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a {@code "setInterestOps"} request to the last
|
||||||
|
* {@link ChannelDownstreamHandler} in the {@link ChannelPipeline} of
|
||||||
|
* the specified {@link Channel}.
|
||||||
|
*
|
||||||
|
* @param channel the channel to change its interestOps
|
||||||
|
* @param interestOps the new interestOps
|
||||||
|
*
|
||||||
|
* @return the {@link ChannelFuture} which will be notified when the
|
||||||
|
* interestOps is changed
|
||||||
|
*/
|
||||||
public static ChannelFuture setInterestOps(Channel channel, int interestOps) {
|
public static ChannelFuture setInterestOps(Channel channel, int interestOps) {
|
||||||
validateInterestOps(interestOps);
|
validateInterestOps(interestOps);
|
||||||
validateDownstreamInterestOps(channel, interestOps);
|
validateDownstreamInterestOps(channel, interestOps);
|
||||||
|
@ -492,6 +638,16 @@ public class Channels {
|
||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a {@code "setInterestOps"} request to the previous
|
||||||
|
* {@link ChannelDownstreamHandler} in the {@link ChannelPipeline} where
|
||||||
|
* the specified {@link ChannelHandlerContext} belongs.
|
||||||
|
*
|
||||||
|
* @param ctx the context
|
||||||
|
* @param channel the channel to change the interestOps
|
||||||
|
* @param future the future which will be notified when the interestOps is
|
||||||
|
* changed.
|
||||||
|
*/
|
||||||
public static void setInterestOps(
|
public static void setInterestOps(
|
||||||
ChannelHandlerContext ctx, Channel channel,
|
ChannelHandlerContext ctx, Channel channel,
|
||||||
ChannelFuture future, int interestOps) {
|
ChannelFuture future, int interestOps) {
|
||||||
|
@ -504,6 +660,15 @@ public class Channels {
|
||||||
Integer.valueOf(interestOps)));
|
Integer.valueOf(interestOps)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a {@code "disconnect"} request to the last
|
||||||
|
* {@link ChannelDownstreamHandler} in the {@link ChannelPipeline} of
|
||||||
|
* the specified {@link Channel}.
|
||||||
|
*
|
||||||
|
* @param channel the channel to disconnect
|
||||||
|
*
|
||||||
|
* @return the {@link ChannelFuture} which will be notified on disconnection
|
||||||
|
*/
|
||||||
public static ChannelFuture disconnect(Channel channel) {
|
public static ChannelFuture disconnect(Channel channel) {
|
||||||
ChannelFuture future = future(channel);
|
ChannelFuture future = future(channel);
|
||||||
channel.getPipeline().sendDownstream(new DefaultChannelStateEvent(
|
channel.getPipeline().sendDownstream(new DefaultChannelStateEvent(
|
||||||
|
@ -511,6 +676,15 @@ public class Channels {
|
||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a {@code "disconnect"} request to the previous
|
||||||
|
* {@link ChannelDownstreamHandler} in the {@link ChannelPipeline} where
|
||||||
|
* the specified {@link ChannelHandlerContext} belongs.
|
||||||
|
*
|
||||||
|
* @param ctx the context
|
||||||
|
* @param channel the channel to disconnect
|
||||||
|
* @param future the future which will be notified on disconnection
|
||||||
|
*/
|
||||||
public static void disconnect(
|
public static void disconnect(
|
||||||
ChannelHandlerContext ctx, Channel channel, ChannelFuture future) {
|
ChannelHandlerContext ctx, Channel channel, ChannelFuture future) {
|
||||||
ctx.sendDownstream(new DefaultChannelStateEvent(
|
ctx.sendDownstream(new DefaultChannelStateEvent(
|
||||||
|
@ -518,11 +692,13 @@ public class Channels {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a close request to the specified {@link Channel}.
|
* Sends a {@code "close"} request to the last
|
||||||
|
* {@link ChannelDownstreamHandler} in the {@link ChannelPipeline} of
|
||||||
|
* the specified {@link Channel}.
|
||||||
*
|
*
|
||||||
* @param channel the channel to close
|
* @param channel the channel to close
|
||||||
*
|
*
|
||||||
* @return the future which will be notified on closure
|
* @return the {@link ChannelFuture} which will be notified on closure
|
||||||
*/
|
*/
|
||||||
public static ChannelFuture close(Channel channel) {
|
public static ChannelFuture close(Channel channel) {
|
||||||
ChannelFuture future = future(channel);
|
ChannelFuture future = future(channel);
|
||||||
|
@ -532,12 +708,9 @@ public class Channels {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a close request to the specified {@link ChannelHandlerContext}.
|
* Sends a {@code "close"} request to the previous
|
||||||
* This method is a shortcut to the following code:
|
* {@link ChannelDownstreamHandler} in the {@link ChannelPipeline} where
|
||||||
* <pre>
|
* the specified {@link ChannelHandlerContext} belongs.
|
||||||
* ctx.sendDownstream(new DefaultChannelStateEvent(
|
|
||||||
* channel, future, ChannelState.OPEN, Boolean.FALSE));
|
|
||||||
* </pre>
|
|
||||||
*
|
*
|
||||||
* @param ctx the context
|
* @param ctx the context
|
||||||
* @param channel the channel to close
|
* @param channel the channel to close
|
||||||
|
|
Loading…
Reference in New Issue
Block a user