ca.uhn.hl7v2.app
Class ConnectionHub

java.lang.Object
  extended by ca.uhn.hl7v2.app.ConnectionHub

public class ConnectionHub
extends java.lang.Object

Provides access to shared HL7 Connections. The ConnectionHub has at most one connection to any given address at any time.

Author:
Bryan Tripp

Method Summary
 Connection attach(java.lang.String host, int port, Parser parser, java.lang.Class<? extends LowerLayerProtocol> llpClass)
          Returns a Connection to the given address, opening this Connection if necessary.
 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 Concection so that it can not be returned in subsequent calls to attach().
static ConnectionHub getInstance()
          Returns the singleton instance of ConnectionHub
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ConnectionHub getInstance()
Returns the singleton instance of ConnectionHub


attach

public Connection attach(java.lang.String host,
                         int port,
                         Parser parser,
                         java.lang.Class<? extends LowerLayerProtocol> llpClass)
                  throws HL7Exception
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 returnd will be using the Parser you provide. If you need explicit access to the Parser the Connection is using, call Connection.getParser().

Throws:
HL7Exception

detach

public 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.


discard

public void discard(Connection c)
Closes and discards the given Concection 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.



Copyright © 2001-2011 University Health Network. All Rights Reserved.