org.apache.mina.transport.socket.apr
Class AprSocketAcceptor

java.lang.Object
  extended by org.apache.mina.core.service.AbstractIoService
      extended by org.apache.mina.core.service.AbstractIoAcceptor
          extended by org.apache.mina.core.polling.AbstractPollingIoAcceptor<AprSession,Long>
              extended by org.apache.mina.transport.socket.apr.AprSocketAcceptor
All Implemented Interfaces:
IoAcceptor, IoService, SocketAcceptor

public final class AprSocketAcceptor
extends AbstractPollingIoAcceptor<AprSession,Long>
implements SocketAcceptor

TODO Add documentation

Version:
$Rev: 671827 $, $Date: 2008-06-26 10:49:48 +0200 (jeu, 26 jun 2008) $
Author:
The Apache MINA Project (dev@mina.apache.org)

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
AprSocketAcceptor()
           
AprSocketAcceptor(Executor executor, IoProcessor<AprSession> processor)
           
AprSocketAcceptor(int processorCount)
           
AprSocketAcceptor(IoProcessor<AprSession> processor)
           
 
Method Summary
protected  AprSession accept(IoProcessor<AprSession> processor, Long handle)
          Accept a client connection for a server socket and return a new IoSession associated with the given IoProcessor
protected  void close(Long handle)
          Close a server socket.
protected  void destroy()
          Destroy the polling system, will be called when this IoAcceptor implementation will be disposed.
 int getBacklog()
          Returns the size of the backlog.
 InetSocketAddress getDefaultLocalAddress()
          Returns the default local address to bind when no argument is specified in IoAcceptor.bind() method.
 InetSocketAddress getLocalAddress()
          Returns the local address which is bound currently.
 SocketSessionConfig getSessionConfig()
          Returns the default configuration of the new IoSessions created by this service.
 TransportMetadata getTransportMetadata()
          Returns the TransportMetadata that this service runs on.
protected  void init()
          Initialize the polling system, will be called at construction time.
 boolean isReuseAddress()
           
protected  SocketAddress localAddress(Long handle)
          Get the local address associated with a given server socket
protected  Long open(SocketAddress localAddress)
          Open a server socket for a given local address.
protected  boolean 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 last AbstractPollingIoAcceptor.select() call.
 void setBacklog(int backlog)
          Sets the size of the backlog.
 void setDefaultLocalAddress(InetSocketAddress localAddress)
           
 void setReuseAddress(boolean reuseAddress)
           
protected  void wakeup()
          Interrupt the AbstractPollingIoAcceptor.select() method.
 
Methods inherited from class org.apache.mina.core.polling.AbstractPollingIoAcceptor
bind0, dispose0, newSession, unbind0
 
Methods inherited from class org.apache.mina.core.service.AbstractIoAcceptor
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, executeWorker, executeWorker, finishSessionInitialization, finishSessionInitialization0, getActivationTime, getFilterChain, getFilterChainBuilder, getHandler, getIdleState, getIdleStatusChecker, getListeners, getManagedSessionCount, getManagedSessions, getScheduledWriteBytes, getScheduledWriteMessages, getSessionDataStructureFactory, getStatistics, isActive, isDisposed, isDisposing, notifyIdleness, 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.IoAcceptor
bind, bind, bind, bind, getDefaultLocalAddresses, getLocalAddresses, isCloseOnDeactivation, newSession, setCloseOnDeactivation, setDefaultLocalAddress, setDefaultLocalAddresses, setDefaultLocalAddresses, setDefaultLocalAddresses, unbind, unbind, unbind, unbind
 
Methods inherited from interface org.apache.mina.core.service.IoService
addListener, broadcast, dispose, getActivationTime, getFilterChain, getFilterChainBuilder, getHandler, getIdleState, getManagedSessionCount, getManagedSessions, getScheduledWriteBytes, getScheduledWriteMessages, getSessionDataStructureFactory, getStatistics, isActive, isDisposed, isDisposing, removeListener, setFilterChainBuilder, setHandler, setSessionDataStructureFactory
 

Constructor Detail

AprSocketAcceptor

public AprSocketAcceptor()

AprSocketAcceptor

public AprSocketAcceptor(int processorCount)

AprSocketAcceptor

public AprSocketAcceptor(IoProcessor<AprSession> processor)

AprSocketAcceptor

public AprSocketAcceptor(Executor executor,
                         IoProcessor<AprSession> processor)
Method Detail

accept

protected AprSession accept(IoProcessor<AprSession> processor,
                            Long handle)
                     throws Exception
Description copied from class: AbstractPollingIoAcceptor
Accept a client connection for a server socket and return a new IoSession associated with the given IoProcessor

