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

java.lang.Object
  extended by org.apache.mina.common.AbstractIoService
      extended by org.apache.mina.common.AbstractIoAcceptor
          extended by org.apache.mina.common.AbstractPollingIoAcceptor<org.apache.mina.transport.socket.nio.NioSession,ServerSocketChannel>
              extended by org.apache.mina.transport.socket.nio.NioSocketAcceptor
All Implemented Interfaces:
IoAcceptor, IoService, SocketAcceptor, SocketService

public final class NioSocketAcceptor
extends AbstractPollingIoAcceptor<org.apache.mina.transport.socket.nio.NioSession,ServerSocketChannel>
implements SocketAcceptor

IoAcceptor for socket transport (TCP/IP). This class handles incoming TCP/IP based socket connections.

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

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.mina.common.AbstractIoAcceptor
AbstractIoAcceptor.AcceptorOperationFuture
 
Nested classes/interfaces inherited from class org.apache.mina.common.AbstractIoService
AbstractIoService.ServiceOperationFuture
 
Field Summary
 
Fields inherited from class org.apache.mina.common.AbstractIoAcceptor
bindLock
 
Constructor Summary
NioSocketAcceptor()
          Create an acceptor with a single processing thread using a NewThreadExecutor
NioSocketAcceptor(Executor executor, IoProcessor<org.apache.mina.transport.socket.nio.NioSession> processor)
           
NioSocketAcceptor(int processorCount)
           
NioSocketAcceptor(IoProcessor<org.apache.mina.transport.socket.nio.NioSession> processor)
           
 
Method Summary
protected  org.apache.mina.transport.socket.nio.NioSession accept(IoProcessor<org.apache.mina.transport.socket.nio.NioSession> processor, ServerSocketChannel handle)
           
protected  void close(ServerSocketChannel handle)
           
protected  void destroy()
           
 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()
           
 boolean isReuseAddress()
           
protected  SocketAddress localAddress(ServerSocketChannel handle)
           
protected  ServerSocketChannel open(SocketAddress localAddress)
           
protected  boolean select()
           
protected  Iterator<ServerSocketChannel> selectedHandles()
           
 void setBacklog(int backlog)
          Sets the size of the backlog.
 void setDefaultLocalAddress(InetSocketAddress localAddress)
           
 void setReuseAddress(boolean reuseAddress)
           
protected  void wakeup()
           
 
Methods inherited from class org.apache.mina.common.AbstractPollingIoAcceptor
bind0, dispose0, newSession, unbind0
 
Methods inherited from class org.apache.mina.common.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.common.AbstractIoService
addListener, broadcast, decreaseScheduledWriteMessages, dispose, finishSessionInitialization, finishSessionInitialization0, getActivationTime, getBothIdleCount, getBothIdleTime, getBothIdleTimeInMillis, getCumulativeManagedSessionCount, getFilterChain, getFilterChainBuilder, getHandler, getIdleCount, getIdleTime, getIdleTimeInMillis, getLargestManagedSessionCount, getLargestReadBytesThroughput, getLargestReadMessagesThroughput, getLargestWrittenBytesThroughput, getLargestWrittenMessagesThroughput, getLastBothIdleTime, getLastIdleTime, getLastIoTime, getLastReaderIdleTime, getLastReadTime, getLastWriterIdleTime, getLastWriteTime, getListeners, getManagedSessionCount, getManagedSessions, getReadBytes, getReadBytesThroughput, getReaderIdleCount, getReaderIdleTime, getReaderIdleTimeInMillis, getReadMessages, getReadMessagesThroughput, getScheduledWriteBytes, getScheduledWriteMessages, getSessionDataStructureFactory, getThroughputCalculationInterval, getThroughputCalculationIntervalInMillis, getWriterIdleCount, getWriterIdleTime, getWriterIdleTimeInMillis, getWrittenBytes, getWrittenBytesThroughput, getWrittenMessages, getWrittenMessagesThroughput, increaseReadBytes, increaseReadMessages, increaseScheduledWriteBytes, increaseScheduledWriteMessages, increaseWrittenBytes, increaseWrittenMessages, isActive, isBothIdle, isDisposed, isDisposing, isIdle, isReaderIdle, isWriterIdle, notifyIdleness, removeListener, setBothIdleTime, setFilterChainBuilder, setHandler, setIdleTime, setLastReadTime, setLastWriteTime, setReaderIdleTime, setSessionDataStructureFactory, setThroughputCalculationInterval, setWriterIdleTime
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.mina.common.IoService
addListener, broadcast, dispose, getActivationTime, getBothIdleCount, getBothIdleTime, getBothIdleTimeInMillis, getCumulativeManagedSessionCount, getFilterChain, getFilterChainBuilder, getHandler, getIdleCount, getIdleTime, getIdleTimeInMillis, getLargestManagedSessionCount, getLargestReadBytesThroughput, getLargestReadMessagesThroughput, getLargestWrittenBytesThroughput, getLargestWrittenMessagesThroughput, getLastBothIdleTime, getLastIdleTime, getLastIoTime, getLastReaderIdleTime, getLastReadTime, getLastWriterIdleTime, getLastWriteTime, getManagedSessionCount, getManagedSessions, getReadBytes, getReadBytesThroughput, getReaderIdleCount, getReaderIdleTime, getReaderIdleTimeInMillis, getReadMessages, getReadMessagesThroughput, getScheduledWriteBytes, getScheduledWriteMessages, getSessionDataStructureFactory, getThroughputCalculationInterval, getThroughputCalculationIntervalInMillis, getWriterIdleCount, getWriterIdleTime, getWriterIdleTimeInMillis, getWrittenBytes, getWrittenBytesThroughput, getWrittenMessages, getWrittenMessagesThroughput, isActive, isBothIdle, isDisposed, isDisposing, isIdle, isReaderIdle, isWriterIdle, removeListener, setBothIdleTime, setFilterChainBuilder, setHandler, setIdleTime, setReaderIdleTime, setSessionDataStructureFactory, setThroughputCalculationInterval, setWriterIdleTime
 
