|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.mina.core.service.AbstractIoService
org.apache.mina.core.service.AbstractIoAcceptor
org.apache.mina.core.polling.AbstractPollingIoAcceptor<T,H>
public abstract class AbstractPollingIoAcceptor<T extends AbstractIoSession,H>
A base class for implementing transport using a polling strategy. The
underlying sockets will be checked in an active loop and woke up when an
socket needed to be processed. This class handle the logic behind binding,
accepting and disposing the server sockets. An 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| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class org.apache.mina.core.service.AbstractIoAcceptor |
|---|
AbstractIoAcceptor.AcceptorOperationFuture |
| Nested classes/interfaces inherited from class org.apache.mina.core.service.AbstractIoService |
|---|
AbstractIoService.ServiceOperationFuture |
| Field Summary |
|---|
| Fields inherited from class org.apache.mina.core.service.AbstractIoAcceptor |
|---|
bindLock |
| Fields inherited from class org.apache.mina.core.service.AbstractIoService |
|---|
disposalLock |
| Constructor Summary | |
|---|---|
protected |
AbstractPollingIoAcceptor(IoSessionConfig sessionConfig,
Class<? extends IoProcessor<T>> processorClass)
Constructor for AbstractPollingIoAcceptor. |
protected |
AbstractPollingIoAcceptor(IoSessionConfig sessionConfig,
Class<? extends IoProcessor<T>> processorClass,
int processorCount)
Constructor for AbstractPollingIoAcceptor. |
protected |
AbstractPollingIoAcceptor(IoSessionConfig sessionConfig,
Executor executor,
IoProcessor<T> processor)
Constructor for AbstractPollingIoAcceptor. |
protected |
AbstractPollingIoAcceptor(IoSessionConfig sessionConfig,
IoProcessor<T> processor)
Constructor for AbstractPollingIoAcceptor. |
| Method Summary | |
|---|---|
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 Set<SocketAddress> |
bind0(List<? extends SocketAddress> localAddresses)
Implement this method to perform the actual bind operation. |
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 IoFuture |
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 SocketAddress |
localAddress(H handle)
Get the local address associated with a given server socket |
IoSession |
newSession(SocketAddress remoteAddress,
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(SocketAddress localAddress)
Open a server socket for a given local address. |
protected abstract boolean |
select()
Check for acceptable connections, interrupt when at least a server is ready for accepting. |
protected abstract Iterator<H> |
selectedHandles()
Iterator for the set of server sockets found with acceptable incoming connections
during the last select() call. |
protected void |
unbind0(List<? extends SocketAddress> localAddresses)
Implement this method to perform the actual unbind operation. |
protected abstract void |
wakeup()
Interrupt the select() method. |
| Methods inherited from class org.apache.mina.core.service.AbstractIoAcceptor |
|---|
bind, bind, bind, bind, getDefaultLocalAddress, getDefaultLocalAddresses, getLocalAddress, getLocalAddresses, isCloseOnDeactivation, setCloseOnDeactivation, setDefaultLocalAddress, setDefaultLocalAddresses, setDefaultLocalAddresses, setDefaultLocalAddresses, toString, unbind, unbind, unbind, unbind |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.apache.mina.core.service.IoService |
|---|
addListener, broadcast, dispose, getActivationTime, getFilterChain, getFilterChainBuilder, getHandler, getIdleState, getManagedSessionCount, getManagedSessions, getScheduledWriteBytes, getScheduledWriteMessages, getSessionConfig, getSessionDataStructureFactory, getStatistics, getTransportMetadata, isActive, isDisposed, isDisposing, removeListener, setFilterChainBuilder, setHandler, setSessionDataStructureFactory |
| Constructor Detail |
|---|
protected AbstractPollingIoAcceptor(IoSessionConfig sessionConfig,
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 IoSessionprocessorClass - a Class of IoProcessor for the associated IoSession
type.SimpleIoProcessorPool
protected AbstractPollingIoAcceptor(IoSessionConfig sessionConfig,
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 IoSessionprocessorClass - 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 IoSessionprocessor - 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,
Executor executor,
IoProcessor<T> processor)
AbstractPollingIoAcceptor. 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().
AbstractIoService#AbstractIoService(IoSessionConfig, Executor)
sessionConfig - the default configuration for the managed IoSessionexecutor - 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| Method Detail |
|---|
protected abstract void init()
throws Exception
Exception - any exception thrown by the underlying system calls
protected abstract void destroy()
throws Exception
IoAcceptor
implementation will be disposed.
Exception - any exception thrown by the underlying systems calls
protected abstract boolean select()
throws Exception
selectedHandles()
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 Iterator<H> selectedHandles()
Iterator for the set of server sockets found with acceptable incoming connections
during the last select() call.
protected abstract H open(SocketAddress localAddress)
throws Exception
localAddress - the associated local address
Exception - any exception thrown by the underlying systems calls
protected abstract SocketAddress localAddress(H handle)
throws Exception
handle - the server socket
SocketAddress associated with this handle
Exception - any exception thrown by the underlying systems calls
protected abstract T accept(IoProcessor<T> processor,
H handle)
throws Exception
IoSession
associated with the given IoProcessor
processor - the IoProcessor to associate with the IoSessionhandle - the server handle
IoSession
Exception - any exception thrown by the underlying systems calls
protected abstract void close(H handle)
throws Exception
handle - the server socket
Exception - any exception thrown by the underlying systems calls
protected IoFuture dispose0()
throws Exception
AbstractIoService.dispose().
dispose0 in class AbstractIoServiceException
protected final Set<SocketAddress> bind0(List<? extends SocketAddress> localAddresses)
throws Exception
bind0 in class AbstractIoAcceptorSet of the local addresses which is bound actually
Exception
protected final void unbind0(List<? extends SocketAddress> localAddresses)
throws Exception
unbind0 in class AbstractIoAcceptorException
public final IoSession newSession(SocketAddress remoteAddress,
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.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||