Package ca.uhn.hl7v2.app
Class SimpleServer
java.lang.Object
ca.uhn.hl7v2.concurrent.Service
ca.uhn.hl7v2.app.HL7Service
ca.uhn.hl7v2.app.SimpleServer
- All Implemented Interfaces:
Runnable
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
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSimpleServer(int port) Creates a new instance of SimpleServer that listens on the given port, using theMinLowerLayerProtocoland a standardPipeParser.SimpleServer(int port, boolean tls) Creates a new instance of SimpleServer that listens on the given port, using theMinLowerLayerProtocoland a standardPipeParser.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 {linkExecutorService.SimpleServer(HapiContext hapiContext, int port, boolean tls) Creates a new instance of SimpleServer that listens on a given server socket.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. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidPrepare server by initializing the server socketprotected voidClose down socketprotected voidhandle()Loop that waits for a connection and starts a ConnectionManager when it gets one.static voidRun server from command line.Methods inherited from class ca.uhn.hl7v2.app.HL7Service
getRemoteConnection, getRemoteConnections, keepRunning, loadApplicationsFromFile, newConnection, registerApplication, registerApplication, registerApplication, registerApplication, registerConnectionListener, setExceptionHandler, setParserExeptionHandler, unregisterApplication, unregisterApplicationMethods inherited from class ca.uhn.hl7v2.concurrent.Service
getExecutorService, getServiceExitedWithException, isRunning, prepareTermination, run, setServiceExitedWithException, setShutdownTimeout, start, startAndWait, stop, stopAndWait, waitForTermination
-
Field Details
-
SO_TIMEOUT
Socket timeout for simple server- See Also:
-
-
Constructor Details
-
SimpleServer
Creates a new instance of SimpleServer that listens on the given port, using theMinLowerLayerProtocoland a standardPipeParser. -
SimpleServer
Creates a new instance of SimpleServer that listens on the given port, using theMinLowerLayerProtocoland a standardPipeParser. -
SimpleServer
Creates a new instance of SimpleServer that listens on the given port. -
SimpleServer
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 {linkExecutorService. ThisExecutorServiceinstance will not be shut down after the server stops! -
SimpleServer
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
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
Prepare server by initializing the server socket- Overrides:
afterStartupin classHL7Service- See Also:
-
handle
Loop that waits for a connection and starts a ConnectionManager when it gets one. -
afterTermination
Close down socket- Overrides:
afterTerminationin classHL7Service
-
main
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 perloadApplicationsFromFile(...)). Uses the default LowerLayerProtocol.
-