public class ConnectionHub extends Object
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.
| Modifier and Type | Field and Description |
|---|---|
static String |
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.
|
| Modifier and Type | Method and Description |
|---|---|
Set<? extends ca.uhn.hl7v2.app.ConnectionData> |
allConnections() |
Connection |
attach(ca.uhn.hl7v2.app.ConnectionData data) |
Connection |
attach(String host,
int outboundPort,
int inboundPort,
Parser parser,
Class<? extends LowerLayerProtocol> llpClass) |
Connection |
attach(String host,
int outboundPort,
int inboundPort,
Parser parser,
Class<? extends LowerLayerProtocol> llpClass,
boolean tls) |
Connection |
attach(String host,
int outboundPort,
int inboundPort,
Parser parser,
LowerLayerProtocol llp,
boolean tls) |
Connection |
attach(String host,
int port,
Parser parser,
Class<? extends LowerLayerProtocol> llpClass)
Returns a Connection to the given address, opening this Connection if
necessary.
|
Connection |
attach(String host,
int port,
Parser parser,
Class<? extends LowerLayerProtocol> llpClass,
boolean tls) |
Connection |
attach(String host,
int port,
Parser parser,
LowerLayerProtocol llp,
boolean tls) |
void |
detach(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.
|
void |
discard(Connection c)
Closes and discards the given Connection so that it can not be returned
in subsequent calls to attach().
|
void |
discardAll() |
static ConnectionHub |
getInstance()
Returns the singleton instance of ConnectionHub
|
static ConnectionHub |
getInstance(ExecutorService service)
Returns the singleton instance of ConnectionHub.
|
Connection |
getKnownConnection(ca.uhn.hl7v2.app.ConnectionData key) |
boolean |
isOpen(ca.uhn.hl7v2.app.ConnectionData key) |
static void |
shutdown() |
public static final String MAX_CONCURRENT_TARGETS
public static ConnectionHub getInstance()
public static void shutdown()
public static ConnectionHub getInstance(ExecutorService service)
public Connection attach(String host, int port, Parser parser, Class<? extends LowerLayerProtocol> llpClass) throws HL7Exception
Connection.getParser().HL7Exceptionpublic Connection attach(String host, int port, Parser parser, Class<? extends LowerLayerProtocol> llpClass, boolean tls) throws HL7Exception
HL7Exceptionpublic Connection attach(String host, int port, Parser parser, LowerLayerProtocol llp, boolean tls) throws HL7Exception
HL7Exceptionpublic Connection attach(String host, int outboundPort, int inboundPort, Parser parser, Class<? extends LowerLayerProtocol> llpClass) throws HL7Exception
HL7Exceptionpublic Connection attach(String host, int outboundPort, int inboundPort, Parser parser, Class<? extends LowerLayerProtocol> llpClass, boolean tls) throws HL7Exception
HL7Exceptionpublic Connection attach(String host, int outboundPort, int inboundPort, Parser parser, LowerLayerProtocol llp, boolean tls) throws HL7Exception
HL7Exceptionpublic Connection attach(ca.uhn.hl7v2.app.ConnectionData data) throws HL7Exception
HL7Exceptionpublic void detach(Connection c)
public void discard(Connection c)
public void discardAll()
public Set<? extends ca.uhn.hl7v2.app.ConnectionData> allConnections()
public Connection getKnownConnection(ca.uhn.hl7v2.app.ConnectionData key)
public boolean isOpen(ca.uhn.hl7v2.app.ConnectionData key)
Copyright © 2001-2012 University Health Network. All Rights Reserved.