Top Fields Constructors Methods
io.vertx.core.net.impl

public final Class VertxHandler<C extends ConnectionBase>

extends ChannelDuplexHandler
Class Inheritance
Imports
io.netty.buffer.ByteBuf, .CompositeByteBuf, .PooledByteBufAllocator, .Unpooled, io.netty.channel.ChannelDuplexHandler, .ChannelHandlerContext, .ChannelPromise, io.netty.handler.timeout.IdleStateEvent, io.vertx.core.Handler, io.vertx.core.buffer.impl.VertxByteBufAllocator, java.util.function.Function

Author
Norman Maurer

Field Summary

Modifier and TypeField and Description
private Handler<C>
private C
private final Function<ChannelHandlerContext, C>
private Handler<C>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public VertxHandler<C>

Returns:

this
addHandler
(Handler<C>
the handler to be notified
handler
)

Set an handler to be called when the connection is set on this handler.

public void
public void
public void
public void
public void
close(ChannelHandlerContext
the ChannelHandlerContext for which the close operation is made
ctx
,
ChannelPromise
the ChannelPromise to notify once the operation completes
promise
)

Overrides io.netty.channel.ChannelDuplexHandler.close.

Implements io.netty.channel.ChannelOutboundHandler.close.

Calls ChannelHandlerContext#close(ChannelPromise) to forward to the next ChannelOutboundHandler in the ChannelPipeline.

public static <C extends ConnectionBase> VertxHandler<C>
create(Function<ChannelHandlerContext, C> connectionFactory)

public void
public C
public void
handlerAdded(ChannelHandlerContext ctx)

Overrides io.netty.channel.ChannelHandlerAdapter.handlerAdded.

Implements io.netty.channel.ChannelHandler.handlerAdded.

Gets called after the ChannelHandler was added to the actual context and it's ready to handle events.

public void
handlerRemoved(ChannelHandlerContext ctx)

Overrides io.netty.channel.ChannelHandlerAdapter.handlerRemoved.

Implements io.netty.channel.ChannelHandler.handlerRemoved.

Gets called after the ChannelHandler was removed from the actual context and it doesn't handle events anymore.

public VertxHandler<C>

Returns:

this
removeHandler
(Handler<C>
the handler to be notified
handler
)

Set an handler to be called when the connection is unset from this handler.

public static ByteBuf

Returns:

a safe buffer to use
safeBuffer
(ByteBuf
the buffer
buf
)

Copy and release the buf when necessary.

private void
setConnection(C
the connection
connection
)

Set the connection, this is called when the channel is added to the pipeline.

public void
Inherited from io.netty.channel.ChannelDuplexHandler:
bindconnectderegisterdisconnectflushreadwrite

Field Detail

addHandlerback to summary
private Handler<C> addHandler
connback to summary
private C conn
connectionFactoryback to summary
private final Function<ChannelHandlerContext, C> connectionFactory
removeHandlerback to summary
private Handler<C> removeHandler

Constructor Detail

VertxHandlerback to summary
private VertxHandler(Function<ChannelHandlerContext, C> connectionFactory)

Method Detail

addHandlerback to summary
public VertxHandler<C> addHandler(Handler<C> handler)

Set an handler to be called when the connection is set on this handler.

Parameters
handler:Handler<C>

the handler to be notified

Returns:VertxHandler<C>

this

channelInactiveback to summary
public void channelInactive(ChannelHandlerContext chctx)

Overrides io.netty.channel.ChannelInboundHandlerAdapter.channelInactive.

Implements io.netty.channel.ChannelInboundHandler.channelInactive.

Doc from io.netty.channel.ChannelInboundHandlerAdapter.channelInactive.

Calls ChannelHandlerContext#fireChannelInactive() to forward to the next ChannelInboundHandler in the ChannelPipeline. Sub-classes may override this method to change behavior.

Annotations
@Override
channelReadback to summary
public void channelRead(ChannelHandlerContext chctx, Object msg)

Overrides io.netty.channel.ChannelInboundHandlerAdapter.channelRead.

Implements io.netty.channel.ChannelInboundHandler.channelRead.

Doc from io.netty.channel.ChannelInboundHandlerAdapter.channelRead.

Calls ChannelHandlerContext#fireChannelRead(Object) to forward to the next ChannelInboundHandler in the ChannelPipeline. Sub-classes may override this method to change behavior.

Annotations
@Override
channelReadCompleteback to summary
public void channelReadComplete(ChannelHandlerContext ctx)

Overrides io.netty.channel.ChannelInboundHandlerAdapter.channelReadComplete.

Implements io.netty.channel.ChannelInboundHandler.channelReadComplete.

