ca.uhn.hl7v2.app
Class SimpleServer

java.lang.Object
  extended by ca.uhn.hl7v2.concurrent.Service
      extended by ca.uhn.hl7v2.app.HL7Service
          extended by ca.uhn.hl7v2.app.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 Summary
static int SO_TIMEOUT
          Socket timeout for simple server
 
Fields inherited from class ca.uhn.hl7v2.app.HL7Service
llp, parser
 
Constructor Summary
SimpleServer(int port)
          Creates a new instance of SimpleServer that listens on the given port, using the MinLowerLayerProtocol and a standard PipeParser.
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(int port, LowerLayerProtocol llp, Parser parser)
          Creates a new instance of SimpleServer that listens on the given port.
SimpleServer(int port, LowerLayerProtocol llp, Parser parser, boolean tls)
          Creates a new instance of SimpleServer that listens on the given port.
SimpleServer(int port, LowerLayerProtocol llp, Parser parser, boolean tls, ExecutorService executorService)
          Creates a new instance of SimpleServer using a custom {link ExecutorService.
 
Method Summary
protected  void afterStartup()
          Prepare server by initializing the server socket
protected  void afterTermination()
          Close down socket
protected  void handle()
          Loop that waits for a connection and starts a ConnectionManager when it gets one.
static void main(String[] args)
          Run server from command line.
 
Methods inherited from class ca.uhn.hl7v2.app.HL7Service
getRemoteConnection, getRemoteConnections, keepRunning, loadApplicationsFromFile, newConnection, registerApplication, registerConnectionListener
 
Methods inherited from class ca.uhn.hl7v2.concurrent.Service
getExecutorService, getServiceExitedWithException, isRunning, prepareTermination, run, setServiceExitedWithException, setShutdownTimeout, start, stop, stopAndWait, waitForTermination
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SO_TIMEOUT

public static final int SO_TIMEOUT
Socket timeout for simple server

See Also:
Constant Field Values
Constructor Detail

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!

Method Detail

afterStartup

protected void afterStartup()
Prepare server by initializing the server socket

Overrides:
afterStartup in class HL7Service
See Also:
HL7Service.afterStartup()

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.



Copyright © 2001-2012 University Health Network. All Rights Reserved.