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

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.AbstractPollingConnectionlessIoAcceptor<NioSession,DatagramChannel>
              extended by org.apache.mina.transport.socket.nio.NioDatagramAcceptor
All Implemented Interfaces:
IoAcceptor, IoService, DatagramAcceptor

public final class NioDatagramAcceptor
extends AbstractPollingConnectionlessIoAcceptor<NioSession,DatagramChannel>
implements DatagramAcceptor

IoAcceptor for datagram transport (UDP/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.service.AbstractIoAcceptor
bindLock
 
Fields inherited from class org.apache.mina.core.service.AbstractIoService
disposalLock
 
Constructor Summary
NioDatagramAcceptor()
          Creates a new instance.
NioDatagramAcceptor(Executor executor)
          Creates a new instance.
 
Method Summary
protected  void close(DatagramChannel handle)
           
protected  void destroy()
           
 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.
 DatagramSessionConfig 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()
           
protected  boolean isReadable(DatagramChannel handle)
           
protected  boolean isWritable(DatagramChannel handle)
           
protected  SocketAddress localAddress(DatagramChannel handle)
           
protected  NioSession newSession(IoProcessor<NioSession> processor, DatagramChannel handle, SocketAddress remoteAddress)
           
protected  DatagramChannel open(SocketAddress localAddress)
           
protected  SocketAddress receive(DatagramChannel handle, IoBuffer buffer)
           
protected  int select()
           
protected  int select(long timeout)
           
protected  Iterator<DatagramChannel> selectedHandles()
           
protected  int send(NioSession session, IoBuffer buffer, SocketAddress remoteAddress)
           
 void setDefaultLocalAddress(InetSocketAddress localAddress)
           
protected  void setInterestedInWrite(NioSession session, boolean isInterested)
           
protected  void wakeup()
           
 
Methods inherited from class org.apache.mina.core.polling.AbstractPollingConnectionlessIoAcceptor
bindInternal, dispose0, getSessionRecycler, newSession, setSessionRecycler, 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, 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.transport.socket.DatagramAcceptor
getSessionRecycler, setSessionRecycler
 
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, dispose, getActivationTime, getFilterChain, getFilterChainBuilder, getHandler, getManagedSessionCount, getManagedSessions, getScheduledWriteBytes, getScheduledWriteMessages, getSessionDataStructureFactory, getStatistics, isActive, isDisposed, isDisposing, removeListener, setFilterChainBuilder, setHandler, setSessionDataStructureFactory
 

Constructor Detail

NioDatagramAcceptor

public NioDatagramAcceptor()
Creates a new instance.


NioDatagramAcceptor

public NioDatagramAcceptor(Executor executor)
Creates a new instance.

Method Detail

init

protected void init()
             throws Exception
Specified by:
init in class AbstractPollingConnectionlessIoAcceptor<NioSession,DatagramChannel>
Throws:
Exception

destroy

protected void destroy()
                throws Exception
Specified by:
destroy in class AbstractPollingConnectionlessIoAcceptor<NioSession,DatagramChannel>
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 DatagramSessionConfig getSessionConfig()
Description copied from class: AbstractIoService
Returns the default configuration of the new IoSessions created by this service.

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

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 DatagramAcceptor
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 DatagramAcceptor
Overrides:
getDefaultLocalAddress in class AbstractIoAcceptor

setDefaultLocalAddress

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

open

protected DatagramChannel open(SocketAddress localAddress)
                        throws Exception
Specified by:
open in class AbstractPollingConnectionlessIoAcceptor<NioSession,DatagramChannel>
Throws:
Exception

isReadable

protected boolean isReadable(DatagramChannel handle)
Specified by:
isReadable in class AbstractPollingConnectionlessIoAcceptor<NioSession,DatagramChannel>

isWritable

protected boolean isWritable(DatagramChannel handle)
Specified by:
isWritable in class AbstractPollingConnectionlessIoAcceptor<NioSession,DatagramChannel>

localAddress

protected SocketAddress localAddress(DatagramChannel handle)
                              throws Exception
Specified by:
localAddress in class AbstractPollingConnectionlessIoAcceptor<NioSession,DatagramChannel>
Throws:
Exception

newSession

protected NioSession newSession(IoProcessor<NioSession> processor,
                                DatagramChannel handle,
                                SocketAddress remoteAddress)
Specified by:
newSession in class AbstractPollingConnectionlessIoAcceptor<NioSession,DatagramChannel>

receive

protected SocketAddress receive(DatagramChannel handle,
                                IoBuffer buffer)
                         throws Exception
Specified by:
receive in class AbstractPollingConnectionlessIoAcceptor<NioSession,DatagramChannel>
Throws:
Exception

select

protected int select()
              throws Exception
Specified by:
select in class AbstractPollingConnectionlessIoAcceptor<NioSession,DatagramChannel>
Throws:
Exception

select

protected int select(long timeout)
              throws Exception
Specified by:
select in class AbstractPollingConnectionlessIoAcceptor<NioSession,DatagramChannel>
Throws:
Exception

selectedHandles

protected Iterator<DatagramChannel> selectedHandles()
Specified by:
selectedHandles in class AbstractPollingConnectionlessIoAcceptor<NioSession,DatagramChannel>

send

protected int send(NioSession session,
                   IoBuffer buffer,
                   SocketAddress remoteAddress)
            throws Exception
Specified by:
send in class AbstractPollingConnectionlessIoAcceptor<NioSession,DatagramChannel>
Throws:
Exception

setInterestedInWrite

protected void setInterestedInWrite(NioSession session,
                                    boolean isInterested)
                             throws Exception
Specified by:
setInterestedInWrite in class AbstractPollingConnectionlessIoAcceptor<NioSession,DatagramChannel>
Throws:
Exception

close

protected void close(DatagramChannel handle)
              throws Exception
Specified by:
close in class AbstractPollingConnectionlessIoAcceptor<NioSession,DatagramChannel>
Throws:
Exception

wakeup

protected void wakeup()
Specified by:
wakeup in class AbstractPollingConnectionlessIoAcceptor<NioSession,DatagramChannel>


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