Package de.gebit.integrity.remoting.transport

## Class ServerEndpoint

- java.lang.Object
- - de.gebit.integrity.remoting.transport.ServerEndpoint

-     public class ServerEndpoint
      extends Object

  A server endpoint. This endpoint listens on a specified port and host IP for incoming connections from client endpoints. When a connection is established, it spawns a new `Endpoint` for that specific connection and continues listening for more connections.
  Author:
    Rene Schneider - initial API and implementation

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `ServerEndpoint​(String aHostIP, int aPort, Map<Class<? extends AbstractMessage>,​MessageProcessor<?>> aProcessorMap, ClassLoader aClassLoader, boolean anIsForkFlag)` | Creates a new server endpoint that listens on a specified port/IP.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `broadcastMessage​(AbstractMessage aMessage)` | Broadcasts a message to all active endpoints.
    `void` | `closeAll​(boolean anEmptyOutputQueueFlag)` | Closes the server endpoint and all endpoints currently active.
    `int` | `getPort()` | Returns the port number on which the server endpoint is listening.
    `boolean` | `isActive()` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ServerEndpoint

          public ServerEndpoint​(String aHostIP,
                                int aPort,
                                Map<Class<? extends AbstractMessage>,​MessageProcessor<?>> aProcessorMap,
                                ClassLoader aClassLoader,
                                boolean anIsForkFlag)
                         throws UnknownHostException,
                                IOException

      Creates a new server endpoint that listens on a specified port/IP.
      Parameters:
        `aHostIP` - the host IP to listen on
        `aPort` - the port to bind to (0 = auto-choose a free port)
        `aProcessorMap` - the map of processors to use for processing incoming messages
        `aClassLoader` - the classloader to use when deserializing objects
        `anIsForkFlag` - whether this server endpoint is serving inside an Integrity fork process
      Throws:
        `UnknownHostException`
        `IOException`

  - ### Method Detail

    - #### isActive

          public boolean isActive()

    - #### getPort

          public int getPort()

      Returns the port number on which the server endpoint is listening.
      Returns:

    - #### closeAll

          public void closeAll​(boolean anEmptyOutputQueueFlag)

      Closes the server endpoint and all endpoints currently active.
      Parameters:
        `anEmptyOutputQueueFlag` - whether output queues to the endpoints shall be emptied before closing the connection.

    - #### broadcastMessage

          public void broadcastMessage​(AbstractMessage aMessage)

      Broadcasts a message to all active endpoints.
      Parameters:
        `aMessage` - the message