public abstract class AbstractIoAcceptor extends AbstractIoService implements IoAcceptor
IoAcceptor
.Modifier and Type | Class and Description |
---|---|
static class |
AbstractIoAcceptor.AcceptorOperationFuture
A
IoFuture |
AbstractIoService.ServiceOperationFuture
Modifier and Type | Field and Description |
---|---|
protected Object |
bindLock
The lock object which is acquired while bind or unbind operation is performed.
|
disposalLock, LOGGER, sessionConfig
Modifier | Constructor and Description |
---|---|
protected |
AbstractIoAcceptor(IoSessionConfig sessionConfig,
Executor executor)
Constructor for
AbstractIoAcceptor . |
Modifier and Type | Method and Description |
---|---|
void |
bind()
Binds to the default local address(es) and start to accept incoming
connections.
|
void |
bind(Iterable<? extends SocketAddress> localAddresses)
Binds to the specified local addresses and start to accept incoming
connections.
|
void |
bind(SocketAddress... addresses)
Binds to the specified local addresses and start to accept incoming
connections.
|
void |
bind(SocketAddress localAddress)
Binds to the specified local address and start to accept incoming
connections.
|
void |
bind(SocketAddress firstLocalAddress,
SocketAddress... addresses)
Binds to the specified local addresses and start to accept incoming
connections.
|
protected abstract Set<SocketAddress> |
bindInternal(List<? extends SocketAddress> localAddresses)
Starts the acceptor, and register the given addresses
|
SocketAddress |
getDefaultLocalAddress()
Returns the default local address to bind when no argument is specified
in
IoAcceptor.bind() method. |
List<SocketAddress> |
getDefaultLocalAddresses()
Returns a
List of the default local addresses to bind when no
argument is specified in IoAcceptor.bind() method. |
SocketAddress |
getLocalAddress()
Returns the local address which is bound currently.
|
Set<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(SocketAddress localAddress)
Sets the default local address to bind when no argument is specified in
IoAcceptor.bind() method. |
void |
setDefaultLocalAddresses(Iterable<? extends SocketAddress> localAddresses)
Sets the default local addresses to bind when no argument is specified
in
IoAcceptor.bind() method. |
void |
setDefaultLocalAddresses(List<? extends SocketAddress> localAddresses)
Sets the default local addresses to bind when no argument is specified
in
IoAcceptor.bind() method. |
void |
setDefaultLocalAddresses(SocketAddress firstLocalAddress,
SocketAddress... otherLocalAddresses)
Sets the default local addresses to bind when no argument is specified
in
IoAcceptor.bind() method. |
String |
toString() |
void |
unbind()
Unbinds from all local addresses that this service is bound to and stops
to accept incoming connections.
|
void |
unbind(Iterable<? extends SocketAddress> localAddresses)
Unbinds from the specified local addresses and stop to accept incoming
connections.
|
void |
unbind(SocketAddress localAddress)
Unbinds from the specified local address and stop to accept incoming
connections.
|
void |
unbind(SocketAddress firstLocalAddress,
SocketAddress... otherLocalAddresses)
Unbinds from the specified local addresses and stop to accept incoming
connections.
|
protected abstract void |
unbind0(List<? extends 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 Object bindLock
protected AbstractIoAcceptor(IoSessionConfig sessionConfig, 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(IoSessionConfig, Executor)
public SocketAddress getLocalAddress()
getLocalAddress
in interface IoAcceptor
public final Set<SocketAddress> getLocalAddresses()
Set
of the local addresses which are bound currently.getLocalAddresses
in interface IoAcceptor
public 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
in interface IoAcceptor
public final void setDefaultLocalAddress(SocketAddress localAddress)
IoAcceptor.bind()
method. Please note that the default will not be used
if any local address is specified.setDefaultLocalAddress
in interface IoAcceptor
localAddress
- The local addresses to bind the acceptor onpublic final List<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
in interface IoAcceptor
public final void setDefaultLocalAddresses(List<? extends SocketAddress> localAddresses)
IoAcceptor.bind()
method. Please note that the default will not be
used if any local address is specified.setDefaultLocalAddresses
in interface IoAcceptor
localAddresses
- The local addresses to bind the acceptor onpublic final void setDefaultLocalAddresses(Iterable<? extends SocketAddress> localAddresses)
IoAcceptor.bind()
method. Please note that the default will not be
used if any local address is specified.setDefaultLocalAddresses
in interface IoAcceptor
localAddresses
- The local addresses to bind the acceptor onpublic final void setDefaultLocalAddresses(SocketAddress firstLocalAddress, SocketAddress... otherLocalAddresses)
IoAcceptor.bind()
method. Please note that the default will not be
used if any local address is specified.setDefaultLocalAddresses
in interface IoAcceptor
firstLocalAddress
- The first local address to bind the acceptor onotherLocalAddresses
- The other local addresses to bind the acceptor onpublic final boolean isCloseOnDeactivation()
isCloseOnDeactivation
in interface IoAcceptor
public final void setCloseOnDeactivation(boolean disconnectClientsOnUnbind)
setCloseOnDeactivation
in interface IoAcceptor
disconnectClientsOnUnbind
- true if we should close on deactivationpublic final void bind() throws IOException
bind
in interface IoAcceptor
IOException
- if failed to bindpublic final void bind(SocketAddress localAddress) throws IOException
bind
in interface IoAcceptor
localAddress
- The SocketAddress to bind toIOException
- if failed to bindpublic final void bind(SocketAddress... addresses) throws IOException
bind
in interface IoAcceptor
addresses
- The SocketAddresses to bind toIOException
- if failed to bindpublic final void bind(SocketAddress firstLocalAddress, SocketAddress... addresses) throws IOException
bind
in interface IoAcceptor
firstLocalAddress
- The first address to bind toaddresses
- The SocketAddresses to bind toIOException
- if failed to bindpublic final void bind(Iterable<? extends SocketAddress> localAddresses) throws IOException
bind
in interface IoAcceptor
localAddresses
- The local address we will be bound toIOException
- if failed to bindpublic final void unbind()
disconnectOnUnbind
property
is true. This method returns silently if no local address is
bound yet.unbind
in interface IoAcceptor
public final void unbind(SocketAddress localAddress)
disconnectOnUnbind
property is
true. This method returns silently if the default local
address is not bound yet.unbind
in interface IoAcceptor
localAddress
- The local address we will be unbound frompublic final void unbind(SocketAddress firstLocalAddress, SocketAddress... otherLocalAddresses)
disconnectOnUnbind
property is
true. This method returns silently if the default local
addresses are not bound yet.unbind
in interface IoAcceptor
firstLocalAddress
- The first local address to be unbound fromotherLocalAddresses
- The other local address to be unbound frompublic final void unbind(Iterable<? extends SocketAddress> localAddresses)
disconnectOnUnbind
property is
true. This method returns silently if the default local
addresses are not bound yet.unbind
in interface IoAcceptor
localAddresses
- The local address we will be unbound fromprotected abstract Set<SocketAddress> bindInternal(List<? extends SocketAddress> localAddresses) throws Exception
protected abstract void unbind0(List<? extends SocketAddress> localAddresses) throws Exception
localAddresses
- The address to unbind fromException
- If the unbind failedCopyright © 2004–2022 Apache MINA Project. All rights reserved.