ca.uhn.hl7v2.app
Class Connection

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

public class Connection
extends java.lang.Object

A TCP/IP connection to a remote HL7 server.

Author:
Bryan Tripp

Constructor Summary
Connection(Parser parser, LowerLayerProtocol llp, java.net.Socket bidirectional)
          Creates a new instance of Connection, with inbound and outbound communication on a single port.
Connection(Parser parser, LowerLayerProtocol llp, java.net.Socket inbound, java.net.Socket outbound)
          Creates a new instance of Connection, with inbound communication on one port and outbound on another.
 
Method Summary
 void close()
          Stops running Receiver threads and closes open sockets
protected  ca.uhn.hl7v2.app.MessageReceipt findRecipient(java.lang.String ackID)
          Given the ack ID (MSA-2) of a message, returns the corresponding MessageReceipt if one exists (ie if reserveResponse has been called for this ack ID).
protected  HL7Writer getAckWriter()
          Returns the HL7Writer through which responses to inbound messages should be sent.
 Initiator getInitiator()
          Returns the Initiator associated with this connection
 Parser getParser()
           
 java.net.InetAddress getRemoteAddress()
          Returns the address of the remote host to which this Connection is connected.
 Responder getResponder()
          Returns the Responder associated with this connection
protected  HL7Writer getSendWriter()
          Returns the HL7Writer through which unsolicited outbound messages should be sent.
 int hashCode()
          
 boolean isOpen()
          Returns false if the Connection has been closed.
protected  ca.uhn.hl7v2.app.MessageReceipt reserveResponse(java.lang.String messageID)
          Reserves a future incoming message by ack ID.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Connection

public Connection(Parser parser,
                  LowerLayerProtocol llp,
                  java.net.Socket bidirectional)
           throws LLPException,
                  java.io.IOException
Creates a new instance of Connection, with inbound and outbound communication on a single port.

Throws:
LLPException
java.io.IOException

Connection

public Connection(Parser parser,
                  LowerLayerProtocol llp,
                  java.net.Socket inbound,
                  java.net.Socket outbound)
           throws LLPException,
                  java.io.IOException
Creates a new instance of Connection, with inbound communication on one port and outbound on another.

Throws:
LLPException
java.io.IOException
Method Detail

getRemoteAddress

public java.net.InetAddress getRemoteAddress()
Returns the address of the remote host to which this Connection is connected. If separate inbound and outbound sockets are used, the address of the outbound socket is returned (the addresses should normally be the same, but this isn't checked).


getInitiator

public Initiator getInitiator()
Returns the Initiator associated with this connection


getResponder

public Responder getResponder()
Returns the Responder associated with this connection


getSendWriter

protected HL7Writer getSendWriter()
Returns the HL7Writer through which unsolicited outbound messages should be sent.


getAckWriter

protected HL7Writer getAckWriter()
Returns the HL7Writer through which responses to inbound messages should be sent.


getParser

public Parser getParser()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

reserveResponse

protected ca.uhn.hl7v2.app.MessageReceipt reserveResponse(java.lang.String messageID)
Reserves a future incoming message by ack ID. When the incoming message with the given ack ID arrives, the message will be available through the returned MessageReceipt.


findRecipient

protected ca.uhn.hl7v2.app.MessageReceipt findRecipient(java.lang.String ackID)
Given the ack ID (MSA-2) of a message, returns the corresponding MessageReceipt if one exists (ie if reserveResponse has been called for this ack ID). Otherwise (i.e. if no object is waiting for this message), returns null. This method can only be called once per ackId (the record is dropped with the call).


close

public void close()
Stops running Receiver threads and closes open sockets


hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

isOpen

public boolean isOpen()
Returns false if the Connection has been closed.



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