org.apache.mina.transport.socket.nio
Class SocketAcceptor

java.lang.Object
  extended by org.apache.mina.common.support.BaseIoService
      extended by org.apache.mina.common.support.BaseIoAcceptor
          extended by org.apache.mina.transport.socket.nio.SocketAcceptor
All Implemented Interfaces:
IoAcceptor, IoService

public class SocketAcceptor
extends org.apache.mina.common.support.BaseIoAcceptor

IoAcceptor for socket transport (TCP/IP).

Version:
$Rev: 389042 $, $Date: 2006-03-27 07:49:41Z $
Author:
The Apache Directory Project (mina-dev@directory.apache.org)

Constructor Summary
SocketAcceptor()
          Create an acceptor with a single processing thread
SocketAcceptor(int processorCount)
          Create an acceptor with the desired number of processing threads
 
Method Summary
 void bind(SocketAddress address, IoHandler handler, IoServiceConfig config)
          Binds to the specified address and handles incoming connections with the specified handler.
 IoServiceConfig getDefaultConfig()
          Returns the default configuration which is used when you didn't specify any configuration.
 Set getManagedSessions(SocketAddress address)
          Returns all sessions with the specified remote or local address, which are currently managed by this service.
 boolean isBound(SocketAddress address)
          Returns true if and only if the specified address is bound by this acceptor.
 void unbind(SocketAddress address)
          Unbinds from the specified address and disconnects all clients connected there.
 void unbindAll()
          Unbinds all addresses which were bound by this acceptor.
 
Methods inherited from class org.apache.mina.common.support.BaseIoAcceptor
bind, newSession
 
Methods inherited from class org.apache.mina.common.support.BaseIoService
getFilterChain, getFilterChainBuilder, setFilterChainBuilder
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.mina.common.IoService
getFilterChain, getFilterChainBuilder, setFilterChainBuilder
 

Constructor Detail

SocketAcceptor

public SocketAcceptor()
Create an acceptor with a single processing thread


SocketAcceptor

public SocketAcceptor(int processorCount)
Create an acceptor with the desired number of processing threads

Parameters:
processorCount - Number of processing threads
Method Detail

bind

public void bind(SocketAddress address,
                 IoHandler handler,
                 IoServiceConfig config)
          throws IOException
Binds to the specified address and handles incoming connections with the specified handler. Backlog value is configured to the value of backlog property.

config - the configuration
Throws:
IOException - if failed to bind

getManagedSessions

public Set getManagedSessions(SocketAddress address)
Description copied from interface: IoService
Returns all sessions with the specified remote or local address, which are currently managed by this service. IoAcceptor will assume the specified address is a local address, and IoConnector will assume it's a remote address.

Specified by:
getManagedSessions in interface IoService
Overrides:
getManagedSessions in class org.apache.mina.common.support.BaseIoService
Parameters:
address - the address to return all sessions for.
Returns:
the sessions. An empty collection if there's no session.

unbind

public void unbind(SocketAddress address)
Description copied from interface: IoAcceptor
Unbinds from the specified address and disconnects all clients connected there.


unbindAll

public void unbindAll()
Description copied from interface: IoAcceptor
Unbinds all addresses which were bound by this acceptor.


isBound

public boolean isBound(SocketAddress address)
Description copied from interface: IoAcceptor
Returns true if and only if the specified address is bound by this acceptor.


getDefaultConfig

public IoServiceConfig getDefaultConfig()
Description copied from interface: IoService
Returns the default configuration which is used when you didn't specify any configuration.