org.apache.mina.service

## Class AbstractIoService

- java.lang.Object
- - org.apache.mina.service.AbstractIoService

- All Implemented Interfaces:
    IoService
  Direct Known Subclasses:
    AbstractIoClient, AbstractIoServer

      public abstract class AbstractIoService
      extends Object
      implements IoService

  Base implementation for `IoService`s.
  Author:
    Apache MINA Project

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected static class` | `AbstractIoService.ServiceState` The Service states

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected IoSessionConfig` | `config` the default session configuration
    `protected IoHandlerExecutor` | `ioHandlerExecutor` used for executing IoHandler event in another pool of thread (not in the low level I/O one)

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractIoService(IoHandlerExecutor eventExecutor)` Create an AbstractIoService

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `fireServiceActivated()` Inform all current the listeners of the service activation.
    `protected void` | `fireServiceInactivated()` Inform all current the listeners of the service desactivation.
    `IoFilter[]` | `getFilters()` Get the list of filters installed on this service
    `IoHandler` | `getIoHandler()` Get the `IoHandler` in charge of your business logic for this service.
    `IoHandlerExecutor` | `getIoHandlerExecutor()` Get the `IoHandlerExecutor` used for executing `IoHandler` events in another pool of thread (not in the low level I/O one).
    `Map<Long,IoSession>` | `getManagedSessions()` Returns the map of all sessions which are currently managed by this service.
    `protected void` | `initState()` Initialize the IoService state
    `boolean` | `isActive()`
    `boolean` | `isCreated()`
    `boolean` | `isDisposed()`
    `boolean` | `isDisposing()`
    `boolean` | `isSuspended()`
    `protected void` | `setActive()` Sets the IoService state to ACTIVE.
    `protected void` | `setCreated()` Sets the IoService state to CREATED.
    `protected void` | `setDisposed()` Sets the IoService state to DISPOSED.
    `protected void` | `setDisposing()` Sets the IoService state to DISPOSING.
    `void` | `setFilters(IoFilter... filters)` Set the list of filters for this service.
    `void` | `setIoHandler(IoHandler handler)` Set the `IoHandler` in charge of your business logic for this service.
    `protected void` | `setSuspended()` Sets the IoService state to SUSPENDED.

    - ### 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.api.IoService

      `getSessionConfig`

- - ### Field Detail

    - #### config

          protected IoSessionConfig config

      the default session configuration

    - #### ioHandlerExecutor

          protected final IoHandlerExecutor ioHandlerExecutor

      used for executing IoHandler event in another pool of thread (not in the low level I/O one)

  - ### Constructor Detail

    - #### AbstractIoService

          protected AbstractIoService(IoHandlerExecutor eventExecutor)

      Create an AbstractIoService
      Parameters:
        `eventExecutor` - used for executing IoHandler event in another pool of thread (not in the low level I/O one). Use `null` if you don't want one. Be careful, the IoHandler processing will block the I/O operations.

  - ### Method Detail

    - #### getManagedSessions

          public Map<Long,IoSession> getManagedSessions()

      Returns the map of all sessions which are currently managed by this service. The key of map is the `ID` of the session.
      Specified by:
        `getManagedSessions` in interface `IoService`
      Returns:
        the sessions. An empty collection if there's no session.

    - #### setIoHandler

          public void setIoHandler(IoHandler handler)

      Set the `IoHandler` in charge of your business logic for this service.
      Specified by:
        `setIoHandler` in interface `IoService`
      Parameters:
        `handler` - the handler called for every event of the service (new connections, messages received, etc..)

    - #### getIoHandler

          public IoHandler getIoHandler()

      Get the `IoHandler` in charge of your business logic for this service.
      Specified by:
        `getIoHandler` in interface `IoService`
      Returns:
        the handler called for every event of the service (new connections, messages received, etc..)

    - #### getIoHandlerExecutor

          public IoHandlerExecutor getIoHandlerExecutor()

      Get the `IoHandlerExecutor` used for executing `IoHandler` events in another pool of thread (not in the low level I/O one).
      Specified by:
        `getIoHandlerExecutor` in interface `IoService`

    - #### isActive

          public boolean isActive()

      Returns:
        true if the IoService is active

    - #### isDisposing

          public boolean isDisposing()

      Returns:
        true if the IoService is being disposed

    - #### isDisposed

          public boolean isDisposed()

      Returns:
        true if the IoService is disposed

    - #### isSuspended

          public boolean isSuspended()

      Returns:
        true if the IoService is suspended

    - #### isCreated

          public boolean isCreated()

      Returns:
        true if the IoService is created

    - #### setCreated

          protected void setCreated()

      Sets the IoService state to CREATED.

    - #### setActive

          protected void setActive()

      Sets the IoService state to ACTIVE.

    - #### setDisposed

          protected void setDisposed()

      Sets the IoService state to DISPOSED.

    - #### setDisposing

          protected void setDisposing()

      Sets the IoService state to DISPOSING.

    - #### setSuspended

          protected void setSuspended()

      Sets the IoService state to SUSPENDED.

    - #### initState

          protected void initState()

      Initialize the IoService state

    - #### fireServiceActivated

          protected void fireServiceActivated()

      Inform all current the listeners of the service activation.

    - #### fireServiceInactivated

          protected void fireServiceInactivated()

      Inform all current the listeners of the service desactivation.

    - #### getFilters

          public IoFilter[] getFilters()

      Get the list of filters installed on this service
      Specified by:
        `getFilters` in interface `IoService`
      Returns:
        The list of installed filters

    - #### setFilters

          public void setFilters(IoFilter... filters)

      Set the list of filters for this service. Must be called before the service is bound/connected
      Specified by:
        `setFilters` in interface `IoService`

Copyright © 2009–2013 Apache MINA Project. All rights reserved.