Specified by:
accept in class AbstractPollingIoAcceptor<AprSession,Long>
Parameters:
processor - the IoProcessor to associate with the IoSession
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
Description copied from class: AbstractPollingIoAcceptor
Open a server socket for a given local address.

Specified by:
open in class AbstractPollingIoAcceptor<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
Description copied from class: AbstractPollingIoAcceptor
Initialize the polling system, will be called at construction time.

Specified by:
init in class AbstractPollingIoAcceptor<AprSession,Long>
Throws:
Exception - any exception thrown by the underlying system calls

destroy

protected void destroy()
                throws Exception
Description copied from class: AbstractPollingIoAcceptor
Destroy the polling system, will be called when this IoAcceptor implementation will be disposed.

Specified by:
destroy in class AbstractPollingIoAcceptor<AprSession,Long>
Throws:
Exception - any exception thrown by the underlying systems calls

localAddress

protected SocketAddress localAddress(Long handle)
                              throws Exception
Description copied from class: AbstractPollingIoAcceptor
Get the local address associated with a given server socket

Specified by:
localAddress in class AbstractPollingIoAcceptor<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 boolean select()
                  throws Exception
Description copied from class: AbstractPollingIoAcceptor
Check for acceptable connections, interrupt when at least a server is ready for accepting. All the ready server socket descriptors need to be returned by AbstractPollingIoAcceptor.selectedHandles()

Specified by:
select in class AbstractPollingIoAcceptor<AprSession,Long>
Returns:
true if one server socket have got incoming client
Throws:
Exception - any exception thrown by the underlying systems calls

selectedHandles

protected Iterator<Long> selectedHandles()
Description copied from class: AbstractPollingIoAcceptor
Iterator for the set of server sockets found with acceptable incoming connections during the last AbstractPollingIoAcceptor.select() call.

Specified by:
selectedHandles in class AbstractPollingIoAcceptor<AprSession,Long>
Returns:
the list of server handles ready

close

protected void close(Long handle)
              throws Exception
Description copied from class: AbstractPollingIoAcceptor
Close a server socket.

Specified by:
close in class AbstractPollingIoAcceptor<AprSession,Long>
Parameters:
handle - the server socket
Throws:
Exception - any exception thrown by the underlying systems calls

wakeup

protected void wakeup()
Description copied from class: AbstractPollingIoAcceptor
Interrupt the AbstractPollingIoAcceptor.select() method. Used when the poll set need to be modified.

Specified by:
wakeup in class AbstractPollingIoAcceptor<AprSession,Long>

getBacklog

public int getBacklog()
Description copied from interface: SocketAcceptor
Returns the size of the backlog.

Specified by:
getBacklog in interface SocketAcceptor

isReuseAddress

public boolean isReuseAddress()
Specified by:
isReuseAddress in interface SocketAcceptor
See Also:
ServerSocket.getReuseAddress()

setBacklog

public void setBacklog(int backlog)
Description copied from interface: SocketAcceptor
Sets the size of the backlog. This can only be done when this class is not bound

Specified by:
setBacklog in interface SocketAcceptor

getLocalAddress

public InetSocketAddress getLocalAddress()
Description copied from class: AbstractIoAcceptor
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 interface IoAcceptor
Specified by:
getLocalAddress in interface SocketAcceptor
Overrides:
getLocalAddress in class AbstractIoAcceptor

getDefaultLocalAddress

public InetSocketAddress getDefaultLocalAddress()
Description copied from class: AbstractIoAcceptor
Returns the default local address 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. 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).

Specified by:
getDefaultLocalAddress in interface IoAcceptor
Specified by:
getDefaultLocalAddress in interface SocketAcceptor
Overrides:
getDefaultLocalAddress in class AbstractIoAcceptor

setDefaultLocalAddress

public void setDefaultLocalAddress(InetSocketAddress localAddress)
Specified by:
setDefaultLocalAddress in interface SocketAcceptor

setReuseAddress

public void setReuseAddress(boolean reuseAddress)
Specified by:
setReuseAddress in interface SocketAcceptor
See Also:
ServerSocket.setReuseAddress(boolean)

getTransportMetadata

public TransportMetadata getTransportMetadata()
Description copied from interface: IoService
Returns the TransportMetadata that this service runs on.

Specified by:
getTransportMetadata in interface IoService

getSessionConfig

public SocketSessionConfig getSessionConfig()
Description copied from class: AbstractIoService
Returns the default configuration of the new IoSessions created by this service.

Specified by:
getSessionConfig in interface IoService
Specified by:
getSessionConfig in interface SocketAcceptor
Overrides:
getSessionConfig in class AbstractIoService


Copyright © 2004-2008 Apache MINA Project. All Rights Reserved.