public abstract class HL7Service extends Service
An HL7 service. Accepts incoming TCP/IP connections and creates Connection objects. Uses a single ApplicationRouter object (for all Connections) to define the Applications to which message are sent. To configure, use registerApplication() or loadApplicationsFromFile().
A separate thread looks for Connections that have been closed (locally or remotely) and discards them.Constructor and Description |
---|
HL7Service(HapiContext theHapiContext) |
HL7Service(Parser parser,
LowerLayerProtocol llp) |
HL7Service(Parser parser,
LowerLayerProtocol llp,
ExecutorService executorService)
Creates a new instance of Server
|
Modifier and Type | Method and Description |
---|---|
protected void |
afterStartup()
Called after startup before the thread enters its main loop.
|
protected void |
afterTermination()
Called after the thread has left its main loop.
|
Connection |
getRemoteConnection(String ipAddress)
Returns a connection to a remote host that was initiated by the given
remote host.
|
List<Connection> |
getRemoteConnections()
Returns all currently active connections.
|
protected boolean |
keepRunning()
Deprecated.
Use
Service.isRunning() . Deprecated as of version 0.6. |
void |
loadApplicationsFromFile(File f)
A convenience method for registering applications (using
registerApplication()
) with this service. |
void |
newConnection(ActiveConnection c)
Called by subclasses when a new Connection is made.
|
void |
registerApplication(ApplicationRouter.AppRoutingData appRouting,
ReceivingApplication<? extends Message> application)
Registers the given application to handle messages corresponding to ALL
message types and trigger events.
|
void |
registerApplication(ReceivingApplication<? extends Message> application)
Registers the given application to handle messages corresponding to ALL
message types and trigger events.
|
void |
registerApplication(String messageType,
String triggerEvent,
Application handler)
|
void |
registerApplication(String messageType,
String triggerEvent,
ReceivingApplication handler)
Registers the given application to handle messages corresponding to the
given type and trigger event.
|
void |
registerConnectionListener(ConnectionListener listener)
Registers the given ConnectionListener with the HL7Service - when a
remote host makes a new Connection, all registered listeners will be
notified.
|
void |
setExceptionHandler(ReceivingApplicationExceptionHandler exHandler)
Sets an exception handler which will be invoked in the event of a
failure during parsing, processing, or encoding of an
incoming message or its response.
|
boolean |
unregisterApplication(ApplicationRouter.AppRoutingData appRouting)
Unregisteres the first application that matches the routing data
|
boolean |
unregisterApplication(ReceivingApplication<? extends Message> application)
Unregisteres the passed application
|
getExecutorService, getServiceExitedWithException, handle, isRunning, prepareTermination, run, setServiceExitedWithException, setShutdownTimeout, start, startAndWait, stop, stopAndWait, waitForTermination
public HL7Service(HapiContext theHapiContext)
theHapiContext
- HapiContextpublic HL7Service(Parser parser, LowerLayerProtocol llp)
parser
- parser to be usedllp
- LowerLayerProtocolpublic HL7Service(Parser parser, LowerLayerProtocol llp, ExecutorService executorService)
parser
- parser to be usedllp
- LowerLayerProtocolexecutorService
- executor used for starting threadsprotected void afterStartup()
ServerSocket
s etc.afterStartup
in class Service
protected void afterTermination()
ServerSocket
s.afterTermination
in class Service
protected boolean keepRunning()
Service.isRunning()
. Deprecated as of version 0.6.public void newConnection(ActiveConnection c)
c
- existing connectionpublic Connection getRemoteConnection(String ipAddress)
ipAddress
- IP Addresspublic List<Connection> getRemoteConnections()
public void registerConnectionListener(ConnectionListener listener)
listener
- connection listener to be calledpublic void registerApplication(String messageType, String triggerEvent, Application handler)
registerApplication(String, String, ca.uhn.hl7v2.protocol.ReceivingApplication)
and
AppWrapper
public void registerApplication(String messageType, String triggerEvent, ReceivingApplication handler)
public void registerApplication(ApplicationRouter.AppRoutingData appRouting, ReceivingApplication<? extends Message> application)
public void registerApplication(ReceivingApplication<? extends Message> application)
public boolean unregisterApplication(ApplicationRouter.AppRoutingData appRouting)
appRouting
- public boolean unregisterApplication(ReceivingApplication<? extends Message> application)
application
- receiving applicationpublic void setExceptionHandler(ReceivingApplicationExceptionHandler exHandler)
public void loadApplicationsFromFile(File f) throws IOException, HL7Exception, ClassNotFoundException, InstantiationException, IllegalAccessException
A convenience method for registering applications (using
registerApplication()
) with this service. Information about which Applications should
handle which messages is read from the given text file. Each line in the
file should have the following format (entries tab delimited):
message_type trigger_event application_class
message_type trigger_event application_class
Note that message type and event can be the wildcard "*", which means any.
For example, if you write an Application called org.yourorganiztion.ADTProcessor that processes several types of ADT messages, and another called org.yourorganization.ResultProcessor that processes result messages, you might have a file that looks like this:
ADT * org.yourorganization.ADTProcessor
ORU R01 org.yourorganization.ResultProcessor
Each class listed in this file must implement Application and must have a zero-argument constructor.
Copyright © 2001–2017 University Health Network. All rights reserved.