public abstract class AbstractPollingIoAcceptor<T extends AbstractIoSession,H> extends AbstractIoAcceptor
Executor
will be used
for running client accepting and an AbstractPollingIoProcessor
will
be used for processing client I/O operations like reading, writing and
closing.
All the low level methods for binding, accepting, closing need to be provided
by the subclassing implementation.for a example of implementation
AbstractIoAcceptor.AcceptorOperationFuture
AbstractIoService.ServiceOperationFuture
bindLock
disposalLock
Modifier | Constructor and Description |
---|---|
protected |
AbstractPollingIoAcceptor(IoSessionConfig sessionConfig,
java.lang.Class<? extends IoProcessor<T>> processorClass)
Constructor for
AbstractPollingIoAcceptor . |
protected |
AbstractPollingIoAcceptor(IoSessionConfig sessionConfig,
java.lang.Class<? extends IoProcessor<T>> processorClass,
int processorCount)
Constructor for
AbstractPollingIoAcceptor . |
protected |
AbstractPollingIoAcceptor(IoSessionConfig sessionConfig,
java.util.concurrent.Executor executor,
IoProcessor<T> processor)
Constructor for
AbstractPollingIoAcceptor . |
protected |
AbstractPollingIoAcceptor(IoSessionConfig sessionConfig,
IoProcessor<T> processor)
Constructor for
AbstractPollingIoAcceptor . |
Modifier and Type | Method and Description |
---|---|
protected abstract T |
accept(IoProcessor<T> processor,
H handle)
Accept a client connection for a server socket and return a new
IoSession
associated with the given IoProcessor |
protected java.util.Set<java.net.SocketAddress> |
bindInternal(java.util.List<? extends java.net.SocketAddress> localAddresses)
Starts the acceptor, and register the given addresses
|
protected abstract void |
close(H handle)
Close a server socket.
|
protected abstract void |
destroy()
Destroy the polling system, will be called when this
IoAcceptor
implementation will be disposed. |
protected void |
dispose0()
Implement this method to release any acquired resources.
|
protected abstract void |
init()
Initialize the polling system, will be called at construction time.
|
protected abstract java.net.SocketAddress |
localAddress(H handle)
Get the local address associated with a given server socket
|
IoSession |
newSession(java.net.SocketAddress remoteAddress,
java.net.SocketAddress localAddress)
(Optional) Returns an
IoSession that is bound to the specified
localAddress and the specified remoteAddress which
reuses the local address that is already bound by this service. |
protected abstract H |
open(java.net.SocketAddress localAddress)
Open a server socket for a given local address.
|
protected abstract int |
select()
Check for acceptable connections, interrupt when at least a server is ready for accepting.
|
protected abstract java.util.Iterator<H> |
selectedHandles()
Iterator for the set of server sockets found with acceptable incoming connections
during the last select() call. |
protected void |
unbind0(java.util.List<? extends java.net.SocketAddress> localAddresses)
Implement this method to perform the actual unbind operation.
|
protected abstract void |
wakeup()
Interrupt the
select() method. |
bind, bind, bind, bind, getDefaultLocalAddress, getDefaultLocalAddresses, getLocalAddress, getLocalAddresses, isCloseOnDeactivation, setCloseOnDeactivation, setDefaultLocalAddress, setDefaultLocalAddresses, setDefaultLocalAddresses, setDefaultLocalAddresses, toString, unbind, unbind, unbind, unbind
addListener, broadcast, dispose, dispose, executeWorker, executeWorker, finishSessionInitialization0, getActivationTime, getFilterChain, getFilterChainBuilder, getHandler, getListeners, getManagedSessionCount, getManagedSessions, getScheduledWriteBytes, getScheduledWriteMessages, getSessionConfig, getSessionDataStructureFactory, getStatistics, initSession, isActive, isDisposed, isDisposing, removeListener, setFilterChainBuilder, setHandler, setSessionDataStructureFactory
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addListener, broadcast, dispose, dispose, getActivationTime, getFilterChain, getFilterChainBuilder, getHandler, getManagedSessionCount, getManagedSessions, getScheduledWriteBytes, getScheduledWriteMessages, getSessionConfig, getSessionDataStructureFactory, getStatistics, getTransportMetadata, isActive, isDisposed, isDisposing, removeListener, setFilterChainBuilder, setHandler, setSessionDataStructureFactory
protected AbstractPollingIoAcceptor(IoSessionConfig sessionConfig, java.lang.Class<? extends IoProcessor<T>> processorClass)
AbstractPollingIoAcceptor
. You need to provide a default
session configuration, a class of IoProcessor
which will be instantiated in a
SimpleIoProcessorPool
for better scaling in multiprocessor systems. The default
pool size will be used.sessionConfig
- the default configuration for the managed IoSession
processorClass
- a Class
of IoProcessor
for the associated IoSession
type.SimpleIoProcessorPool
protected AbstractPollingIoAcceptor(IoSessionConfig sessionConfig, java.lang.Class<? extends IoProcessor<T>> processorClass, int processorCount)
AbstractPollingIoAcceptor
. You need to provide a default
session configuration, a class of IoProcessor
which will be instantiated in a
SimpleIoProcessorPool
for using multiple thread for better scaling in multiprocessor
systems.sessionConfig
- the default configuration for the managed IoSession
processorClass
- a Class
of IoProcessor
for the associated IoSession
type.processorCount
- the amount of processor to instantiate for the poolSimpleIoProcessorPool
protected AbstractPollingIoAcceptor(IoSessionConfig sessionConfig, IoProcessor<T> processor)
AbstractPollingIoAcceptor
. You need to provide a default
session configuration, a default Executor
will be created using
Executors.newCachedThreadPool()
.
AbstractIoService#AbstractIoService(IoSessionConfig, Executor)
sessionConfig
- the default configuration for the managed IoSession
processor
- the IoProcessor
for processing the IoSession
of this transport, triggering
events to the bound IoHandler
and processing the chains of IoFilter
protected AbstractPollingIoAcceptor(IoSessionConfig sessionConfig, java.util.concurrent.Executor executor, IoProcessor<T> processor)
AbstractPollingIoAcceptor
. You need to provide a default
session configuration and an Executor
for handling I/O events. If a
null Executor
is provided, a default one will be created using
Executors.newCachedThreadPool()
.
AbstractIoService#AbstractIoService(IoSessionConfig, Executor)
sessionConfig
- the default configuration for the managed IoSession
executor
- the Executor
used for handling asynchronous execution of I/O
events. Can be null
.processor
- the IoProcessor
for processing the IoSession
of this transport, triggering
events to the bound IoHandler
and processing the chains of IoFilter
protected abstract void init() throws java.lang.Exception
java.lang.Exception
- any exception thrown by the underlying system callsprotected abstract void destroy() throws java.lang.Exception
IoAcceptor
implementation will be disposed.java.lang.Exception
- any exception thrown by the underlying systems callsprotected abstract int select() throws java.lang.Exception
selectedHandles()
java.lang.Exception
- any exception thrown by the underlying systems callsprotected abstract void wakeup()
select()
method. Used when the poll set need to be modified.protected abstract java.util.Iterator<H> selectedHandles()
Iterator
for the set of server sockets found with acceptable incoming connections
during the last select()
call.protected abstract H open(java.net.SocketAddress localAddress) throws java.lang.Exception
localAddress
- the associated local addressjava.lang.Exception
- any exception thrown by the underlying systems callsprotected abstract java.net.SocketAddress localAddress(H handle) throws java.lang.Exception
handle
- the server socketSocketAddress
associated with this handlejava.lang.Exception
- any exception thrown by the underlying systems callsprotected abstract T accept(IoProcessor<T> processor, H handle) throws java.lang.Exception
IoSession
associated with the given IoProcessor
processor
- the IoProcessor
to associate with the IoSession
handle
- the server handleIoSession
java.lang.Exception
- any exception thrown by the underlying systems callsprotected abstract void close(H handle) throws java.lang.Exception
handle
- the server socketjava.lang.Exception
- any exception thrown by the underlying systems callsprotected void dispose0() throws java.lang.Exception
AbstractIoService.dispose()
.dispose0
in class AbstractIoService
java.lang.Exception
protected final java.util.Set<java.net.SocketAddress> bindInternal(java.util.List<? extends java.net.SocketAddress> localAddresses) throws java.lang.Exception
bindInternal
in class AbstractIoAcceptor
Set
of the local addresses which is bound actuallyjava.lang.Exception
protected final void unbind0(java.util.List<? extends java.net.SocketAddress> localAddresses) throws java.lang.Exception
unbind0
in class AbstractIoAcceptor
java.lang.Exception
public final IoSession newSession(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress)
IoSession
that is bound to the specified
localAddress and the specified remoteAddress which
reuses the local address that is already bound by this service.
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.
Copyright © 2004-2019 Apache MINA Project. All Rights Reserved.