public class DelegatedIoAcceptor extends java.lang.Object implements IoAcceptor
IoAcceptor
that wraps the other IoAcceptor
.Modifier and Type | Field and Description |
---|---|
protected IoAcceptor |
delegate |
Modifier | Constructor and Description |
---|---|
protected |
DelegatedIoAcceptor()
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(IoServiceListener listener)
Adds an
IoServiceListener that listens any events related with
this service. |
void |
bind(java.net.SocketAddress address,
IoHandler handler)
Binds to the specified
address and handles incoming
connections with the specified handler . |
void |
bind(java.net.SocketAddress address,
IoHandler handler,
IoServiceConfig config)
Binds to the specified
address and handles incoming
connections with the specified handler . |
IoServiceConfig |
getDefaultConfig()
Returns the default configuration which is used when you didn't specify
any configuration.
|
DefaultIoFilterChainBuilder |
getFilterChain()
A shortcut for ( ( DefaultIoFilterChainBuilder )
IoService.getFilterChainBuilder() ). |
IoFilterChainBuilder |
getFilterChainBuilder()
Returns the global
IoFilterChainBuilder which will modify the
IoFilterChain of all IoSession s which is managed
by this service. |
java.util.Set<java.net.SocketAddress> |
getManagedServiceAddresses()
Returns all
SocketAddress es this service is managing. |
java.util.Set<IoSession> |
getManagedSessions(java.net.SocketAddress serviceAddress)
Returns all sessions with the specified remote or local address,
which are currently managed by this service.
|
protected void |
init(IoAcceptor delegate)
Sets the delegate.
|
boolean |
isManaged(java.net.SocketAddress address)
Returns true if this service is managing the specified serviceAddress.
|
IoSession |
newSession(java.net.SocketAddress remoteAddress,
java.net.SocketAddress localAddress)
(Optional) Returns an
IoSession that is bound to the specified
localAddress and remoteAddress which reuses
the localAddress that is already bound by IoAcceptor
via IoAcceptor.bind(SocketAddress, IoHandler) . |
void |
removeListener(IoServiceListener listener)
Removed an existing
IoServiceListener that listens any events
related with this service. |
void |
setFilterChainBuilder(IoFilterChainBuilder builder)
Sets the global
IoFilterChainBuilder which will modify the
IoFilterChain of all IoSession s which is managed
by this service. |
void |
unbind(java.net.SocketAddress address)
Unbinds from the specified
address and disconnects all clients
connected there. |
void |
unbindAll()
Unbinds all addresses which were bound by this acceptor.
|
protected IoAcceptor delegate
protected void init(IoAcceptor delegate)
public void bind(java.net.SocketAddress address, IoHandler handler) throws java.io.IOException
IoAcceptor
address
and handles incoming
connections with the specified handler
.bind
in interface IoAcceptor
java.io.IOException
- if failed to bindpublic void bind(java.net.SocketAddress address, IoHandler handler, IoServiceConfig config) throws java.io.IOException
IoAcceptor
address
and handles incoming
connections with the specified handler
.bind
in interface IoAcceptor
config
- the configurationjava.io.IOException
- if failed to bindpublic void unbind(java.net.SocketAddress address)
IoAcceptor
address
and disconnects all clients
connected there.unbind
in interface IoAcceptor
public void unbindAll()
IoAcceptor
unbindAll
in interface IoAcceptor
public boolean isManaged(java.net.SocketAddress address)
IoService
IoAcceptor
, serviceAddress is a bind address.
If this service is an IoConnector
, serviceAddress is a remote address.public java.util.Set<java.net.SocketAddress> getManagedServiceAddresses()
IoService
SocketAddress
es this service is managing.
If this service is an IoAcceptor
, a set of bind addresses will
be returned. If this service is an IoConnector
, a set of remote
addresses will be returned.getManagedServiceAddresses
in interface IoService
public java.util.Set<IoSession> getManagedSessions(java.net.SocketAddress serviceAddress)
IoService
IoAcceptor
will assume the specified address is a local
address, and IoConnector
will assume it's a remote address.getManagedSessions
in interface IoService
serviceAddress
- the address to return all sessions for.public IoSession newSession(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress)
IoAcceptor
IoSession
that is bound to the specified
localAddress and remoteAddress which reuses
the localAddress that is already bound by IoAcceptor
via IoAcceptor.bind(SocketAddress, IoHandler)
.
This operation is optional. Please throw UnsupportedOperationException
if the transport type doesn't support this operation. This operation is
usually implemented for connectionless transport types.
newSession
in interface IoAcceptor
public IoServiceConfig getDefaultConfig()
IoService
getDefaultConfig
in interface IoService
public IoFilterChainBuilder getFilterChainBuilder()
IoService
IoFilterChainBuilder
which will modify the
IoFilterChain
of all IoSession
s which is managed
by this service.
The default value is an empty DefaultIoFilterChainBuilder
.getFilterChainBuilder
in interface IoService
public void setFilterChainBuilder(IoFilterChainBuilder builder)
IoService
IoFilterChainBuilder
which will modify the
IoFilterChain
of all IoSession
s which is managed
by this service.
If you specify null this property will be set to
an empty DefaultIoFilterChainBuilder
.setFilterChainBuilder
in interface IoService
public DefaultIoFilterChainBuilder getFilterChain()
IoService
IoService.getFilterChainBuilder()
).
Please note that the returned object is not a real IoFilterChain
but a DefaultIoFilterChainBuilder
. Modifying the returned builder
won't affect the existing IoSession
s at all, because
IoFilterChainBuilder
s affect only newly created IoSession
s.getFilterChain
in interface IoService
public void addListener(IoServiceListener listener)
IoService
IoServiceListener
that listens any events related with
this service.addListener
in interface IoService
public void removeListener(IoServiceListener listener)
IoService
IoServiceListener
that listens any events
related with this service.removeListener
in interface IoService