Package ca.uhn.hl7v2.protocol.impl
Class ApplicationRouterImpl
java.lang.Object
ca.uhn.hl7v2.protocol.impl.ApplicationRouterImpl
- All Implemented Interfaces:
ApplicationRouter
A default implementation of ApplicationRouter
- Version:
- $Revision: 1.2 $ updated on $Date: 2009-09-01 00:22:23 $ by $Author: jamesagnew $
- Author:
- Bryan Tripp
-
Nested Class Summary
Nested classes/interfaces inherited from interface ca.uhn.hl7v2.protocol.ApplicationRouter
ApplicationRouter.AppRoutingData -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final AcknowledgmentCodeThe default acknowledgment code used in MSA-1 when generating a NAK (negative ACK) message as a result of a processing exception.static final StringKey under which raw message text is stored in metadata Map sent toReceivingApplications.Fields inherited from interface ca.uhn.hl7v2.protocol.ApplicationRouter
METADATA_KEY_MESSAGE_CHARSET, METADATA_KEY_MESSAGE_CONTROL_ID, METADATA_KEY_SENDING_IP, METADATA_KEY_SENDING_PORT -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.ApplicationRouterImpl(HapiContext theContext) ApplicationRouterImpl(HapiContext theContext, Parser theParser) Deprecated.define parser over contextApplicationRouterImpl(Parser theParser) Creates an instance that uses the specifiedParser. -
Method Summary
Modifier and TypeMethodDescriptionvoidbindApplication(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.voiddisableBinding(ApplicationRouter.AppRoutingData theRoutingData) Temporarily deactivates the binding on the given field data, if present.voidenableBinding(ApplicationRouter.AppRoutingData theRoutingData) UndoesdisableBinding(AppRoutingData theRoutingData).booleanhasActiveBinding(ApplicationRouter.AppRoutingData theRoutingData) 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 booleanmatches(ApplicationRouter.AppRoutingData theMessageData, ApplicationRouter.AppRoutingData theReferenceData) processMessage(Transportable theMessage) Attempts to route the given message to the associatedApplicationand obtain a response.voidsetDefaultAcknowledgementMode(AcknowledgmentCode defaultAcknowledgementMode) voidsetExceptionHandler(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.booleanunbindApplication(ApplicationRouter.AppRoutingData theRoutingData) Removes the binding for the given message parametersbooleanunbindApplication(ReceivingApplication<? extends Message> theApplication) Removes the binding for the given message parameters
-
Field Details
-
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. -
RAW_MESSAGE_KEY
Key under which raw message text is stored in metadata Map sent toReceivingApplications.- See Also:
-
-
Constructor Details
-
ApplicationRouterImpl
Deprecated.Creates an instance that uses aGenericParser. -
ApplicationRouterImpl
Creates an instance that uses the specifiedParser.- Parameters:
theParser- the parser used for converting between Message and Transportable
-
ApplicationRouterImpl
-
ApplicationRouterImpl
Deprecated.define parser over contextCreates an instance that uses the specifiedParser.- Parameters:
theContext- HAPI contexttheParser- the parser used for converting between Message and Transportable
-
-
Method Details
-
setDefaultAcknowledgementMode
-
processMessage
Description copied from interface:ApplicationRouterAttempts to route the given message to the associatedApplicationand obtain a response.- Specified by:
processMessagein interfaceApplicationRouter- Parameters:
theMessage- the message to route- Returns:
- the response message (this may be null, for example if the given message doesn't require an application ACK)
- Throws:
HL7Exception- See Also:
-
hasActiveBinding
- Specified by:
hasActiveBindingin interfaceApplicationRouter- Parameters:
theRoutingData- message fields used in determining the appropriate destination- Returns:
- true if there is a destination application for messages with the given characteristics
- See Also:
-
bindApplication
public void bindApplication(ApplicationRouter.AppRoutingData theRoutingData, ReceivingApplication<? extends Message> theApplication) Description copied from interface:ApplicationRouterAssociates 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.
- Specified by:
bindApplicationin interfaceApplicationRouter- Parameters:
theRoutingData- message fields used in determining the appropriate destinationtheApplication- the application to which messages with these parameters should be sent- See Also:
-
unbindApplication
Description copied from interface:ApplicationRouterRemoves the binding for the given message parameters- Specified by:
unbindApplicationin interfaceApplicationRouter- Returns:
- true if an application was unbound, false otherwise
- See Also:
-
unbindApplication
Description copied from interface:ApplicationRouterRemoves the binding for the given message parameters- Specified by:
unbindApplicationin interfaceApplicationRouter- Returns:
- true if an application was unbound, false otherwise
- See Also:
-
disableBinding
Description copied from interface:ApplicationRouterTemporarily deactivates the binding on the given field data, if present.- Specified by:
disableBindingin interfaceApplicationRouter- Parameters:
theRoutingData- the fields that define a set of messages that are bound to someApplication- See Also:
-
enableBinding
Description copied from interface:ApplicationRouterUndoesdisableBinding(AppRoutingData theRoutingData).- Specified by:
enableBindingin interfaceApplicationRouter- Parameters:
theRoutingData- the fields that define a set of messages that are bound to someApplication- See Also:
-
getParser
- Specified by:
getParserin interfaceApplicationRouter- Returns:
- the
Parserthat is used to parse inbound messages and encode outbound ones. It may be of interest to set certain parameters of this parser. - See Also:
-
setExceptionHandler
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.- Specified by:
setExceptionHandlerin interfaceApplicationRouter
-
matches
public static boolean matches(ApplicationRouter.AppRoutingData theMessageData, ApplicationRouter.AppRoutingData theReferenceData) - Parameters:
theMessageData- routing data related to a particular messagetheReferenceData- routing data related to a binding, which may include wildcards- Returns:
- true if the message data is consist with the reference data, ie all values either match or are wildcards in the reference
-
logAndMakeErrorMessage
public String logAndMakeErrorMessage(Exception e, Segment inHeader, Parser p, String encoding) throws HL7Exception Logs the given exception and creates an error message to send to the remote system.- Parameters:
e- exceptioninHeader- MSH segment of incoming messagep- parser to be usedencoding- The encoding for the error message. Ifnull, uses default encoding- Returns:
- error message as string
- Throws:
HL7Exception- if an error occured during generation of the error message
-