public class DefaultHapiContext extends Object implements HapiContext
HapiContext.
With this class you can configure HAPI and obtain all major HAPI business
objects that are initialized accordingly. All configuration objects already
have reasonable defaults.
When using Spring Framework for initializing objects, you can use the factory methods like this:
<!-- Define the context -->
<bean id="hapiContext" class="ca.uhn.hl7v2.DefaultHapiContext">
...
</bean>
<!-- Obtain the default PipeParser instance -->
<bean id="pipeParser" factory-bean="hapiContext" factory-method="getPipeParser"/>
...
| Constructor and Description |
|---|
DefaultHapiContext() |
DefaultHapiContext(ExecutorService executorService) |
DefaultHapiContext(HapiContext context) |
DefaultHapiContext(ModelClassFactory modelClassFactory) |
DefaultHapiContext(ParserConfiguration parserConfiguration,
ValidationContext validationContext,
ModelClassFactory modelClassFactory) |
DefaultHapiContext(ParserConfiguration parserConfiguration,
ValidationRuleBuilder builder,
ModelClassFactory modelClassFactory) |
DefaultHapiContext(ValidationContext validationContext) |
DefaultHapiContext(ValidationRuleBuilder builder) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
CodeStoreRegistry |
getCodeStoreRegistry() |
Validator |
getConformanceValidator()
Returns a ca.uhn.hl7v2.conf.check.Validator instance.
|
ConnectionHub |
getConnectionHub() |
ExecutorService |
getExecutorService() |
GenericParser |
getGenericParser() |
LowerLayerProtocol |
getLowerLayerProtocol() |
<R> Validator<R> |
getMessageValidator() |
ModelClassFactory |
getModelClassFactory() |
ParserConfiguration |
getParserConfiguration() |
PipeParser |
getPipeParser() |
ProfileStore |
getProfileStore() |
ServerConfiguration |
getServerConfiguration() |
SocketFactory |
getSocketFactory() |
ValidationContext |
getValidationContext()
Returns the ValidationContext.
|
<R> ValidationExceptionHandlerFactory<R> |
getValidationExceptionHandlerFactory() |
ValidationRuleBuilder |
getValidationRuleBuilder() |
XMLParser |
getXMLParser() |
Connection |
newClient(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).
|
Connection |
newClient(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).
|
Connection |
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).
|
Connection |
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> |
newMessage(Class<T> clazz)
Creates a new message of the provided message structure class, without further initializing the message
|
Message |
newMessage(String eventType,
String triggerEvent,
Version version)
Creates a new message of the given event type, trigger and version, and initializes the message header
|
SimpleServer |
newServer(int port,
boolean tls)
Construct a new HL7 Server which will listen for incoming connections
|
TwoPortService |
newServer(int port1,
int port2,
boolean tls)
Construct a new HL7 Server which will listen for a pair of connections (one for
incoming messages, one for outgoing)
|
void |
setCodeStoreRegistry(CodeStoreRegistry codeStoreRegistry) |
void |
setExecutorService(ExecutorService executorService) |
void |
setLowerLayerProtocol(LowerLayerProtocol llp) |
void |
setModelClassFactory(ModelClassFactory modelClassFactory) |
void |
setParserConfiguration(ParserConfiguration configuration) |
void |
setProfileStore(ProfileStore profileStore) |
void |
setServerConfiguration(ServerConfiguration theServerConfiguration)
Sets the
ServerConfiguration to be used by all HL7 servers obtained from this class. |
void |
setSocketFactory(SocketFactory socketFactory) |
void |
setValidationContext(String contextClassName)
Sets a default
ValidationContext. |
void |
setValidationContext(ValidationContext context) |
<R> void |
setValidationExceptionHandlerFactory(ValidationExceptionHandlerFactory<R> factory) |
void |
setValidationRuleBuilder(String builderClassName)
Sets a new instance of
ValidationRuleBuilder as default. |
void |
setValidationRuleBuilder(ValidationRuleBuilder validationRuleBuilder)
Sets a default
ValidationRuleBuilder. |
public DefaultHapiContext()
public DefaultHapiContext(ExecutorService executorService)
public DefaultHapiContext(ModelClassFactory modelClassFactory)
public DefaultHapiContext(ValidationContext validationContext)
public DefaultHapiContext(ValidationRuleBuilder builder)
public DefaultHapiContext(ParserConfiguration parserConfiguration, ValidationContext validationContext, ModelClassFactory modelClassFactory)
public DefaultHapiContext(ParserConfiguration parserConfiguration, ValidationRuleBuilder builder, ModelClassFactory modelClassFactory)
public DefaultHapiContext(HapiContext context)
public void close() throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic ExecutorService getExecutorService()
getExecutorService in interface HapiContextExecutorService to be used by all services that spawn threadspublic void setExecutorService(ExecutorService executorService)
setExecutorService in interface HapiContextexecutorService - the ExecutorService to be used by all services that spawn
threadspublic ConnectionHub getConnectionHub()
getConnectionHub in interface HapiContextpublic ParserConfiguration getParserConfiguration()
getParserConfiguration in interface HapiContextParserConfiguration to be used by all parsers obtained from this class.public void setParserConfiguration(ParserConfiguration configuration)
setParserConfiguration in interface HapiContextconfiguration - ParserConfiguration to be used by all parsers obtained from this
class.public ValidationContext getValidationContext()
getValidationRuleBuilder() is called in order to to contruct a
context. If this is also null, the ca.uhn.hl7v2.validation.context_class
system property is evaluated, otherwise it returns the DefaultValidation
context.getValidationContext in interface HapiContextValidationContext to be used by all parsers obtained from this class.public void setValidationContext(ValidationContext context)
setValidationContext in interface HapiContextcontext - ValidationContext to be used by all parsers obtained from this class.public void setValidationContext(String contextClassName)
HapiContextValidationContext. Note that a default ValidationRuleBuilder
has precedence of this ValidationContext.setValidationContext in interface HapiContextcontextClassName - class name of the ValidationContext to be used by all parsers
obtained from this class.public ValidationRuleBuilder getValidationRuleBuilder()
getValidationRuleBuilder in interface HapiContextValidationRuleBuilder to be used by all parsers obtained from this class.public void setValidationRuleBuilder(ValidationRuleBuilder validationRuleBuilder)
HapiContextValidationRuleBuilder. Note that this ValidationRuleBuilder
has precedence over a default ValidationContext set with
HapiContext.setValidationContext(ValidationContext) or HapiContext.setValidationContext(String)setValidationRuleBuilder in interface HapiContextvalidationRuleBuilder - ValidationRuleBuilder to be used by all parsers obtained from this
class.public void setValidationRuleBuilder(String builderClassName)
HapiContextValidationRuleBuilder as default. Note that this
ValidationRuleBuilder has precedence over a default ValidationContext set
with HapiContext.setValidationContext(ValidationContext) or
HapiContext.setValidationContext(String)setValidationRuleBuilder in interface HapiContextbuilderClassName - class name of the ValidationRuleBuilder to be used by all
parsers obtained from this class.public ModelClassFactory getModelClassFactory()
getModelClassFactory in interface HapiContextModelClassFactory to be used by all parsers obtained from this class.public void setModelClassFactory(ModelClassFactory modelClassFactory)
setModelClassFactory in interface HapiContextmodelClassFactory - the ModelClassFactory to be used by all parsers obtained
from this class.public ProfileStore getProfileStore()
getProfileStore in interface HapiContextProfileStore to be used for loading conformance profile filespublic void setProfileStore(ProfileStore profileStore)
setProfileStore in interface HapiContextprofileStore - the ProfileStore to be used for loading conformance profile filespublic CodeStoreRegistry getCodeStoreRegistry()
getCodeStoreRegistry in interface HapiContextCodeStoreRegistry to be used for serving codes for conformance profilespublic void setCodeStoreRegistry(CodeStoreRegistry codeStoreRegistry)
setCodeStoreRegistry in interface HapiContextcodeStoreRegistry - the CodeStoreRegistry to be used for serving codes for conformance profilespublic Validator getConformanceValidator()
HapiContextHapiContext.getMessageValidator() and configure a Validation rule that checks
a message against a conformance profilegetConformanceValidator in interface HapiContextHapiContext.setCodeStoreRegistry(CodeStoreRegistry)public PipeParser getPipeParser()
getPipeParser in interface HapiContextHapiContext.setModelClassFactory(ModelClassFactory),
HapiContext.setValidationContext(String) and
HapiContext.setParserConfiguration(ParserConfiguration).public XMLParser getXMLParser()
getXMLParser in interface HapiContextHapiContext.setModelClassFactory(ModelClassFactory),
HapiContext.setValidationContext(String) and
HapiContext.setParserConfiguration(ParserConfiguration).public GenericParser getGenericParser()
getGenericParser in interface HapiContextHapiContext.setModelClassFactory(ModelClassFactory),
HapiContext.setValidationContext(String) and
HapiContext.setParserConfiguration(ParserConfiguration).public <R> Validator<R> getMessageValidator()
getMessageValidator in interface HapiContextValidationContext as set
using HapiContext.setValidationContext(ValidationContext). For each validation it will
use a new instance of ValidationExceptionHandler as obtained by
HapiContext.getValidationExceptionHandlerFactory().public <R> ValidationExceptionHandlerFactory<R> getValidationExceptionHandlerFactory()
getValidationExceptionHandlerFactory in interface HapiContextpublic <R> void setValidationExceptionHandlerFactory(ValidationExceptionHandlerFactory<R> factory)
setValidationExceptionHandlerFactory in interface HapiContextfactory - a ValidationExceptionHandlerFactory that is used to create
a ValidationExceptionHandler during message validation.public LowerLayerProtocol getLowerLayerProtocol()
getLowerLayerProtocol in interface HapiContextLowerLayerProtocol instance used by all HL7 MLLP operationspublic void setLowerLayerProtocol(LowerLayerProtocol llp)
setLowerLayerProtocol in interface HapiContextllp - the LowerLayerProtocol instance used by all HL7 MLLP operationspublic SocketFactory getSocketFactory()
getSocketFactory in interface HapiContextSocketFactory instance used by HL7 networking operationspublic void setSocketFactory(SocketFactory socketFactory)
setSocketFactory in interface HapiContextsocketFactory - the SocketFactory instance used by HL7 networking operationspublic SimpleServer newServer(int port, boolean tls)
HapiContextnewServer in interface HapiContextport - The port on which to listen for new connectionstls - Whether or not to use SSL/TLSService.start() or
Service.startAndWait()HapiContext.setSocketFactory(SocketFactory)public TwoPortService newServer(int port1, int port2, boolean tls)
HapiContextnewServer in interface HapiContextport1 - The port on which to listen for connections for inbound messagesport2 - The port on which to listen for connections for outgoing messagestls - Whether or not to use SSL/TLSService.start() or
Service.startAndWait()HapiContext.setSocketFactory(SocketFactory)public Connection newClient(String host, int port, boolean tls) throws HL7Exception
HapiContextNote 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.
newClient in interface HapiContexthost - The host IP/hostname to connect toport - The port to connect totls - Whether or not to use SSL/TLSHL7Exception - If the connection can not be initialized for any reasonpublic Connection newClient(String host, int outboundPort, int inboundPort, boolean tls) throws HL7Exception
HapiContextNote 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.
newClient in interface HapiContexthost - 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/TLSHL7Exception - If the connection can not be initialized for any reasonpublic Connection newLazyClient(String host, int port, boolean tls) throws HL7Exception
HapiContextNote 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.
newLazyClient in interface HapiContexthost - The host IP/hostname to connect toport - The port to connect totls - Whether or not to use SSL/TLSHL7Exception - If the connection can not be initialized for any reasonpublic Connection newLazyClient(String host, int outboundPort, int inboundPort, boolean tls) throws HL7Exception
HapiContextNote 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.
newLazyClient in interface HapiContexthost - 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/TLSHL7Exception - If the connection can not be initialized for any reasonpublic ServerConfiguration getServerConfiguration()
getServerConfiguration in interface HapiContextServerConfiguration to be used by all HL7 servers obtained from this class.HapiContext.newServer(int, boolean),
HapiContext.newServer(int, int, boolean)public void setServerConfiguration(ServerConfiguration theServerConfiguration)
HapiContextServerConfiguration to be used by all HL7 servers obtained from this class.setServerConfiguration in interface HapiContextHapiContext.newServer(int, boolean),
HapiContext.newServer(int, int, boolean)public Message newMessage(String eventType, String triggerEvent, Version version) throws HL7Exception
HapiContextnewMessage in interface HapiContexteventType - event type, e.g. ADTtriggerEvent - trigger event, e.g. A01version - HL7v2 versionHL7Exception - if no message object could be createdpublic <T extends Message> T newMessage(Class<T> clazz) throws HL7Exception
HapiContextnewMessage in interface HapiContextT - message structure class typeclazz - message structure classHL7ExceptionCopyright © 2001–2017 University Health Network. All rights reserved.