Methods inherited from interface org.apache.mina.common.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.common.IoService
addListener, broadcast, dispose, getActivationTime, getBothIdleCount, getBothIdleTime, getBothIdleTimeInMillis, getCumulativeManagedSessionCount, getFilterChain, getFilterChainBuilder, getHandler, getIdleCount, getIdleTime, getIdleTimeInMillis, getLargestManagedSessionCount, getLargestReadBytesThroughput, getLargestReadMessagesThroughput, getLargestWrittenBytesThroughput, getLargestWrittenMessagesThroughput, getLastBothIdleTime, getLastIdleTime, getLastIoTime, getLastReaderIdleTime, getLastReadTime, getLastWriterIdleTime, getLastWriteTime, getManagedSessionCount, getManagedSessions, getReadBytes, getReadBytesThroughput, getReaderIdleCount, getReaderIdleTime, getReaderIdleTimeInMillis, getReadMessages, getReadMessagesThroughput, getScheduledWriteBytes, getScheduledWriteMessages, getSessionDataStructureFactory, getThroughputCalculationInterval, getThroughputCalculationIntervalInMillis, getWriterIdleCount, getWriterIdleTime, getWriterIdleTimeInMillis, getWrittenBytes, getWrittenBytesThroughput, getWrittenMessages, getWrittenMessagesThroughput, isActive, isBothIdle, isDisposed, isDisposing, isIdle, isReaderIdle, isWriterIdle, removeListener, setBothIdleTime, setFilterChainBuilder, setHandler, setIdleTime, setReaderIdleTime, setSessionDataStructureFactory, setThroughputCalculationInterval, setWriterIdleTime
 

Constructor Detail

NioSocketAcceptor

public NioSocketAcceptor()
Create an acceptor with a single processing thread using a NewThreadExecutor


NioSocketAcceptor

public NioSocketAcceptor(int processorCount)

NioSocketAcceptor

public NioSocketAcceptor(IoProcessor<org.apache.mina.transport.socket.nio.NioSession> processor)

NioSocketAcceptor

public NioSocketAcceptor(Executor executor,
                         IoProcessor<org.apache.mina.transport.socket.nio.NioSession> processor)
Method Detail

init

protected void init()
             throws Exception
Specified by:
init in class AbstractPollingIoAcceptor<org.apache.mina.transport.socket.nio.NioSession,ServerSocketChannel>
Throws:
Exception

destroy

protected void destroy()
                throws Exception
Specified by:
destroy in class AbstractPollingIoAcceptor<org.apache.mina.transport.socket.nio.NioSession,ServerSocketChannel>
Throws:
Exception

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 interface: IoService
Returns the default configuration of the new IoSessions created by this service.

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

getLocalAddress

public InetSocketAddress getLocalAddress()
Description copied from interface: IoAcceptor
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 interface: IoAcceptor
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

isReuseAddress

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

setReuseAddress

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

getBacklog

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

Specified by:
getBacklog in interface SocketAcceptor

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

accept

protected org.apache.mina.transport.socket.nio.NioSession accept(IoProcessor<org.apache.mina.transport.socket.nio.NioSession> processor,
                                                                 ServerSocketChannel handle)
                                                          throws Exception
Specified by:
accept in class AbstractPollingIoAcceptor<org.apache.mina.transport.socket.nio.NioSession,ServerSocketChannel>
Throws:
Exception

open

protected ServerSocketChannel open(SocketAddress localAddress)
                            throws Exception
Specified by:
open in class AbstractPollingIoAcceptor<org.apache.mina.transport.socket.nio.NioSession,ServerSocketChannel>
Throws:
Exception

localAddress

protected SocketAddress localAddress(ServerSocketChannel handle)
                              throws Exception
Specified by:
localAddress in class AbstractPollingIoAcceptor<org.apache.mina.transport.socket.nio.NioSession,ServerSocketChannel>
Throws:
Exception

select

protected boolean select()
                  throws Exception
Specified by:
select in class AbstractPollingIoAcceptor<org.apache.mina.transport.socket.nio.NioSession,ServerSocketChannel>
Throws:
Exception

selectedHandles

protected Iterator<ServerSocketChannel> selectedHandles()
Specified by:
selectedHandles in class AbstractPollingIoAcceptor<org.apache.mina.transport.socket.nio.NioSession,ServerSocketChannel>

close

protected void close(ServerSocketChannel handle)
              throws Exception
Specified by:
close in class AbstractPollingIoAcceptor<org.apache.mina.transport.socket.nio.NioSession,ServerSocketChannel>
Throws:
Exception

wakeup

protected void wakeup()
Specified by:
wakeup in class AbstractPollingIoAcceptor<org.apache.mina.transport.socket.nio.NioSession,ServerSocketChannel>


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