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}.
|
||||
*/
|
||||
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
|
||||
* {@link Channel}.
|
||||
*/
|
||||
void fireChannelRegistered();
|
||||
ChannelInboundInvoker fireChannelRegistered();
|
||||
|
||||
/**
|
||||
* 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
|
||||
* {@link Channel}.
|
||||
*/
|
||||
void fireChannelUnregistered();
|
||||
ChannelInboundInvoker fireChannelUnregistered();
|
||||
|
||||
/**
|
||||
* 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
|
||||
* {@link Channel}.
|
||||
*/
|
||||
void fireChannelActive();
|
||||
ChannelInboundInvoker fireChannelActive();
|
||||
|
||||
/**
|
||||
* 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
|
||||
* {@link Channel}.
|
||||
*/
|
||||
void fireChannelInactive();
|
||||
ChannelInboundInvoker fireChannelInactive();
|
||||
|
||||
/**
|
||||
* 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
|
||||
* {@link Channel}.
|
||||
*/
|
||||
void fireExceptionCaught(Throwable cause);
|
||||
ChannelInboundInvoker fireExceptionCaught(Throwable cause);
|
||||
|
||||
/**
|
||||
* 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
|
||||
* {@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.
|
||||
@ -82,11 +82,11 @@ interface ChannelInboundInvoker {
|
||||
* method called of the next {@link ChannelInboundHandler} contained in the {@link ChannelPipeline} of the
|
||||
* {@link Channel}.
|
||||
*/
|
||||
void fireInboundBufferUpdated();
|
||||
ChannelInboundInvoker fireInboundBufferUpdated();
|
||||
|
||||
/**
|
||||
* Triggers an {@link ChannelStateHandler#channelReadSuspended(ChannelHandlerContext) channelReadSuspended}
|
||||
* 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.
|
||||
*/
|
||||
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
|
||||
public void fireChannelRegistered() {
|
||||
public ChannelHandlerContext fireChannelRegistered() {
|
||||
lazyInitHeadHandler();
|
||||
final DefaultChannelHandlerContext next = findContextInbound();
|
||||
EventExecutor executor = next.executor();
|
||||
@ -825,6 +825,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
||||
}
|
||||
executor.execute(task);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
private void invokeChannelRegistered() {
|
||||
@ -838,7 +839,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireChannelUnregistered() {
|
||||
public ChannelHandlerContext fireChannelUnregistered() {
|
||||
final DefaultChannelHandlerContext next = findContextInbound();
|
||||
EventExecutor executor = next.executor();
|
||||
if (prev != null && executor.inEventLoop()) {
|
||||
@ -855,6 +856,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
||||
}
|
||||
executor.execute(task);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
private void invokeChannelUnregistered() {
|
||||
@ -866,7 +868,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireChannelActive() {
|
||||
public ChannelHandlerContext fireChannelActive() {
|
||||
lazyInitHeadHandler();
|
||||
final DefaultChannelHandlerContext next = findContextInbound();
|
||||
EventExecutor executor = next.executor();
|
||||
@ -884,6 +886,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
||||
}
|
||||
executor.execute(task);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
private void invokeChannelActive() {
|
||||
@ -897,7 +900,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireChannelInactive() {
|
||||
public ChannelHandlerContext fireChannelInactive() {
|
||||
final DefaultChannelHandlerContext next = findContextInbound();
|
||||
EventExecutor executor = next.executor();
|
||||
if (prev != null && executor.inEventLoop()) {
|
||||
@ -914,6 +917,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
||||
}
|
||||
executor.execute(task);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
private void invokeChannelInactive() {
|
||||
@ -927,7 +931,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireExceptionCaught(final Throwable cause) {
|
||||
public ChannelHandlerContext fireExceptionCaught(final Throwable cause) {
|
||||
if (cause == null) {
|
||||
throw new NullPointerException("cause");
|
||||
}
|
||||
@ -951,6 +955,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
private void invokeExceptionCaught(Throwable cause) {
|
||||
@ -968,7 +973,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireUserEventTriggered(final Object event) {
|
||||
public ChannelHandlerContext fireUserEventTriggered(final Object event) {
|
||||
if (event == null) {
|
||||
throw new NullPointerException("event");
|
||||
}
|
||||
@ -985,6 +990,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
||||
}
|
||||
});
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
private void invokeUserEventTriggered(Object event) {
|
||||
@ -998,7 +1004,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireInboundBufferUpdated() {
|
||||
public ChannelHandlerContext fireInboundBufferUpdated() {
|
||||
EventExecutor executor = executor();
|
||||
if (executor.inEventLoop()) {
|
||||
fireInboundBufferUpdated0();
|
||||
@ -1014,6 +1020,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
||||
}
|
||||
executor.execute(task);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
private void fireInboundBufferUpdated0() {
|
||||
@ -1060,7 +1067,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireChannelReadSuspended() {
|
||||
public ChannelHandlerContext fireChannelReadSuspended() {
|
||||
final DefaultChannelHandlerContext next = findContextInbound();
|
||||
EventExecutor executor = next.executor();
|
||||
if (executor.inEventLoop()) {
|
||||
@ -1077,6 +1084,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
||||
}
|
||||
executor.execute(task);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
private void invokeChannelReadSuspended() {
|
||||
|
@ -846,22 +846,24 @@ final class DefaultChannelPipeline implements ChannelPipeline {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireChannelRegistered() {
|
||||
public ChannelPipeline fireChannelRegistered() {
|
||||
head.fireChannelRegistered();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireChannelUnregistered() {
|
||||
public ChannelPipeline fireChannelUnregistered() {
|
||||
head.fireChannelUnregistered();
|
||||
|
||||
// Free all buffers if channel is closed and unregistered.
|
||||
if (!channel.isOpen()) {
|
||||
head.invokeFreeInboundBuffer();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireChannelActive() {
|
||||
public ChannelPipeline fireChannelActive() {
|
||||
firedChannelActive = true;
|
||||
head.fireChannelActive();
|
||||
|
||||
@ -873,42 +875,48 @@ final class DefaultChannelPipeline implements ChannelPipeline {
|
||||
fireInboundBufferUpdatedOnActivation = false;
|
||||
head.fireInboundBufferUpdated();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireChannelInactive() {
|
||||
public ChannelPipeline fireChannelInactive() {
|
||||
// Some implementations such as EmbeddedChannel can trigger inboundBufferUpdated()
|
||||
// after deactivation, so it's safe not to revert the firedChannelActive flag here.
|
||||
// Also, all known transports never get re-activated.
|
||||
//firedChannelActive = false;
|
||||
head.fireChannelInactive();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireExceptionCaught(Throwable cause) {
|
||||
public ChannelPipeline fireExceptionCaught(Throwable cause) {
|
||||
head.fireExceptionCaught(cause);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireUserEventTriggered(Object event) {
|
||||
public ChannelPipeline fireUserEventTriggered(Object event) {
|
||||
head.fireUserEventTriggered(event);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireInboundBufferUpdated() {
|
||||
public ChannelPipeline fireInboundBufferUpdated() {
|
||||
if (!firedChannelActive) {
|
||||
fireInboundBufferUpdatedOnActivation = true;
|
||||
return;
|
||||
return this;
|
||||
}
|
||||
head.fireInboundBufferUpdated();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireChannelReadSuspended() {
|
||||
public ChannelPipeline fireChannelReadSuspended() {
|
||||
head.fireChannelReadSuspended();
|
||||
if (channel.config().isAutoRead()) {
|
||||
read();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user