org.apache.mina.core.polling

## Class AbstractPollingConnectionlessIoAcceptor<S extends AbstractIoSession,H>

- java.lang.Object
- - org.apache.mina.core.service.AbstractIoService
  - - org.apache.mina.core.service.AbstractIoAcceptor
    - - org.apache.mina.core.polling.AbstractPollingConnectionlessIoAcceptor<S,H>

- Type Parameters:
    `S` - the type of the `IoSession` this processor can handle
  All Implemented Interfaces:
    IoAcceptor, IoProcessor<S>, IoService
  Direct Known Subclasses:
    NioDatagramAcceptor

      public abstract class AbstractPollingConnectionlessIoAcceptor<S extends AbstractIoSession,H>
      extends AbstractIoAcceptor
      implements IoProcessor<S>

  `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

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractPollingConnectionlessIoAcceptor(IoSessionConfig sessionConfig)` Creates a new instance.
    `protected` | `AbstractPollingConnectionlessIoAcceptor(IoSessionConfig sessionConfig, Executor executor)` Creates a new instance.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(S session)` Adds the specified `session` to the I/O processor so that the I/O processor starts to perform any I/O operations related with the `session`.
    `protected Set<SocketAddress>` | `bindInternal(List<? extends SocketAddress> localAddresses)` Starts the acceptor, and register the given addresses
    `protected abstract void` | `close(H handle)`
    `protected abstract void` | `destroy()`
    `protected void` | `dispose0()` Implement this method to release any acquired resources.
    `void` | `flush(S session)` Flushes the internal write request queue of the specified `session`.
    `IoSessionRecycler` | `getSessionRecycler()`
    `protected abstract void` | `init()`
    `protected abstract boolean` | `isReadable(H handle)`
    `protected abstract boolean` | `isWritable(H handle)`
    `protected abstract SocketAddress` | `localAddress(H handle)`
    `protected abstract S` | `newSession(IoProcessor<S> processor, H handle, SocketAddress remoteAddress)`
    `IoSession` | `newSession(SocketAddress remoteAddress, SocketAddress localAddress)` (Optional) Returns an `IoSession` that is bound to the specified `localAddress` and the specified `remoteAddress` which reuses the local address that is already bound by this service.
    `protected abstract H` | `open(SocketAddress localAddress)`
    `protected abstract SocketAddress` | `receive(H handle, IoBuffer buffer)`
    `void` | `remove(S session)` Removes and closes the specified `session` from the I/O processor so that the I/O processor closes the connection associated with the `session` and releases any other related resources.
    `protected abstract int` | `select()`
    `protected abstract int` | `select(long timeout)`
    `protected abstract Set<SelectionKey>` | `selectedHandles()`
    `protected abstract int` | `send(S session, IoBuffer buffer, SocketAddress remoteAddress)`
    `protected abstract void` | `setInterestedInWrite(S session, boolean interested)`
    `void` | `setSessionRecycler(IoSessionRecycler sessionRecycler)`
    `protected void` | `unbind0(List<? extends SocketAddress> localAddresses)` Implement this method to perform the actual unbind operation.
    `void` | `updateTrafficControl(S session)` Controls the traffic of the specified `session` depending of the `IoSession.isReadSuspended()` and `IoSession.isWriteSuspended()` flags
    `protected abstract void` | `wakeup()`
    `void` | `write(S session, WriteRequest writeRequest)` Writes the WriteRequest for the specified `session`.

    - ### Methods inherited from class org.apache.mina.core.service.AbstractIoAcceptor

      `bind, bind, bind, bind, bind, getDefaultLocalAddress, getDefaultLocalAddresses, getLocalAddress, 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, getSessionConfig, 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.IoProcessor

      `dispose, isDisposed, isDisposing`

    - ### Methods inherited from interface org.apache.mina.core.service.IoService

      `addListener, broadcast, dispose, dispose, getActivationTime, getFilterChain, getFilterChainBuilder, getHandler, getManagedSessionCount, getManagedSessions, getScheduledWriteBytes, getScheduledWriteMessages, getSessionConfig, getSessionDataStructureFactory, getStatistics, getTransportMetadata, isActive, isDisposed, isDisposing, removeListener, setFilterChainBuilder, setHandler, setSessionDataStructureFactory`

