Class ConnectionHub
Provides access to shared HL7 Connections. The ConnectionHub has at most one connection to any given address at any time.
Synchronization Note: This class should be safe to use in a multithreaded environment. A synchronization mutex is maintained for any given target host and port, so that if two threads are trying to connect to two separate destinations neither will block, but if two threads are trying to connect to the same destination, one will block until the other has finished trying. Use caution if this class is to be used in an environment where a very large (over 1000) number of target host/port destinations will be accessed at the same time.
- Author:
- Bryan Tripp
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringSet a system property with this key to a string containing an integer larger than the default ("1000") if you need to connect to a very large number of targets at the same time in a multithreaded environment. -
Method Summary
Modifier and TypeMethodDescriptionSet<? extends ca.uhn.hl7v2.app.ConnectionData>attach(ca.uhn.hl7v2.app.ConnectionData data) attach(DefaultHapiContext hapiContext, String host, int port, boolean tls) attach(DefaultHapiContext hapiContext, String host, int outboundPort, int inboundPort, boolean tls) Returns a Connection to the given address, opening this Connection if necessary.attach(String host, int outboundPort, int inboundPort, Parser parser, LowerLayerProtocol llp, boolean tls) attach(String host, int outboundPort, int inboundPort, Parser parser, LowerLayerProtocol llp, boolean tls, SocketFactory socketFactory) attach(String host, int outboundPort, int inboundPort, Parser parser, Class<? extends LowerLayerProtocol> llpClass) attach(String host, int outboundPort, int inboundPort, Parser parser, Class<? extends LowerLayerProtocol> llpClass, boolean tls) attach(String host, int port, Parser parser, LowerLayerProtocol llp) attach(String host, int port, Parser parser, LowerLayerProtocol llp, boolean tls) attach(String host, int port, Parser parser, LowerLayerProtocol llp, boolean tls, SocketFactory socketFactory) attach(String host, int port, Parser parser, Class<? extends LowerLayerProtocol> llpClass) attach(String host, int port, Parser parser, Class<? extends LowerLayerProtocol> llpClass, boolean tls) attachLazily(DefaultHapiContext hapiContext, String host, int port, boolean tls) attachLazily(DefaultHapiContext hapiContext, String host, int outboundPort, int inboundPort, boolean tls) attachLazily(String host, int port, boolean tls) Returns a Connection to the given address, opening this Connection if necessary.attachLazily(String host, int outboundPort, int inboundPort, boolean tls) attachLazily(String host, int outboundPort, int inboundPort, Parser parser, LowerLayerProtocol llp, boolean tls) attachLazily(String host, int outboundPort, int inboundPort, Parser parser, LowerLayerProtocol llp, boolean tls, SocketFactory socketFactory) attachLazily(String host, int outboundPort, int inboundPort, Parser parser, Class<? extends LowerLayerProtocol> llpClass) attachLazily(String host, int outboundPort, int inboundPort, Parser parser, Class<? extends LowerLayerProtocol> llpClass, boolean tls) attachLazily(String host, int port, Parser parser, LowerLayerProtocol llp) attachLazily(String host, int port, Parser parser, LowerLayerProtocol llp, boolean tls) attachLazily(String host, int port, Parser parser, LowerLayerProtocol llp, boolean tls, SocketFactory socketFactory) voiddetach(Connection c) Informs the ConnectionHub that you are done with the given Connection - if no other code is using it, it will be closed, so you should not attempt to use a Connection after detaching from it.voidCloses and discards the given Connection so that it can not be returned in subsequent calls to attach().voidCloses and discards all connections.static ConnectionHubDeprecated.static ConnectionHubgetInstance(HapiContext context) Deprecated.UseHapiContext.getConnectionHub()to get an instance of ConnectionHub.static ConnectionHubgetInstance(ExecutorService service) Deprecated.UseHapiContext.getConnectionHub()to get an instance of ConnectionHub.getKnownConnection(ca.uhn.hl7v2.app.ConnectionData key) static ConnectionHubgetNewInstance(HapiContext context) Returns a new (non-singleton) instance of the ConnectionHub which uses the given executor service.booleanisOpen(ca.uhn.hl7v2.app.ConnectionData key) static voidshutdown()Deprecated.default executor service is shut down automaticallyMethods inherited from class ca.uhn.hl7v2.HapiContextSupport
getHapiContext, setHapiContext
-
Field Details
-
MAX_CONCURRENT_TARGETS
Set a system property with this key to a string containing an integer larger than the default ("1000") if you need to connect to a very large number of targets at the same time in a multithreaded environment.
-
-
Method Details
-
allConnections
-
attach
- Throws:
HL7Exception- Since:
- 2.0
-
attach
Returns a Connection to the given address, opening this Connection if necessary. The given Parser will only be used if a new Connection is opened, so there is no guarantee that the Connection returned will be using the Parser you provide. If you need explicit access to the Parser the Connection is using, callConnection.getParser().- Throws:
HL7Exception- Since:
- 2.1
-
attachLazily
Returns a Connection to the given address, opening this Connection if necessary. The given Parser will only be used if a new Connection is opened, so there is no guarantee that the Connection returned will be using the Parser you provide. If you need explicit access to the Parser the Connection is using, callConnection.getParser().- Throws:
HL7Exception- Since:
- 2.2
-
attach
public Connection attach(String host, int outboundPort, int inboundPort, boolean tls) throws HL7Exception - Throws:
HL7Exception- Since:
- 2.0
-
attachLazily
public Connection attachLazily(String host, int outboundPort, int inboundPort, boolean tls) throws HL7Exception - Throws:
HL7Exception- Since:
- 2.2
-
attach
public Connection attach(String host, int outboundPort, int inboundPort, Parser parser, Class<? extends LowerLayerProtocol> llpClass) throws HL7Exception - Throws:
HL7Exception- Since:
- 2.0
-
attachLazily
public Connection attachLazily(String host, int outboundPort, int inboundPort, Parser parser, Class<? extends LowerLayerProtocol> llpClass) throws HL7Exception - Throws:
HL7Exception- Since:
- 2.0
-
attach
public Connection attach(String host, int outboundPort, int inboundPort, Parser parser, Class<? extends LowerLayerProtocol> llpClass, boolean tls) throws HL7Exception - Throws:
HL7Exception- Since:
- 2.0
-
attachLazily
public Connection attachLazily(String host, int outboundPort, int inboundPort, Parser parser, Class<? extends LowerLayerProtocol> llpClass, boolean tls) throws HL7Exception - Throws:
HL7Exception
-
attach
public Connection attach(String host, int outboundPort, int inboundPort, Parser parser, LowerLayerProtocol llp, boolean tls) throws HL7Exception - Throws:
HL7Exception- Since:
- 2.0
-
attachLazily
public Connection attachLazily(String host, int outboundPort, int inboundPort, Parser parser, LowerLayerProtocol llp, boolean tls) throws HL7Exception - Throws:
HL7Exception- Since:
- 2.2
-
attach
public Connection attach(String host, int outboundPort, int inboundPort, Parser parser, LowerLayerProtocol llp, boolean tls, SocketFactory socketFactory) throws HL7Exception - Throws:
HL7Exception- Since:
- 2.1
-
attachLazily
public Connection attachLazily(String host, int outboundPort, int inboundPort, Parser parser, LowerLayerProtocol llp, boolean tls, SocketFactory socketFactory) throws HL7Exception - Throws:
HL7Exception- Since:
- 2.1
-
attach
public Connection attach(String host, int port, Parser parser, LowerLayerProtocol llp, boolean tls, SocketFactory socketFactory) throws HL7Exception - Throws:
HL7Exception- Since:
- 2.1
-
attachLazily
public Connection attachLazily(String host, int port, Parser parser, LowerLayerProtocol llp, boolean tls, SocketFactory socketFactory) throws HL7Exception - Throws:
HL7Exception- Since:
- 2.1
-
attach
public Connection attach(DefaultHapiContext hapiContext, String host, int port, boolean tls) throws HL7Exception - Throws:
HL7Exception- Since:
- 2.1
-
attachLazily
public Connection attachLazily(DefaultHapiContext hapiContext, String host, int port, boolean tls) throws HL7Exception - Throws:
HL7Exception- Since:
- 2.2
-
attach
public Connection attach(DefaultHapiContext hapiContext, String host, int outboundPort, int inboundPort, boolean tls) throws HL7Exception - Throws:
HL7Exception- Since:
- 2.1
-
attachLazily
public Connection attachLazily(DefaultHapiContext hapiContext, String host, int outboundPort, int inboundPort, boolean tls) throws HL7Exception - Throws:
HL7Exception- Since:
- 2.2
-
attach
public Connection attach(String host, int port, Parser parser, Class<? extends LowerLayerProtocol> llpClass) throws HL7Exception - Throws:
HL7Exception- Since:
- 1.2
-
attach
public Connection attach(String host, int port, Parser parser, Class<? extends LowerLayerProtocol> llpClass, boolean tls) throws HL7Exception - Throws:
HL7Exception- Since:
- 2.0
-
attach
public Connection attach(String host, int port, Parser parser, LowerLayerProtocol llp) throws HL7Exception - Throws:
HL7Exception- Since:
- 2.0
-
attachLazily
public Connection attachLazily(String host, int port, Parser parser, LowerLayerProtocol llp) throws HL7Exception - Throws:
HL7Exception- Since:
- 2.2
-
attach
public Connection attach(String host, int port, Parser parser, LowerLayerProtocol llp, boolean tls) throws HL7Exception - Throws:
HL7Exception- Since:
- 2.0
-
attachLazily
public Connection attachLazily(String host, int port, Parser parser, LowerLayerProtocol llp, boolean tls) throws HL7Exception - Throws:
HL7Exception- Since:
- 2.0
-
detach
Informs the ConnectionHub that you are done with the given Connection - if no other code is using it, it will be closed, so you should not attempt to use a Connection after detaching from it. If the connection is not enlisted, this method does nothing. -
discard
Closes and discards the given Connection so that it can not be returned in subsequent calls to attach(). This method is to be used when there is a problem with a Connection, e.g. socket connection closed by remote host. -
discardAll
Closes and discards all connections. -
getKnownConnection
-
isOpen
-
getInstance
Deprecated.UseHapiContext.getConnectionHub()to get an instance of ConnectionHub. See this example page for an example of how to use ConnectionHub.Returns the singleton instance of ConnectionHub -
getInstance
Deprecated.UseHapiContext.getConnectionHub()to get an instance of ConnectionHub. See this example page for an example of how to use ConnectionHub.Returns the singleton instance of ConnectionHub. -
getInstance
Deprecated.UseHapiContext.getConnectionHub()to get an instance of ConnectionHub. See this example page for an example of how to use ConnectionHub.Returns the singleton instance of ConnectionHub. -
getNewInstance
Returns a new (non-singleton) instance of the ConnectionHub which uses the given executor service.
See this example page for an example of how to use ConnectionHub.
-
shutdown
Deprecated.default executor service is shut down automatically
-
HapiContext.getConnectionHub()to get an instance of ConnectionHub.