Class SimpleServer

All Implemented Interfaces:
Runnable

public class SimpleServer extends HL7Service

A simple TCP/IP-based HL7 server. This server listens for connections on a particular port, and creates a ConnectionManager for each incoming connection.

A single SimpleServer can only service requests that use a single class of LowerLayerProtocol (specified at construction time).

The ConnectionManager uses a PipeParser of the version specified in the constructor

ConnectionManagers currently only support original mode processing.

The ConnectionManager routes messages to various Applications based on message type. From the HL7 perspective, an Application is something that does something with a message.

Author:
Bryan Tripp, Christian Ohr
  • Field Details

  • Constructor Details

    • SimpleServer

      public SimpleServer(int port)
      Creates a new instance of SimpleServer that listens on the given port, using the MinLowerLayerProtocol and a standard PipeParser.
    • SimpleServer

      public SimpleServer(int port, boolean tls)
      Creates a new instance of SimpleServer that listens on the given port, using the MinLowerLayerProtocol and a standard PipeParser.
    • SimpleServer

      public SimpleServer(int port, LowerLayerProtocol llp, Parser parser)
      Creates a new instance of SimpleServer that listens on the given port.
    • SimpleServer

      public SimpleServer(int port, LowerLayerProtocol llp, Parser parser, boolean tls)
      Creates a new instance of SimpleServer that listens on the given port.
    • SimpleServer

      public SimpleServer(int port, LowerLayerProtocol llp, Parser parser, boolean tls, ExecutorService executorService)
      Creates a new instance of SimpleServer using a custom {link ExecutorService. This ExecutorService instance will not be shut down after the server stops!
    • SimpleServer

      public SimpleServer(HapiContext hapiContext, int port, boolean tls)
      Creates a new instance of SimpleServer that listens on a given server socket. SimpleServer will bind the socket when it is started, so the server socket must not already be bound.
      Throws:
      IllegalStateException - If serverSocket is already bound
      Since:
      2.1
    • SimpleServer

      public SimpleServer(HapiContext hapiContext, int port, boolean tls, boolean acceptAll)
      Creates a new instance of SimpleServer that listens on a given server socket and will pass all messages to the responders, even if the message control id is not known to the server. SimpleServer will bind the socket when it is started, so the server socket must not already be bound.
      Throws:
      IllegalStateException - If serverSocket is already bound
      Since:
      2.4
  • Method Details

    • afterStartup

      protected void afterStartup()
      Prepare server by initializing the server socket
      Overrides:
      afterStartup in class HL7Service
      See Also:
    • handle

      protected void handle()
      Loop that waits for a connection and starts a ConnectionManager when it gets one.
      Specified by:
      handle in class Service
    • afterTermination

      protected void afterTermination()
      Close down socket
      Overrides:
      afterTermination in class HL7Service
    • main

      public static void main(String[] args)
      Run server from command line. Port number should be passed as an argument, and a file containing a list of Applications to use can also be specified as an optional argument (as per loadApplicationsFromFile(...)). Uses the default LowerLayerProtocol.