ca.uhn.hl7v2.app
Class MessageTypeRouter

java.lang.Object
  extended by ca.uhn.hl7v2.app.MessageTypeRouter
All Implemented Interfaces:
Application, ApplicationExceptionHandler

public class MessageTypeRouter
extends Object
implements Application, ApplicationExceptionHandler

Routes messages to various Applications based on message type and trigger event. The router is told which Application to which to route various messages by calling the method registerApplication(...).

Author:
Bryan Tripp

Constructor Summary
MessageTypeRouter()
          Creates a new instance of MessageTypeRouter
 
Method Summary
 boolean canProcess(Message in)
          Returns true if at least one application has been registered to accept this type of message.
 String processException(String incomingMessage, String outgoingMessage, Exception e)
          Forwards the given exception to all Applications.
 Message processMessage(Message in)
          Forwards the given message to any Applications that have been registered to accept messages of that type and trigger event.
 void registerApplication(String messageType, String triggerEvent, Application handler)
          Registers the given application to handle messages corresponding to the given type and trigger event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageTypeRouter

public MessageTypeRouter()
Creates a new instance of MessageTypeRouter

Method Detail

canProcess

public boolean canProcess(Message in)
Returns true if at least one application has been registered to accept this type of message. Applications are registered using registerApplication(...).

Specified by:
canProcess in interface Application

processMessage

public Message processMessage(Message in)
                       throws ApplicationException
Forwards the given message to any Applications that have been registered to accept messages of that type and trigger event.

Specified by:
processMessage in interface Application
Throws:
ApplicationException - if no such Applications are registered, or if the underlying Application throws this exception during processing.

processException

public String processException(String incomingMessage,
                               String outgoingMessage,
                               Exception e)
                        throws HL7Exception
Forwards the given exception to all Applications.

Specified by:
processException in interface ApplicationExceptionHandler
Parameters:
incomingMessage - the incoming message. This is the raw message which was received from the external system
outgoingMessage - the outgoing message. The response NAK message generated by HAPI.
e - the exception
Returns:
The new outgoing message. This can be set to the value provided by HAPI in outgoingMessage, or may be replaced with another message.
Throws:
HL7Exception

registerApplication

public void registerApplication(String messageType,
                                String triggerEvent,
                                Application handler)
Registers the given application to handle messages corresponding to the given type and trigger event. Only one application can be registered for a given message type and trigger event combination. A repeated registration for a particular combination of type and trigger event over-writes the previous one. Use "*" as a wildcard (e.g. registerApplication("ADT", "*", myApp) would register your app for all ADT messages).



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