- - ### Constructor Detail

    - #### AbstractPollingConnectionlessIoAcceptor

          protected AbstractPollingConnectionlessIoAcceptor(IoSessionConfig sessionConfig)

      Creates a new instance.

    - #### AbstractPollingConnectionlessIoAcceptor

          protected AbstractPollingConnectionlessIoAcceptor(IoSessionConfig sessionConfig,
                                                 Executor executor)

      Creates a new instance.

  - ### Method Detail

    - #### init

          protected abstract void init()
                                throws Exception

      Throws:
        `Exception`

    - #### destroy

          protected abstract void destroy()
                                   throws Exception

      Throws:
        `Exception`

    - #### select

          protected abstract int select()
                                 throws Exception

      Throws:
        `Exception`

    - #### select

          protected abstract int select(long timeout)
                                 throws Exception

      Throws:
        `Exception`

    - #### wakeup

          protected abstract void wakeup()

    - #### selectedHandles

          protected abstract Set<SelectionKey> selectedHandles()

    - #### open

          protected abstract H open(SocketAddress localAddress)
                             throws Exception

      Throws:
        `Exception`

    - #### close

          protected abstract void close(H handle)
                                 throws Exception

      Throws:
        `Exception`

    - #### localAddress

          protected abstract SocketAddress localAddress(H handle)
                                                 throws Exception

      Throws:
        `Exception`

    - #### isReadable

          protected abstract boolean isReadable(H handle)

    - #### isWritable

          protected abstract boolean isWritable(H handle)

    - #### receive

          protected abstract SocketAddress receive(H handle,
                              IoBuffer buffer)
                                            throws Exception

      Throws:
        `Exception`

    - #### send

          protected abstract int send(S session,
                 IoBuffer buffer,
                 SocketAddress remoteAddress)
                               throws Exception

      Throws:
        `Exception`

    - #### newSession

          protected abstract S newSession(IoProcessor<S> processor,
                     H handle,
                     SocketAddress remoteAddress)
                                                             throws Exception

      Throws:
        `Exception`

    - #### setInterestedInWrite

          protected abstract void setInterestedInWrite(S session,
                                  boolean interested)
                                                throws Exception

      Throws:
        `Exception`

    - #### dispose0

          protected void dispose0()
                           throws Exception

      Implement this method to release any acquired resources. This method is invoked only once by `AbstractIoService.dispose()`.
      Specified by:
        `dispose0` in class `AbstractIoService`
      Throws:
        `Exception`

    - #### bindInternal

          protected final Set<SocketAddress> bindInternal(List<? extends SocketAddress> localAddresses)
                                                   throws Exception

      Starts the acceptor, and register the given addresses
      Specified by:
        `bindInternal` in class `AbstractIoAcceptor`
      Returns:
        the `Set` of the local addresses which is bound actually
      Throws:
        `Exception`

    - #### unbind0

          protected final void unbind0(List<? extends SocketAddress> localAddresses)
                                throws Exception

      Implement this method to perform the actual unbind operation.
      Specified by:
        `unbind0` in class `AbstractIoAcceptor`
      Throws:
        `Exception`

    - #### newSession

          public final IoSession newSession(SocketAddress remoteAddress,
                             SocketAddress localAddress)

      (Optional) Returns an `IoSession` that is bound to the specified `localAddress` and the specified `remoteAddress` which reuses the local address that is already bound by this service.

      This operation is optional. Please throw `UnsupportedOperationException` if the transport type doesn't support this operation. This operation is usually implemented for connectionless transport types.

      Specified by:
        `newSession` in interface `IoAcceptor`

    - #### getSessionRecycler

          public final IoSessionRecycler getSessionRecycler()

    - #### setSessionRecycler

          public final void setSessionRecycler(IoSessionRecycler sessionRecycler)

    - #### add

          public void add(S session)

      Adds the specified `session` to the I/O processor so that the I/O processor starts to perform any I/O operations related with the `session`.
      Specified by:
        `add` in interface `IoProcessor<S extends AbstractIoSession>`
      Parameters:
        `session` - The added session

    - #### flush

          public void flush(S session)

      Flushes the internal write request queue of the specified `session`.
      Specified by:
        `flush` in interface `IoProcessor<S extends AbstractIoSession>`
      Parameters:
        `session` - The session we want the message to be written

    - #### write

          public void write(S session,
                   WriteRequest writeRequest)

      Writes the WriteRequest for the specified `session`.
      Specified by:
        `write` in interface `IoProcessor<S extends AbstractIoSession>`
      Parameters:
        `session` - The session we want the message to be written
        `writeRequest` - the WriteRequest to write

    - #### remove

          public void remove(S session)

      Removes and closes the specified `session` from the I/O processor so that the I/O processor closes the connection associated with the `session` and releases any other related resources.
      Specified by:
        `remove` in interface `IoProcessor<S extends AbstractIoSession>`

    - #### updateTrafficControl

          public void updateTrafficControl(S session)

      Controls the traffic of the specified `session` depending of the `IoSession.isReadSuspended()` and `IoSession.isWriteSuspended()` flags
      Specified by:
        `updateTrafficControl` in interface `IoProcessor<S extends AbstractIoSession>`

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