Allow for method chaining
This commit is contained in:
parent
707f910d2b
commit
f98da73612
@ -311,4 +311,28 @@ public interface ChannelHandlerContext
|
|||||||
* Return the {@link MessageBuf} of the next {@link ChannelHandlerContext}.
|
* Return the {@link MessageBuf} of the next {@link ChannelHandlerContext}.
|
||||||
*/
|
*/
|
||||||
MessageBuf<Object> nextOutboundMessageBuffer();
|
MessageBuf<Object> nextOutboundMessageBuffer();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
ChannelHandlerContext fireChannelRegistered();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
ChannelHandlerContext fireChannelUnregistered();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
ChannelHandlerContext fireChannelActive();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
ChannelHandlerContext fireChannelInactive();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
ChannelHandlerContext fireExceptionCaught(Throwable cause);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
ChannelHandlerContext fireUserEventTriggered(Object event);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
ChannelHandlerContext fireInboundBufferUpdated();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
ChannelHandlerContext fireChannelReadSuspended();
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ interface ChannelInboundInvoker {
|
|||||||
* called of the next {@link ChannelInboundHandler} contained in the {@link ChannelPipeline} of the
|
* called of the next {@link ChannelInboundHandler} contained in the {@link ChannelPipeline} of the
|
||||||
* {@link Channel}.
|
* {@link Channel}.
|
||||||
*/
|
*/
|
||||||
void fireChannelRegistered();
|
ChannelInboundInvoker fireChannelRegistered();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link Channel} was unregistered from its {@link EventLoop}.
|
* A {@link Channel} was unregistered from its {@link EventLoop}.
|
||||||
@ -37,7 +37,7 @@ interface ChannelInboundInvoker {
|
|||||||
* called of the next {@link ChannelInboundHandler} contained in the {@link ChannelPipeline} of the
|
* called of the next {@link ChannelInboundHandler} contained in the {@link ChannelPipeline} of the
|
||||||
* {@link Channel}.
|
* {@link Channel}.
|
||||||
*/
|
*/
|
||||||
void fireChannelUnregistered();
|
ChannelInboundInvoker fireChannelUnregistered();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link Channel} is active now, which means it is connected.
|
* A {@link Channel} is active now, which means it is connected.
|
||||||
@ -46,7 +46,7 @@ interface ChannelInboundInvoker {
|
|||||||
* called of the next {@link ChannelInboundHandler} contained in the {@link ChannelPipeline} of the
|
* called of the next {@link ChannelInboundHandler} contained in the {@link ChannelPipeline} of the
|
||||||
* {@link Channel}.
|
* {@link Channel}.
|
||||||
*/
|
*/
|
||||||
void fireChannelActive();
|
ChannelInboundInvoker fireChannelActive();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link Channel} is inactive now, which means it is closed.
|
* A {@link Channel} is inactive now, which means it is closed.
|
||||||
@ -55,7 +55,7 @@ interface ChannelInboundInvoker {
|
|||||||
* called of the next {@link ChannelInboundHandler} contained in the {@link ChannelPipeline} of the
|
* called of the next {@link ChannelInboundHandler} contained in the {@link ChannelPipeline} of the
|
||||||
* {@link Channel}.
|
* {@link Channel}.
|
||||||
*/
|
*/
|
||||||
void fireChannelInactive();
|
ChannelInboundInvoker fireChannelInactive();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link Channel} received an {@link Throwable} in one of its inbound operations.
|
* A {@link Channel} received an {@link Throwable} in one of its inbound operations.
|
||||||
@ -64,7 +64,7 @@ interface ChannelInboundInvoker {
|
|||||||
* method called of the next {@link ChannelInboundHandler} contained in the {@link ChannelPipeline} of the
|
* method called of the next {@link ChannelInboundHandler} contained in the {@link ChannelPipeline} of the
|
||||||
* {@link Channel}.
|
* {@link Channel}.
|
||||||
*/
|
*/
|
||||||
void fireExceptionCaught(Throwable cause);
|
ChannelInboundInvoker fireExceptionCaught(Throwable cause);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link Channel} received an user defined event.
|
* A {@link Channel} received an user defined event.
|
||||||
@ -73,7 +73,7 @@ interface ChannelInboundInvoker {
|
|||||||
* method called of the next {@link ChannelInboundHandler} contained in the {@link ChannelPipeline} of the
|
* method called of the next {@link ChannelInboundHandler} contained in the {@link ChannelPipeline} of the
|
||||||
* {@link Channel}.
|
* {@link Channel}.
|
||||||
*/
|
*/
|
||||||
void fireUserEventTriggered(Object event);
|
ChannelInboundInvoker fireUserEventTriggered(Object event);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link Channel} received bytes which are now ready to read from its inbound buffer.
|
* A {@link Channel} received bytes which are now ready to read from its inbound buffer.
|
||||||
@ -82,11 +82,11 @@ interface ChannelInboundInvoker {
|
|||||||
* method called of the next {@link ChannelInboundHandler} contained in the {@link ChannelPipeline} of the
|
* method called of the next {@link ChannelInboundHandler} contained in the {@link ChannelPipeline} of the
|
||||||
* {@link Channel}.
|
* {@link Channel}.
|
||||||
*/
|
*/
|
||||||
void fireInboundBufferUpdated();
|
ChannelInboundInvoker fireInboundBufferUpdated();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Triggers an {@link ChannelStateHandler#channelReadSuspended(ChannelHandlerContext) channelReadSuspended}
|
* Triggers an {@link ChannelStateHandler#channelReadSuspended(ChannelHandlerContext) channelReadSuspended}
|
||||||
* event to the next {@link ChannelStateHandler} in the {@link ChannelPipeline}.
|
* event to the next {@link ChannelStateHandler} in the {@link ChannelPipeline}.
|
||||||
*/
|
*/
|
||||||
void fireChannelReadSuspended();
|
ChannelInboundInvoker fireChannelReadSuspended();
|
||||||
}
|
}
|
||||||
|
@ -735,4 +735,28 @@ public interface ChannelPipeline extends ChannelInboundInvoker, ChannelOutboundI
|
|||||||
* handler names and whose values are handlers.
|
* handler names and whose values are handlers.
|
||||||
*/
|
*/
|
||||||
Map<String, ChannelHandler> toMap();
|
Map<String, ChannelHandler> toMap();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
ChannelPipeline fireChannelRegistered();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
ChannelPipeline fireChannelUnregistered();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
ChannelPipeline fireChannelActive();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
ChannelPipeline fireChannelInactive();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
ChannelPipeline fireExceptionCaught(Throwable cause);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
ChannelPipeline fireUserEventTriggered(Object event);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
ChannelPipeline fireInboundBufferUpdated();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
ChannelPipeline fireChannelReadSuspended();
|
||||||
}
|
}
|
||||||
|
@ -807,7 +807,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireChannelRegistered() {
|
public ChannelHandlerContext fireChannelRegistered() {
|
||||||
lazyInitHeadHandler();
|
lazyInitHeadHandler();
|
||||||
final DefaultChannelHandlerContext next = findContextInbound();
|
final DefaultChannelHandlerContext next = findContextInbound();
|
||||||
EventExecutor executor = next.executor();
|
EventExecutor executor = next.executor();
|
||||||
@ -825,6 +825,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
|||||||
}
|
}
|
||||||
executor.execute(task);
|
executor.execute(task);
|
||||||
}
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void invokeChannelRegistered() {
|
private void invokeChannelRegistered() {
|
||||||
@ -838,7 +839,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireChannelUnregistered() {
|
public ChannelHandlerContext fireChannelUnregistered() {
|
||||||
final DefaultChannelHandlerContext next = findContextInbound();
|
final DefaultChannelHandlerContext next = findContextInbound();
|
||||||
EventExecutor executor = next.executor();
|
EventExecutor executor = next.executor();
|
||||||
if (prev != null && executor.inEventLoop()) {
|
if (prev != null && executor.inEventLoop()) {
|
||||||
@ -855,6 +856,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
|||||||
}
|
}
|
||||||
executor.execute(task);
|
executor.execute(task);
|
||||||
}
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void invokeChannelUnregistered() {
|
private void invokeChannelUnregistered() {
|
||||||
@ -866,7 +868,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireChannelActive() {
|
public ChannelHandlerContext fireChannelActive() {
|
||||||
lazyInitHeadHandler();
|
lazyInitHeadHandler();
|
||||||
final DefaultChannelHandlerContext next = findContextInbound();
|
final DefaultChannelHandlerContext next = findContextInbound();
|
||||||
EventExecutor executor = next.executor();
|
EventExecutor executor = next.executor();
|
||||||
@ -884,6 +886,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
|||||||
}
|
}
|
||||||
executor.execute(task);
|
executor.execute(task);
|
||||||
}
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void invokeChannelActive() {
|
private void invokeChannelActive() {
|
||||||
@ -897,7 +900,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireChannelInactive() {
|
public ChannelHandlerContext fireChannelInactive() {
|
||||||
final DefaultChannelHandlerContext next = findContextInbound();
|
final DefaultChannelHandlerContext next = findContextInbound();
|
||||||
EventExecutor executor = next.executor();
|
EventExecutor executor = next.executor();
|
||||||
if (prev != null && executor.inEventLoop()) {
|
if (prev != null && executor.inEventLoop()) {
|
||||||
@ -914,6 +917,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
|||||||
}
|
}
|
||||||
executor.execute(task);
|
executor.execute(task);
|
||||||
}
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void invokeChannelInactive() {
|
private void invokeChannelInactive() {
|
||||||
@ -927,7 +931,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireExceptionCaught(final Throwable cause) {
|
public ChannelHandlerContext fireExceptionCaught(final Throwable cause) {
|
||||||
if (cause == null) {
|
if (cause == null) {
|
||||||
throw new NullPointerException("cause");
|
throw new NullPointerException("cause");
|
||||||
}
|
}
|
||||||
@ -951,6 +955,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void invokeExceptionCaught(Throwable cause) {
|
private void invokeExceptionCaught(Throwable cause) {
|
||||||
@ -968,7 +973,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireUserEventTriggered(final Object event) {
|
public ChannelHandlerContext fireUserEventTriggered(final Object event) {
|
||||||
if (event == null) {
|
if (event == null) {
|
||||||
throw new NullPointerException("event");
|
throw new NullPointerException("event");
|
||||||
}
|
}
|
||||||
@ -985,6 +990,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void invokeUserEventTriggered(Object event) {
|
private void invokeUserEventTriggered(Object event) {
|
||||||
@ -998,7 +1004,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireInboundBufferUpdated() {
|
public ChannelHandlerContext fireInboundBufferUpdated() {
|
||||||
EventExecutor executor = executor();
|
EventExecutor executor = executor();
|
||||||
if (executor.inEventLoop()) {
|
if (executor.inEventLoop()) {
|
||||||
fireInboundBufferUpdated0();
|
fireInboundBufferUpdated0();
|
||||||
@ -1014,6 +1020,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
|||||||
}
|
}
|
||||||
executor.execute(task);
|
executor.execute(task);
|
||||||
}
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fireInboundBufferUpdated0() {
|
private void fireInboundBufferUpdated0() {
|
||||||
@ -1060,7 +1067,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireChannelReadSuspended() {
|
public ChannelHandlerContext fireChannelReadSuspended() {
|
||||||
final DefaultChannelHandlerContext next = findContextInbound();
|
final DefaultChannelHandlerContext next = findContextInbound();
|
||||||
EventExecutor executor = next.executor();
|
EventExecutor executor = next.executor();
|
||||||
if (executor.inEventLoop()) {
|
if (executor.inEventLoop()) {
|
||||||
@ -1077,6 +1084,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
|||||||
}
|
}
|
||||||
executor.execute(task);
|
executor.execute(task);
|
||||||
}
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void invokeChannelReadSuspended() {
|
private void invokeChannelReadSuspended() {
|
||||||
|
@ -846,22 +846,24 @@ final class DefaultChannelPipeline implements ChannelPipeline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireChannelRegistered() {
|
public ChannelPipeline fireChannelRegistered() {
|
||||||
head.fireChannelRegistered();
|
head.fireChannelRegistered();
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireChannelUnregistered() {
|
public ChannelPipeline fireChannelUnregistered() {
|
||||||
head.fireChannelUnregistered();
|
head.fireChannelUnregistered();
|
||||||
|
|
||||||
// Free all buffers if channel is closed and unregistered.
|
// Free all buffers if channel is closed and unregistered.
|
||||||
if (!channel.isOpen()) {
|
if (!channel.isOpen()) {
|
||||||
head.invokeFreeInboundBuffer();
|
head.invokeFreeInboundBuffer();
|
||||||
}
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireChannelActive() {
|
public ChannelPipeline fireChannelActive() {
|
||||||
firedChannelActive = true;
|
firedChannelActive = true;
|
||||||
head.fireChannelActive();
|
head.fireChannelActive();
|
||||||
|
|
||||||
@ -873,42 +875,48 @@ final class DefaultChannelPipeline implements ChannelPipeline {
|
|||||||
fireInboundBufferUpdatedOnActivation = false;
|
fireInboundBufferUpdatedOnActivation = false;
|
||||||
head.fireInboundBufferUpdated();
|
head.fireInboundBufferUpdated();
|
||||||
}
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireChannelInactive() {
|
public ChannelPipeline fireChannelInactive() {
|
||||||
// Some implementations such as EmbeddedChannel can trigger inboundBufferUpdated()
|
// Some implementations such as EmbeddedChannel can trigger inboundBufferUpdated()
|
||||||
// after deactivation, so it's safe not to revert the firedChannelActive flag here.
|
// after deactivation, so it's safe not to revert the firedChannelActive flag here.
|
||||||
// Also, all known transports never get re-activated.
|
// Also, all known transports never get re-activated.
|
||||||
//firedChannelActive = false;
|
//firedChannelActive = false;
|
||||||
head.fireChannelInactive();
|
head.fireChannelInactive();
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireExceptionCaught(Throwable cause) {
|
public ChannelPipeline fireExceptionCaught(Throwable cause) {
|
||||||
head.fireExceptionCaught(cause);
|
head.fireExceptionCaught(cause);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireUserEventTriggered(Object event) {
|
public ChannelPipeline fireUserEventTriggered(Object event) {
|
||||||
head.fireUserEventTriggered(event);
|
head.fireUserEventTriggered(event);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireInboundBufferUpdated() {
|
public ChannelPipeline fireInboundBufferUpdated() {
|
||||||
if (!firedChannelActive) {
|
if (!firedChannelActive) {
|
||||||
fireInboundBufferUpdatedOnActivation = true;
|
fireInboundBufferUpdatedOnActivation = true;
|
||||||
return;
|
return this;
|
||||||
}
|
}
|
||||||
head.fireInboundBufferUpdated();
|
head.fireInboundBufferUpdated();
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireChannelReadSuspended() {
|
public ChannelPipeline fireChannelReadSuspended() {
|
||||||
head.fireChannelReadSuspended();
|
head.fireChannelReadSuspended();
|
||||||
if (channel.config().isAutoRead()) {
|
if (channel.config().isAutoRead()) {
|
||||||
read();
|
read();
|
||||||
}
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user