Class ServerEndpoint


  • public class ServerEndpoint
    extends java.lang.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​(java.lang.String aHostIP, int aPort, java.util.Map<java.lang.Class<? extends AbstractMessage>,​MessageProcessor<?>> aProcessorMap, java.lang.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​(java.lang.String aHostIP,
                              int aPort,
                              java.util.Map<java.lang.Class<? extends AbstractMessage>,​MessageProcessor<?>> aProcessorMap,
                              java.lang.ClassLoader aClassLoader,
                              boolean anIsForkFlag)
                       throws java.net.UnknownHostException,
                              java.io.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:
        java.net.UnknownHostException
        java.io.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