Class JobAgentServerConnection

All Implemented Interfaces:

public class JobAgentServerConnection
extends Object
implements AutoCloseable
This class is used by job agents to listen for incoming requests from client applications.
Last modified
$Date: 2018-12-12 15:41:10 +0100 (on, 12 dec 2018) $
  • Field Details

    • port

      private final int port
    • requestHandler

      private final RequestHandler requestHandler
    • logger

      private final org.slf4j.Logger logger
    • listener

      private Thread listener
  • Constructor Details

    • JobAgentServerConnection

      public JobAgentServerConnection​(int port, RequestHandler requestHandler, org.slf4j.Logger logger)
      Create a new server connection. The open() method must be called to start listening for incoming connections.
      port - The port to listing to for incoming connections
      requestHandler - A handler for taking care of incoming requests. The handler must be thread-safe and able to handle multiple requests at the same time
      logger - A logger object for logging debug and other information or null if no logging is wanted
  • Method Details

    • open

      public void open() throws IOException
      Start listening for incoming connections. This method starts a new listener thread that answers incoming requests. For each request a new thread is created and control is passed on to the RequestHandler. If a listener has already been create thi method does nothing.
      IOException - If there is an error
    • close

      public void close()
      Stop listening for incoming connections. The thread that listens for incoming connections is killed. Any executing requests are not affected by this method.
      Specified by:
      close in interface AutoCloseable
    • isListening

      public boolean isListening()
      Is a listener active or not for this server.
      TRUE if a listener is active, FALSE otherwise