public class ApplicationRouterImpl extends Object implements ApplicationRouter
A default implementation of ApplicationRouter
ApplicationRouter.AppRoutingData
Modifier and Type | Field and Description |
---|---|
static AcknowledgmentCode |
DEFAULT_EXCEPTION_ACKNOWLEDGEMENT_CODE
The default acknowledgment code used in MSA-1 when generating a NAK (negative ACK) message
as a result of a processing exception.
|
static String |
RAW_MESSAGE_KEY
Key under which raw message text is stored in metadata Map sent to
ReceivingApplication s. |
METADATA_KEY_MESSAGE_CHARSET, METADATA_KEY_MESSAGE_CONTROL_ID, METADATA_KEY_SENDING_IP, METADATA_KEY_SENDING_PORT
Constructor and Description |
---|
ApplicationRouterImpl()
Deprecated.
|
ApplicationRouterImpl(HapiContext theContext) |
ApplicationRouterImpl(HapiContext theContext,
Parser theParser)
Deprecated.
define parser over context
|
ApplicationRouterImpl(Parser theParser)
Creates an instance that uses the specified
Parser . |
Modifier and Type | Method and Description |
---|---|
void |
bindApplication(ApplicationRouter.AppRoutingData theRoutingData,
ReceivingApplication<? extends Message> theApplication)
Associates the given application with the given message parameters, so that messages
with matching parameters will be sent there.
|
void |
disableBinding(ApplicationRouter.AppRoutingData theRoutingData)
Temporarily deactivates the binding on the given field data, if present.
|
void |
enableBinding(ApplicationRouter.AppRoutingData theRoutingData)
Undoes
disableBinding(AppRoutingData theRoutingData) . |
Parser |
getParser() |
boolean |
hasActiveBinding(ApplicationRouter.AppRoutingData theRoutingData) |
String |
logAndMakeErrorMessage(Exception e,
Segment inHeader,
Parser p,
String encoding)
Logs the given exception and creates an error message to send to the
remote system.
|
static boolean |
matches(ApplicationRouter.AppRoutingData theMessageData,
ApplicationRouter.AppRoutingData theReferenceData) |
Transportable |
processMessage(Transportable theMessage)
Attempts to route the given message to the associated
Application
and obtain a response. |
void |
setDefaultAcknowledgementMode(AcknowledgmentCode defaultAcknowledgementMode) |
void |
setExceptionHandler(ReceivingApplicationExceptionHandler theExceptionHandler)
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 |
unbindApplication(ApplicationRouter.AppRoutingData theRoutingData)
Removes the binding for the given message parameters
|
boolean |
unbindApplication(ReceivingApplication<? extends Message> theApplication)
Removes the binding for the given message parameters
|
public static final AcknowledgmentCode DEFAULT_EXCEPTION_ACKNOWLEDGEMENT_CODE
public static final String RAW_MESSAGE_KEY
ReceivingApplication
s.@Deprecated public ApplicationRouterImpl()
GenericParser
.public ApplicationRouterImpl(Parser theParser)
Parser
.theParser
- the parser used for converting between Message and
Transportablepublic ApplicationRouterImpl(HapiContext theContext)
public ApplicationRouterImpl(HapiContext theContext, Parser theParser)
Parser
.theContext
- HAPI contexttheParser
- the parser used for converting between Message and
Transportablepublic void setDefaultAcknowledgementMode(AcknowledgmentCode defaultAcknowledgementMode)
public Transportable processMessage(Transportable theMessage) throws HL7Exception
ApplicationRouter
Application
and obtain a response.processMessage
in interface ApplicationRouter
theMessage
- the message to routeHL7Exception
ApplicationRouter.processMessage(ca.uhn.hl7v2.protocol.Transportable)
public boolean hasActiveBinding(ApplicationRouter.AppRoutingData theRoutingData)
hasActiveBinding
in interface ApplicationRouter
theRoutingData
- message fields used in determining the appropriate destinationApplicationRouter.hasActiveBinding(ca.uhn.hl7v2.protocol.ApplicationRouter.AppRoutingData)
public void bindApplication(ApplicationRouter.AppRoutingData theRoutingData, ReceivingApplication<? extends Message> theApplication)
ApplicationRouter
Associates the given application with the given message parameters, so that messages with matching parameters will be sent there. Only one application can be registered for a given set of parameters: repeated registration for a particular combination over-writes the previous one.
Because of wildcards, there may be multiple registrations that match a given message. In this case, the first registered wins.
bindApplication
in interface ApplicationRouter
theRoutingData
- message fields used in determining the appropriate destinationtheApplication
- the application to which messages with these parameters should be
sentApplicationRouter.bindApplication(
ca.uhn.hl7v2.protocol.ApplicationRouter.AppRoutingData, ca.uhn.hl7v2.protocol.ReceivingApplication)
public boolean unbindApplication(ApplicationRouter.AppRoutingData theRoutingData)
ApplicationRouter
unbindApplication
in interface ApplicationRouter
ApplicationRouter.unbindApplication(ca.uhn.hl7v2.protocol.ApplicationRouter.AppRoutingData)
public boolean unbindApplication(ReceivingApplication<? extends Message> theApplication)
ApplicationRouter
unbindApplication
in interface ApplicationRouter
ApplicationRouter.unbindApplication(ca.uhn.hl7v2.protocol.ReceivingApplication)
public void disableBinding(ApplicationRouter.AppRoutingData theRoutingData)
ApplicationRouter
disableBinding
in interface ApplicationRouter
theRoutingData
- the fields that define a set of messages that are bound to
some Application
ApplicationRouter.disableBinding(ca.uhn.hl7v2.protocol.ApplicationRouter.AppRoutingData)
public void enableBinding(ApplicationRouter.AppRoutingData theRoutingData)
ApplicationRouter
disableBinding(AppRoutingData theRoutingData)
.enableBinding
in interface ApplicationRouter
theRoutingData
- the fields that define a set of messages that are bound to
some Application
ApplicationRouter.enableBinding(ca.uhn.hl7v2.protocol.ApplicationRouter.AppRoutingData)
public Parser getParser()
getParser
in interface ApplicationRouter
Parser
that is used to parse inbound messages
and encode outbound ones. It may be of interest to set certain parameters
of this parser.ApplicationRouter.getParser()
public void setExceptionHandler(ReceivingApplicationExceptionHandler theExceptionHandler)
setExceptionHandler
in interface ApplicationRouter
public static boolean matches(ApplicationRouter.AppRoutingData theMessageData, ApplicationRouter.AppRoutingData theReferenceData)
theMessageData
- routing data related to a particular messagetheReferenceData
- routing data related to a binding, which may include
wildcardspublic String logAndMakeErrorMessage(Exception e, Segment inHeader, Parser p, String encoding) throws HL7Exception
e
- exceptioninHeader
- MSH segment of incoming messagep
- parser to be usedencoding
- The encoding for the error message. If null
, uses
default encodingHL7Exception
- if an error occured during generation of the error messageCopyright © 2001–2017 University Health Network. All rights reserved.