Package io.netty.handler.address
Class DynamicAddressConnectHandler
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelOutboundHandlerAdapter
-
- io.netty.handler.address.DynamicAddressConnectHandler
-
- All Implemented Interfaces:
ChannelHandler,ChannelOutboundHandler
public abstract class DynamicAddressConnectHandler extends ChannelOutboundHandlerAdapter
ChannelOutboundHandlerimplementation which allows to dynamically replace the usedremoteAddressand / orlocalAddresswhen making a connection attempt.This can be useful to for example bind to a specific
NetworkInterfacebased on theremoteAddress.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
-
Constructor Summary
Constructors Constructor Description DynamicAddressConnectHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconnect(ChannelHandlerContext ctx, java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress, ChannelPromise promise)CallsChannelOutboundInvoker.connect(SocketAddress, SocketAddress, ChannelPromise)to forward to the nextChannelOutboundHandlerin theChannelPipeline.protected java.net.SocketAddresslocalAddress(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress)Returns the localSocketAddressto use forChannelOutboundInvoker.connect(SocketAddress, SocketAddress)based on the originalremoteAddressandlocalAddress.protected java.net.SocketAddressremoteAddress(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress)Returns the remoteSocketAddressto use forChannelOutboundInvoker.connect(SocketAddress, SocketAddress)based on the originalremoteAddressandlocalAddress.-
Methods inherited from class io.netty.channel.ChannelOutboundHandlerAdapter
bind, close, deregister, disconnect, flush, read, write
-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, exceptionCaught, handlerAdded, handlerRemoved, isSharable
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty.channel.ChannelHandler
exceptionCaught, handlerAdded, handlerRemoved
-
-
-
-
Method Detail
-
connect
public final void connect(ChannelHandlerContext ctx, java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress, ChannelPromise promise)
Description copied from class:ChannelOutboundHandlerAdapterCallsChannelOutboundInvoker.connect(SocketAddress, SocketAddress, ChannelPromise)to forward to the nextChannelOutboundHandlerin theChannelPipeline. Sub-classes may override this method to change behavior.- Specified by:
connectin interfaceChannelOutboundHandler- Overrides:
connectin classChannelOutboundHandlerAdapter- Parameters:
ctx- theChannelHandlerContextfor which the connect operation is maderemoteAddress- theSocketAddressto which it should connectlocalAddress- theSocketAddresswhich is used as source on connectpromise- theChannelPromiseto notify once the operation completes
-
localAddress
protected java.net.SocketAddress localAddress(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress) throws java.lang.ExceptionReturns the localSocketAddressto use forChannelOutboundInvoker.connect(SocketAddress, SocketAddress)based on the originalremoteAddressandlocalAddress. By default, this method returns the givenlocalAddress.- Throws:
java.lang.Exception
-
remoteAddress
protected java.net.SocketAddress remoteAddress(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress) throws java.lang.ExceptionReturns the remoteSocketAddressto use forChannelOutboundInvoker.connect(SocketAddress, SocketAddress)based on the originalremoteAddressandlocalAddress. By default, this method returns the givenremoteAddress.- Throws:
java.lang.Exception
-
-