Class Endpoint


  • public class Endpoint
    extends java.lang.Object
    An endpoint is a client- or serverside termination point of a message channel. The endpoint uses a TCP connection to transmit messages bidirectionally, with processors waiting for new messages to arrive.
    Author:
    Rene Schneider - initial API and implementation
    • Constructor Summary

      Constructors 
      Constructor Description
      Endpoint​(java.lang.String aHost, int aPort, java.util.Map<java.lang.Class<? extends AbstractMessage>,​MessageProcessor<?>> aProcessorMap, EndpointListener aListener, java.lang.ClassLoader aClassLoader)
      Creates a new endpoint and connects to a remote host, on which a ServerEndpoint is expected to run.
      Endpoint​(java.net.Socket aSocket, java.util.Map<java.lang.Class<? extends AbstractMessage>,​MessageProcessor<?>> aProcessorMap, EndpointListener aListener, java.lang.ClassLoader aClassLoader)
      Creates a new endpoint from a specific, already-connected socket.
    • Constructor Detail

      • Endpoint

        public Endpoint​(java.net.Socket aSocket,
                        java.util.Map<java.lang.Class<? extends AbstractMessage>,​MessageProcessor<?>> aProcessorMap,
                        EndpointListener aListener,
                        java.lang.ClassLoader aClassLoader)
        Creates a new endpoint from a specific, already-connected socket.
        Parameters:
        aSocket - the connected socket
        aProcessorMap - the processors
        aListener - the listener
        aClassLoader - the classloader to use when deserializing objects
      • Endpoint

        public Endpoint​(java.lang.String aHost,
                        int aPort,
                        java.util.Map<java.lang.Class<? extends AbstractMessage>,​MessageProcessor<?>> aProcessorMap,
                        EndpointListener aListener,
                        java.lang.ClassLoader aClassLoader)
                 throws java.net.UnknownHostException,
                        java.io.IOException
        Creates a new endpoint and connects to a remote host, on which a ServerEndpoint is expected to run.
        Parameters:
        aHost - the host name or IP
        aPort - the port to connect to
        aProcessorMap - the map of processors
        aListener - the listener
        aClassLoader - the classloader to use when deserializing objects
        Throws:
        java.net.UnknownHostException
        java.io.IOException
    • Method Detail

      • sendMessage

        public void sendMessage​(AbstractMessage aMessage)
        Sends a message. This queues the message into the outqueue, which is then emptied asynchronously by the outputProcessor.
        Parameters:
        aMessage - the message to send
      • isActive

        public boolean isActive()
      • isDisconnectRequested

        public boolean isDisconnectRequested()
      • close

        public void close​(boolean anEmptyOutputQueueFlag)
        Close the connection.
        Parameters:
        anEmptyOutputQueueFlag - whether the output queue shall be sent to the other endpoint before closing
      • instantiateKryo

        protected com.esotericsoftware.kryo.Kryo instantiateKryo()
        Instantiates the Kryo serialization framework.
        Returns:
        an instantiated and fully configured Kryo instance