public abstract class AbstractIoAcceptor extends AbstractIoService implements IoAcceptor
IoAcceptor
.限定符和类型 | 类和说明 |
---|---|
static class |
AbstractIoAcceptor.AcceptorOperationFuture |
AbstractIoService.ServiceOperationFuture
限定符和类型 | 字段和说明 |
---|---|
protected java.lang.Object |
bindLock
The lock object which is acquired while bind or unbind operation is performed.
|
disposalLock, sessionConfig
限定符 | 构造器和说明 |
---|---|
protected |
AbstractIoAcceptor(IoSessionConfig sessionConfig,
java.util.concurrent.Executor executor)
Constructor for
AbstractIoAcceptor . |
限定符和类型 | 方法和说明 |
---|---|
void |
bind()
Binds to the default local address(es) and start to accept incoming
connections.
|
void |
bind(java.lang.Iterable<? extends java.net.SocketAddress> localAddresses)
Binds to the specified local addresses and start to accept incoming
connections.
|
void |
bind(java.net.SocketAddress... addresses)
Binds to the specified local addresses and start to accept incoming
connections.
|
void |
bind(java.net.SocketAddress localAddress)
Binds to the specified local address and start to accept incoming
connections.
|
void |
bind(java.net.SocketAddress firstLocalAddress,
java.net.SocketAddress... addresses)
Binds to the specified local addresses and start to accept incoming
connections.
|
protected abstract java.util.Set<java.net.SocketAddress> |
bindInternal(java.util.List<? extends java.net.SocketAddress> localAddresses)
Starts the acceptor, and register the given addresses
|
java.net.SocketAddress |
getDefaultLocalAddress()
Returns the default local address to bind when no argument is specified
in
IoAcceptor.bind() method. |
java.util.List<java.net.SocketAddress> |
getDefaultLocalAddresses()
Returns a
List of the default local addresses to bind when no
argument is specified in IoAcceptor.bind() method. |
java.net.SocketAddress |
getLocalAddress()
Returns the local address which is bound currently.
|
java.util.Set<java.net.SocketAddress> |
getLocalAddresses()
Returns a
Set of the local addresses which are bound currently. |
boolean |
isCloseOnDeactivation()
Returns true if and only if all clients are closed when this
acceptor unbinds from all the related local address (i.e. when the
service is deactivated).
|
void |
setCloseOnDeactivation(boolean disconnectClientsOnUnbind)
Sets whether all client sessions are closed when this acceptor unbinds
from all the related local addresses (i.e. when the service is
deactivated).
|
void |
setDefaultLocalAddress(java.net.SocketAddress localAddress)
Sets the default local address to bind when no argument is specified in
IoAcceptor.bind() method. |
void |
setDefaultLocalAddresses(java.lang.Iterable<? extends java.net.SocketAddress> localAddresses)
Sets the default local addresses to bind when no argument is specified
in
IoAcceptor.bind() method. |
void |
setDefaultLocalAddresses(java.util.List<? extends java.net.SocketAddress> localAddresses)
Sets the default local addresses to bind when no argument is specified
in
IoAcceptor.bind() method. |
void |
setDefaultLocalAddresses(java.net.SocketAddress firstLocalAddress,
java.net.SocketAddress... otherLocalAddresses)
Sets the default local addresses to bind when no argument is specified
in
IoAcceptor.bind() method. |
java.lang.String |
toString() |
void |
unbind()
Unbinds from all local addresses that this service is bound to and stops
to accept incoming connections.
|
void |
unbind(java.lang.Iterable<? extends java.net.SocketAddress> localAddresses)
Unbinds from the specified local addresses and stop to accept incoming
connections.
|
void |
unbind(java.net.SocketAddress localAddress)
Unbinds from the specified local address and stop to accept incoming
connections.
|
void |
unbind(java.net.SocketAddress firstLocalAddress,
java.net.SocketAddress... otherLocalAddresses)
Unbinds from the specified local addresses and stop to accept incoming
connections.
|
protected abstract void |
unbind0(java.util.List<? extends java.net.SocketAddress> localAddresses)
Implement this method to perform the actual unbind operation.
|
addListener, broadcast, dispose, dispose, dispose0, executeWorker, executeWorker, finishSessionInitialization0, getActivationTime, getFilterChain, getFilterChainBuilder, getHandler, getListeners, getManagedSessionCount, getManagedSessions, getScheduledWriteBytes, getScheduledWriteMessages, getSessionDataStructureFactory, getStatistics, initSession, isActive, isDisposed, isDisposing, removeListener, setFilterChainBuilder, setHandler, setSessionDataStructureFactory
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
newSession
addListener, broadcast, dispose, dispose, getActivationTime, getFilterChain, getFilterChainBuilder, getHandler, getManagedSessionCount, getManagedSessions, getScheduledWriteBytes, getScheduledWriteMessages, getSessionConfig, getSessionDataStructureFactory, getStatistics, getTransportMetadata, isActive, isDisposed, isDisposing, removeListener, setFilterChainBuilder, setHandler, setSessionDataStructureFactory
protected final java.lang.Object bindLock
protected AbstractIoAcceptor(IoSessionConfig sessionConfig, java.util.concurrent.Executor executor)
AbstractIoAcceptor
. You need to provide a default
session configuration and an Executor
for handling I/O events. If
null Executor
is provided, a default one will be created using
Executors.newCachedThreadPool()
.sessionConfig
- the default configuration for the managed IoSession
executor
- the Executor
used for handling execution of I/O
events. Can be null
.AbstractIoService.AbstractIoService(IoSessionConfig, Executor)
public java.net.SocketAddress getLocalAddress()
getLocalAddress
在接口中 IoAcceptor
public final java.util.Set<java.net.SocketAddress> getLocalAddresses()
Set
of the local addresses which are bound currently.getLocalAddresses
在接口中 IoAcceptor
public java.net.SocketAddress getDefaultLocalAddress()
IoAcceptor.bind()
method. Please note that the default will not be
used if any local address is specified. If more than one address are
set, only one of them will be returned, but it's not necessarily the
firstly specified address in IoAcceptor.setDefaultLocalAddresses(List)
.getDefaultLocalAddress
在接口中 IoAcceptor
public final void setDefaultLocalAddress(java.net.SocketAddress localAddress)
IoAcceptor.bind()
method. Please note that the default will not be used
if any local address is specified.setDefaultLocalAddress
在接口中 IoAcceptor
localAddress
- The local addresses to bind the acceptor onpublic final java.util.List<java.net.SocketAddress> getDefaultLocalAddresses()
List
of the default local addresses to bind when no
argument is specified in IoAcceptor.bind()
method. Please note that the
default will not be used if any local address is specified.getDefaultLocalAddresses
在接口中 IoAcceptor
public final void setDefaultLocalAddresses(java.util.List<? extends java.net.SocketAddress> localAddresses)
IoAcceptor.bind()
method. Please note that the default will not be
used if any local address is specified.setDefaultLocalAddresses
在接口中 IoAcceptor
localAddresses
- The local addresses to bind the acceptor onpublic final void setDefaultLocalAddresses(java.lang.Iterable<? extends java.net.SocketAddress> localAddresses)
IoAcceptor.bind()
method. Please note that the default will not be
used if any local address is specified.setDefaultLocalAddresses
在接口中 IoAcceptor
localAddresses
- The local addresses to bind the acceptor onpublic final void setDefaultLocalAddresses(java.net.SocketAddress firstLocalAddress, java.net.SocketAddress... otherLocalAddresses)
IoAcceptor.bind()
method. Please note that the default will not be
used if any local address is specified.setDefaultLocalAddresses
在接口中 IoAcceptor
firstLocalAddress
- The first local address to bind the acceptor onotherLocalAddresses
- The other local addresses to bind the acceptor onpublic final boolean isCloseOnDeactivation()
isCloseOnDeactivation
在接口中 IoAcceptor
public final void setCloseOnDeactivation(boolean disconnectClientsOnUnbind)
setCloseOnDeactivation
在接口中 IoAcceptor
disconnectClientsOnUnbind
- true if we should close on deactivationpublic final void bind() throws java.io.IOException
bind
在接口中 IoAcceptor
java.io.IOException
- if failed to bindpublic final void bind(java.net.SocketAddress localAddress) throws java.io.IOException
bind
在接口中 IoAcceptor
localAddress
- The SocketAddress to bind tojava.io.IOException
- if failed to bindpublic final void bind(java.net.SocketAddress... addresses) throws java.io.IOException
bind
在接口中 IoAcceptor
addresses
- The SocketAddresses to bind tojava.io.IOException
- if failed to bindpublic final void bind(java.net.SocketAddress firstLocalAddress, java.net.SocketAddress... addresses) throws java.io.IOException
bind
在接口中 IoAcceptor
firstLocalAddress
- The first address to bind toaddresses
- The SocketAddresses to bind tojava.io.IOException
- if failed to bindpublic final void bind(java.lang.Iterable<? extends java.net.SocketAddress> localAddresses) throws java.io.IOException
bind
在接口中 IoAcceptor
localAddresses
- The local address we will be bound tojava.io.IOException
- if failed to bindpublic final void unbind()
disconnectOnUnbind
property
is true. This method returns silently if no local address is
bound yet.unbind
在接口中 IoAcceptor
public final void unbind(java.net.SocketAddress localAddress)
disconnectOnUnbind
property is
true. This method returns silently if the default local
address is not bound yet.unbind
在接口中 IoAcceptor
localAddress
- The local address we will be unbound frompublic final void unbind(java.net.SocketAddress firstLocalAddress, java.net.SocketAddress... otherLocalAddresses)
disconnectOnUnbind
property is
true. This method returns silently if the default local
addresses are not bound yet.unbind
在接口中 IoAcceptor
firstLocalAddress
- The first local address to be unbound fromotherLocalAddresses
- The other local address to be unbound frompublic final void unbind(java.lang.Iterable<? extends java.net.SocketAddress> localAddresses)
disconnectOnUnbind
property is
true. This method returns silently if the default local
addresses are not bound yet.unbind
在接口中 IoAcceptor
localAddresses
- The local address we will be unbound fromprotected abstract java.util.Set<java.net.SocketAddress> bindInternal(java.util.List<? extends java.net.SocketAddress> localAddresses) throws java.lang.Exception
localAddresses
- The address to bind toSet
of the local addresses which is bound actuallyjava.lang.Exception
- If the bind failedprotected abstract void unbind0(java.util.List<? extends java.net.SocketAddress> localAddresses) throws java.lang.Exception
localAddresses
- The address to unbind fromjava.lang.Exception
- If the unbind failedpublic java.lang.String toString()
toString
在类中 java.lang.Object