Class AprSocketAcceptor
- java.lang.Object
-
- org.apache.mina.core.service.AbstractIoService
-
- org.apache.mina.core.service.AbstractIoAcceptor
-
- org.apache.mina.core.polling.AbstractPollingIoAcceptor<AprSession,Long>
-
- org.apache.mina.transport.socket.apr.AprSocketAcceptor
-
- All Implemented Interfaces:
IoAcceptor
,IoService
public final class AprSocketAcceptor extends AbstractPollingIoAcceptor<AprSession,Long>
IoAcceptor
for APR based socket transport (TCP/IP).- Author:
- Apache MINA Project
-
-
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.polling.AbstractPollingIoAcceptor
backlog, reuseAddress
-
Fields inherited from class org.apache.mina.core.service.AbstractIoAcceptor
bindLock
-
Fields inherited from class org.apache.mina.core.service.AbstractIoService
disposalLock, LOGGER, sessionConfig
-
-
Constructor Summary
Constructors Constructor Description AprSocketAcceptor()
Constructor forAprSocketAcceptor
using default parameters (multiple thread model).AprSocketAcceptor(int processorCount)
Constructor forAprSocketAcceptor
using default parameters, and given number ofAprIoProcessor
for multithreading I/O operations.AprSocketAcceptor(Executor executor, IoProcessor<AprSession> processor)
Constructor forAprSocketAcceptor
with a givenExecutor
for handling connection events and a givenAprIoProcessor
for handling I/O events, useful for sharing the same processor and executor over multipleIoService
of the same type.AprSocketAcceptor(IoProcessor<AprSession> processor)
Constructor forAprSocketAcceptor
with default configuration but a specificAprIoProcessor
, useful for sharing the same processor over multipleIoService
of the same type.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected AprSession
accept(IoProcessor<AprSession> processor, Long handle)
Accept a client connection for a server socket and return a newIoSession
associated with the givenIoProcessor
protected void
close(Long handle)
Close a server socket.protected void
destroy()
Destroy the polling system, will be called when thisIoAcceptor
implementation will be disposed.InetSocketAddress
getDefaultLocalAddress()
Returns the default local address to bind when no argument is specified inIoAcceptor.bind()
method.InetSocketAddress
getLocalAddress()
Returns the local address which is bound currently.TransportMetadata
getTransportMetadata()
protected void
init()
Initialize the polling system, will be called at construction time.protected void
init(SelectorProvider selectorProvider)
Initialize the polling system, will be called at construction time.protected SocketAddress
localAddress(Long handle)
Get the local address associated with a given server socketprotected Long
open(SocketAddress localAddress)
Open a server socket for a given local address.protected int
select()
Check for acceptable connections, interrupt when at least a server is ready for accepting.protected Iterator<Long>
selectedHandles()
Iterator
for the set of server sockets found with acceptable incoming connections during the lastAbstractPollingIoAcceptor.select()
call.void
setDefaultLocalAddress(InetSocketAddress localAddress)
protected void
wakeup()
Interrupt theAbstractPollingIoAcceptor.select()
method.-
Methods inherited from class org.apache.mina.core.polling.AbstractPollingIoAcceptor
bindInternal, dispose0, getBacklog, getSessionConfig, isReuseAddress, newSession, setBacklog, setReuseAddress, unbind0
-
Methods inherited from class org.apache.mina.core.service.AbstractIoAcceptor
bind, bind, bind, bind, bind, getDefaultLocalAddresses, getLocalAddresses, isCloseOnDeactivation, setCloseOnDeactivation, setDefaultLocalAddress, setDefaultLocalAddresses, setDefaultLocalAddresses, setDefaultLocalAddresses, toString, unbind, unbind, unbind, unbind
-
Methods inherited from class org.apache.mina.core.service.AbstractIoService
addListener, broadcast, dispose, dispose, executeWorker, executeWorker, finishSessionInitialization0, getActivationTime, getFilterChain, getFilterChainBuilder, getHandler, getListeners, getManagedSessionCount, getManagedSessions, getScheduledWriteBytes, getScheduledWriteMessages, getSessionDataStructureFactory, getStatistics, initSession, isActive, isDisposed, isDisposing, removeListener, setFilterChainBuilder, setHandler, setSessionDataStructureFactory
-
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, dispose, getActivationTime, getFilterChain, getFilterChainBuilder, getHandler, getManagedSessionCount, getManagedSessions, getScheduledWriteBytes, getScheduledWriteMessages, getSessionDataStructureFactory, getStatistics, isActive, isDisposed, isDisposing, removeListener, setFilterChainBuilder, setHandler, setSessionDataStructureFactory
-
-
-
-
Constructor Detail
-
AprSocketAcceptor
public AprSocketAcceptor()
Constructor forAprSocketAcceptor
using default parameters (multiple thread model).
-
AprSocketAcceptor
public AprSocketAcceptor(int processorCount)
Constructor forAprSocketAcceptor
using default parameters, and given number ofAprIoProcessor
for multithreading I/O operations.- Parameters:
processorCount
- the number of processor to create and place in aSimpleIoProcessorPool
-
AprSocketAcceptor
public AprSocketAcceptor(IoProcessor<AprSession> processor)
Constructor forAprSocketAcceptor
with default configuration but a specificAprIoProcessor
, useful for sharing the same processor over multipleIoService
of the same type.- Parameters:
processor
- the processor to use for managing I/O events
-
AprSocketAcceptor
public AprSocketAcceptor(Executor executor, IoProcessor<AprSession> processor)
Constructor forAprSocketAcceptor
with a givenExecutor
for handling connection events and a givenAprIoProcessor
for handling I/O events, useful for sharing the same processor and executor over multipleIoService
of the same type.- Parameters:
executor
- the executor for connectionprocessor
- the processor for I/O operations
-
-
Method Detail
-
accept
protected AprSession accept(IoProcessor<AprSession> processor, Long handle) throws Exception
Accept a client connection for a server socket and return a newIoSession
associated with the givenIoProcessor
- Specified by:
accept
in classAbstractPollingIoAcceptor<AprSession,Long>
- Parameters:
processor
- theIoProcessor
to associate with theIoSession
handle
- the server handle- Returns:
- the created
IoSession
- Throws:
Exception
- any exception thrown by the underlying systems calls
-
open
protected Long open(SocketAddress localAddress) throws Exception
Open a server socket for a given local address.- Specified by:
open
in classAbstractPollingIoAcceptor<AprSession,Long>
- Parameters:
localAddress
- the associated local address- Returns:
- the opened server socket
- Throws:
Exception
- any exception thrown by the underlying systems calls
-
init
protected void init() throws Exception
Initialize the polling system, will be called at construction time.- Specified by:
init
in classAbstractPollingIoAcceptor<AprSession,Long>
- Throws:
Exception
- any exception thrown by the underlying system calls
-
destroy
protected void destroy() throws Exception
Destroy the polling system, will be called when thisIoAcceptor
implementation will be disposed.- Specified by:
destroy
in classAbstractPollingIoAcceptor<AprSession,Long>
- Throws:
Exception
- any exception thrown by the underlying systems calls
-
localAddress
protected SocketAddress localAddress(Long handle) throws Exception
Get the local address associated with a given server socket- Specified by:
localAddress
in classAbstractPollingIoAcceptor<AprSession,Long>
- Parameters:
handle
- the server socket- Returns:
- the local
SocketAddress
associated with this handle - Throws:
Exception
- any exception thrown by the underlying systems calls
-
select
protected int select() throws Exception
Check for acceptable connections, interrupt when at least a server is ready for accepting. All the ready server socket descriptors need to be returned byAbstractPollingIoAcceptor.selectedHandles()
- Specified by:
select
in classAbstractPollingIoAcceptor<AprSession,Long>
- Returns:
- The number of sockets having got incoming client
- Throws:
Exception
- any exception thrown by the underlying systems calls
-
selectedHandles
protected Iterator<Long> selectedHandles()
Iterator
for the set of server sockets found with acceptable incoming connections during the lastAbstractPollingIoAcceptor.select()
call.- Specified by:
selectedHandles
in classAbstractPollingIoAcceptor<AprSession,Long>
- Returns:
- the list of server handles ready
-
close
protected void close(Long handle) throws Exception
Close a server socket.- Specified by:
close
in classAbstractPollingIoAcceptor<AprSession,Long>
- Parameters:
handle
- the server socket- Throws:
Exception
- any exception thrown by the underlying systems calls
-
wakeup
protected void wakeup()
Interrupt theAbstractPollingIoAcceptor.select()
method. Used when the poll set need to be modified.- Specified by:
wakeup
in classAbstractPollingIoAcceptor<AprSession,Long>
-
getLocalAddress
public InetSocketAddress getLocalAddress()
Returns the local address which is bound currently. If more than one address are bound, only one of them will be returned, but it's not necessarily the firstly bound address.- Specified by:
getLocalAddress
in interfaceIoAcceptor
- Overrides:
getLocalAddress
in classAbstractIoAcceptor
- Returns:
- The bound LocalAddress
-
getDefaultLocalAddress
public InetSocketAddress getDefaultLocalAddress()
Returns the default local address to bind when no argument is specified inIoAcceptor.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 inIoAcceptor.setDefaultLocalAddresses(List)
.- Specified by:
getDefaultLocalAddress
in interfaceIoAcceptor
- Overrides:
getDefaultLocalAddress
in classAbstractIoAcceptor
- Returns:
- The default bound LocalAddress
-
setDefaultLocalAddress
public void setDefaultLocalAddress(InetSocketAddress localAddress)
- Parameters:
localAddress
- The localAddress to set- See Also:
AbstractIoAcceptor.setDefaultLocalAddress(SocketAddress)
-
getTransportMetadata
public TransportMetadata getTransportMetadata()
- Returns:
- the
TransportMetadata
that this service runs on.
-
init
protected void init(SelectorProvider selectorProvider) throws Exception
Description copied from class:AbstractPollingIoAcceptor
Initialize the polling system, will be called at construction time.- Specified by:
init
in classAbstractPollingIoAcceptor<AprSession,Long>
- Parameters:
selectorProvider
- The Selector Provider that will be used by this polling acceptor- Throws:
Exception
- any exception thrown by the underlying system calls
-
-