Doc from io.netty.channel.ChannelInboundHandlerAdapter.channelReadComplete.

Calls ChannelHandlerContext#fireChannelReadComplete() to forward to the next ChannelInboundHandler in the ChannelPipeline. Sub-classes may override this method to change behavior.

Annotations
@Override
channelWritabilityChangedback to summary
public void channelWritabilityChanged(ChannelHandlerContext ctx)

Overrides io.netty.channel.ChannelInboundHandlerAdapter.channelWritabilityChanged.

Implements io.netty.channel.ChannelInboundHandler.channelWritabilityChanged.

Doc from io.netty.channel.ChannelInboundHandlerAdapter.channelWritabilityChanged.

Calls ChannelHandlerContext#fireChannelWritabilityChanged() to forward to the next ChannelInboundHandler in the ChannelPipeline. Sub-classes may override this method to change behavior.

Annotations
@Override
closeback to summary
public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception

Overrides io.netty.channel.ChannelDuplexHandler.close.

Implements io.netty.channel.ChannelOutboundHandler.close.

Doc from io.netty.channel.ChannelDuplexHandler.close.

Calls ChannelHandlerContext#close(ChannelPromise) to forward to the next ChannelOutboundHandler in the ChannelPipeline. Sub-classes may override this method to change behavior.

Parameters
ctx:ChannelHandlerContext

Doc from io.netty.channel.ChannelOutboundHandler.close.

the ChannelHandlerContext for which the close operation is made

promise:ChannelPromise

Doc from io.netty.channel.ChannelOutboundHandler.close.

the ChannelPromise to notify once the operation completes

Annotations
@Override
Exceptions
Exception:

Doc from io.netty.channel.ChannelOutboundHandler.close.

thrown if an error occurs

createback to summary
public static <C extends ConnectionBase> VertxHandler<C> create(Function<ChannelHandlerContext, C> connectionFactory)
exceptionCaughtback to summary
public void exceptionCaught(ChannelHandlerContext chctx, final Throwable t)

Overrides io.netty.channel.ChannelInboundHandlerAdapter.exceptionCaught.

Implements io.netty.channel.ChannelHandler.exceptionCaught, io.netty.channel.ChannelInboundHandler.exceptionCaught.

Doc from io.netty.channel.ChannelHandler.exceptionCaught.

Gets called if a Throwable was thrown.

Annotations
@Override
getConnectionback to summary
public C getConnection()
handlerAddedback to summary
public void handlerAdded(ChannelHandlerContext ctx)

Overrides io.netty.channel.ChannelHandlerAdapter.handlerAdded.

Implements io.netty.channel.ChannelHandler.handlerAdded.

Doc from io.netty.channel.ChannelHandler.handlerAdded.

Gets called after the ChannelHandler was added to the actual context and it's ready to handle events.

Annotations
@Override
handlerRemovedback to summary
public void handlerRemoved(ChannelHandlerContext ctx) throws Exception

Overrides io.netty.channel.ChannelHandlerAdapter.handlerRemoved.

Implements io.netty.channel.ChannelHandler.handlerRemoved.

Doc from io.netty.channel.ChannelHandler.handlerRemoved.

Gets called after the ChannelHandler was removed from the actual context and it doesn't handle events anymore.

Annotations
@Override
removeHandlerback to summary
public VertxHandler<C> removeHandler(Handler<C> handler)

Set an handler to be called when the connection is unset from this handler.

Parameters
handler:Handler<C>

the handler to be notified

Returns:VertxHandler<C>

this

safeBufferback to summary
public static ByteBuf safeBuffer(ByteBuf buf)

Copy and release the buf when necessary.

This methods assuming the has full ownership of the buffer.

This method assumes that pooled buffers are allocated by PooledByteBufAllocator

The returned buffer will not need to be released and can be wrapped by a io.vertx.core.buffer.Buffer.

Parameters
buf:ByteBuf

the buffer

Returns:ByteBuf

a safe buffer to use

setConnectionback to summary
private void setConnection(C connection)

Set the connection, this is called when the channel is added to the pipeline.

Parameters
connection:C

the connection

userEventTriggeredback to summary
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception

Overrides io.netty.channel.ChannelInboundHandlerAdapter.userEventTriggered.

Implements io.netty.channel.ChannelInboundHandler.userEventTriggered.

Doc from io.netty.channel.ChannelInboundHandlerAdapter.userEventTriggered.

Calls ChannelHandlerContext#fireUserEventTriggered(Object) to forward to the next ChannelInboundHandler in the ChannelPipeline. Sub-classes may override this method to change behavior.

Annotations
@Override