Interface HapiContext
- All Superinterfaces:
AutoCloseable,Closeable
- All Known Implementing Classes:
DefaultHapiContext
- Configuring HAPI core services (e.g. parsing)
- Obtaining correspondingly configured instances of HAPI core services
ExecutorService: thread executors used for the HAPI networking features in ca.uhn.hl7v2.appLowerLayerProtocol: MLLP protocol used for the HAPI networking features in ca.uhn.hl7v2.appSocketFactory: Socket factory used for the HAPI networking features in ca.uhn.hl7v2.appParserConfiguration: detail configuration for all HL7 parsersModelClassFactory: lookup for message model classes during parsing or message creationValidationContext: validation rules used during parsing or during a dedcated validation stepValidationRuleBuilder: alternative way of providing a ValidationContextValidationExceptionHandlerFactory: factory for exception handler used during message validation
-
Method Summary
Modifier and TypeMethodDescriptionReturns a ca.uhn.hl7v2.conf.check.Validator instance.Deprecated.<R> Validator<R>Construct a new HL7 Client which will connect to an external TCP server for the purpose of sending messages (and receiving responses).Construct a new HL7 two-port client which will connect to an external TCP server for the purpose of sending messages (and receiving responses).newLazyClient(String host, int port, boolean tls) Construct a new HL7 Client which will connect to an external TCP server for the purpose of sending messages (and receiving responses).newLazyClient(String host, int outboundPort, int inboundPort, boolean tls) Construct a new HL7 two-port client which will connect to an external TCP server for the purpose of sending messages (and receiving responses).<T extends Message>
TnewMessage(Class<T> clazz) Creates a new message of the provided message structure class, without further initializing the messagenewMessage(String eventType, String triggerEvent, Version version) Creates a new message of the given event type, trigger and version, and initializes the message headernewServer(int port, boolean tls) Construct a new HL7 Server which will listen for incoming connectionsnewServer(int port, boolean tls, boolean acceptAll) Construct a new HL7 Server which will listen for incoming connections and will pass all messages to the responders, even if the message control id is not known to the servernewServer(int inboundPort, int outboundPort, boolean tls) Construct a new HL7 Server which will listen for a pair of connections (one for incoming messages, one for outgoing)voidvoidsetExecutorService(ExecutorService executorService) voidvoidsetModelClassFactory(ModelClassFactory modelClassFactory) voidsetParserConfiguration(ParserConfiguration configuration) voidsetProfileStore(ProfileStore store) voidsetServerConfiguration(ServerConfiguration theServerConfiguration) Sets theServerConfigurationto be used by all HL7 servers obtained from this class.voidsetSocketFactory(SocketFactory socketFactory) voidsetValidationContext(ValidationContext context) voidsetValidationContext(String contextClassName) Sets a defaultValidationContext.<R> voidvoidsetValidationRuleBuilder(ValidationRuleBuilder ruleBuilder) Sets a defaultValidationRuleBuilder.voidsetValidationRuleBuilder(String builderClassName) Sets a new instance ofValidationRuleBuilderas default.
-
Method Details
-
getExecutorService
- Returns:
- the
ExecutorServiceto be used by all services that spawn threads
-
setExecutorService
- Parameters:
executorService- theExecutorServiceto be used by all services that spawn threads
-
getConnectionHub
Deprecated.- Returns:
- a new ConnectionHub instance
-
getParserConfiguration
- Returns:
- the
ParserConfigurationto be used by all parsers obtained from this class.
-
getServerConfiguration
- Returns:
- the
ServerConfigurationto be used by all HL7 servers obtained from this class. - See Also:
-
setServerConfiguration
Sets theServerConfigurationto be used by all HL7 servers obtained from this class. -
setParserConfiguration
- Parameters:
configuration-ParserConfigurationto be used by all parsers obtained from this class.
-
getValidationContext
- Returns:
- the
ValidationContextto be used by all parsers obtained from this class.
-
setValidationContext
- Parameters:
context-ValidationContextto be used by all parsers obtained from this class.
-
setValidationContext
Sets a defaultValidationContext. Note that a defaultValidationRuleBuilderhas precedence of this ValidationContext.- Parameters:
contextClassName- class name of theValidationContextto be used by all parsers obtained from this class.
-
getValidationRuleBuilder
- Returns:
- the
ValidationRuleBuilderto be used by all parsers obtained from this class.
-
setValidationRuleBuilder
Sets a defaultValidationRuleBuilder. Note that thisValidationRuleBuilderhas precedence over a defaultValidationContextset withsetValidationContext(ValidationContext)orsetValidationContext(String)- Parameters:
ruleBuilder-ValidationRuleBuilderto be used by all parsers obtained from this class.
-
setValidationRuleBuilder
Sets a new instance ofValidationRuleBuilderas default. Note that thisValidationRuleBuilderhas precedence over a defaultValidationContextset withsetValidationContext(ValidationContext)orsetValidationContext(String)- Parameters:
builderClassName- class name of theValidationRuleBuilderto be used by all parsers obtained from this class.
-
getModelClassFactory
- Returns:
- the
ModelClassFactoryto be used by all parsers obtained from this class.
-
setModelClassFactory
- Parameters:
modelClassFactory- theModelClassFactoryto be used by all parsers obtained from this class.
-
getProfileStore
- Returns:
- the
ProfileStoreto be used for loading conformance profile files
-
setProfileStore
- Parameters:
store- theProfileStoreto be used for loading conformance profile files
-
getCodeStoreRegistry
- Returns:
- the
CodeStoreRegistryto be used for serving codes for conformance profiles
-
setCodeStoreRegistry
- Parameters:
store- theCodeStoreRegistryto be used for serving codes for conformance profiles
-
getPipeParser
- Returns:
- a new PipeParser instance initialized as set with
setModelClassFactory(ModelClassFactory),setValidationContext(String)andsetParserConfiguration(ParserConfiguration).
-
getXMLParser
- Returns:
- a new XMLParser instance initialized as set with
setModelClassFactory(ModelClassFactory),setValidationContext(String)andsetParserConfiguration(ParserConfiguration).
-
getGenericParser
- Returns:
- a new GenericParser instance initialized as set with
setModelClassFactory(ModelClassFactory),setValidationContext(String)andsetParserConfiguration(ParserConfiguration).
-
getConformanceValidator
Returns a ca.uhn.hl7v2.conf.check.Validator instance. It is recommended to usegetMessageValidator()and configure a Validation rule that checks a message against a conformance profile- Returns:
- a ca.uhn.hl7v2.conf.check.Validator instance initialized as set with
setCodeStoreRegistry(CodeStoreRegistry)
-
getMessageValidator
- Returns:
- a MessageValidator instance initialized with the
ValidationContextas set usingsetValidationContext(ValidationContext). For each validation it will use a new instance ofValidationExceptionHandleras obtained bygetValidationExceptionHandlerFactory().
-
getValidationExceptionHandlerFactory
-
setValidationExceptionHandlerFactory
- Parameters:
factory- aValidationExceptionHandlerFactorythat is used to create aValidationExceptionHandlerduring message validation.
-
getLowerLayerProtocol
- Returns:
- the
LowerLayerProtocolinstance used by all HL7 MLLP operations
-
setLowerLayerProtocol
- Parameters:
llp- theLowerLayerProtocolinstance used by all HL7 MLLP operations
-
getSocketFactory
- Returns:
- the
SocketFactoryinstance used by HL7 networking operations
-
setSocketFactory
- Parameters:
socketFactory- theSocketFactoryinstance used by HL7 networking operations
-
newServer
Construct a new HL7 Server which will listen for incoming connections- Parameters:
port- The port on which to listen for new connectionstls- Whether or not to use SSL/TLS- Returns:
- HL7 service running on the configured port using the default parser and executor
service instances provided by this interface. Note that the returned service will not
be started, and must manually be started using
Service.start()orService.startAndWait() - See Also:
-
- here for an example of how to use this method
setSocketFactory(SocketFactory)
-
newServer
Construct a new HL7 Server which will listen for incoming connections and will pass all messages to the responders, even if the message control id is not known to the server- Parameters:
port- The port on which to listen for new connectionstls- Whether or not to use SSL/TLSacceptAll- Whether or not to accept all messages- Returns:
- HL7 service running on the configured port using the default parser and executor
service instances provided by this interface. Note that the returned service will not
be started, and must manually be started using
Service.start()orService.startAndWait() - See Also:
-
newServer
Construct a new HL7 Server which will listen for a pair of connections (one for incoming messages, one for outgoing)- Parameters:
inboundPort- The port on which to listen for connections for inbound messagesoutboundPort- The port on which to listen for connections for outgoing messagestls- Whether or not to use SSL/TLS- Returns:
- HL7 service running on the configured ports using the default parser and executor
service instances provided by this interface. Note that the returned service will not
be started, and must manually be started using
Service.start()orService.startAndWait() - See Also:
-
- here for an example of how to use this method
setSocketFactory(SocketFactory)
-
newClient
Construct a new HL7 Client which will connect to an external TCP server for the purpose of sending messages (and receiving responses). Unless otherwise stated, the connection is established by the time this method returns, or an exception should be thrown if the connection can not be established. If a connection to this server already exists, it is reused.Note that connections are pooled by the HapiContext by default. If multiple concurrent connections to the same server are required, the easiest way to accomplish this is currently to create multiple HapiContext instances.
- Parameters:
host- The host IP/hostname to connect toport- The port to connect totls- Whether or not to use SSL/TLS- Returns:
- Returns a connection which can be used to transmit messages. Note that this method will attempt to connect to the specified address, and will throw an exception if it fails to connect.
- Throws:
HL7Exception- If the connection can not be initialized for any reason- See Also:
-
- here for an example of how to use this method
-
newLazyClient
Construct a new HL7 Client which will connect to an external TCP server for the purpose of sending messages (and receiving responses). The connection should be established by the time the first message is sent.Note that connections are pooled by the HapiContext by default. If multiple concurrent connections to the same server are required, the easiest way to accomplish this is currently to create multiple HapiContext instances.
- Parameters:
host- The host IP/hostname to connect toport- The port to connect totls- Whether or not to use SSL/TLS- Returns:
- Returns a connection which can be used to transmit messages.
- Throws:
HL7Exception- If the connection can not be initialized for any reason- See Also:
-
- here for an example of how to use this method
-
newClient
Connection newClient(String host, int outboundPort, int inboundPort, boolean tls) throws HL7Exception Construct a new HL7 two-port client which will connect to an external TCP server for the purpose of sending messages (and receiving responses). Unless otherwise stated, the connection is established by the time this method returns, or an exception should be thrown if the connection can not be established. If a connection to this server already exists, it is reused.Note that connections are pooled by the HapiContext by default. If multiple concurrent connections to the same server are required, the easiest way to accomplish this is currently to create multiple HapiContext instances.
- Parameters:
host- The host IP/hostname to connect tooutboundPort- The port to connect to for outgoing messagesinboundPort- The port to connect to for inbound (response) messagestls- Whether or not to use SSL/TLS- Returns:
- Returns a connection which can be used to transmit messages. Note that this method will attempt to connect to the specified address, and will throw an exception if it fails to connect.
- Throws:
HL7Exception- If the connection can not be initialized for any reason
-
newLazyClient
Connection newLazyClient(String host, int outboundPort, int inboundPort, boolean tls) throws HL7Exception Construct a new HL7 two-port client which will connect to an external TCP server for the purpose of sending messages (and receiving responses). The connection should be established by the time the first message is sent.Note that connections are pooled by the HapiContext by default. If multiple concurrent connections to the same server are required, the easiest way to accomplish this is currently to create multiple HapiContext instances.
- Parameters:
host- The host IP/hostname to connect tooutboundPort- The port to connect to for outgoing messagesinboundPort- The port to connect to for inbound (response) messagestls- Whether or not to use SSL/TLS- Returns:
- Returns a connection which can be used to transmit messages.
- Throws:
HL7Exception- If the connection can not be initialized for any reason
-
newMessage
Creates a new message of the given event type, trigger and version, and initializes the message header- Parameters:
eventType- event type, e.g. ADTtriggerEvent- trigger event, e.g. A01version- HL7v2 version- Returns:
- Message object of the type determined by the underlying model class factory
- Throws:
HL7Exception- if no message object could be created
-
newMessage
Creates a new message of the provided message structure class, without further initializing the message- Type Parameters:
T- message structure class type- Parameters:
clazz- message structure class- Returns:
- the created message instance
- Throws:
HL7Exception
-
newClient(String, int, boolean)