ca.uhn.hl7v2.app
Class Connection

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

public class Connection
extends Object

A TCP/IP connection to a remote HL7 server.

Author:
Bryan Tripp

Constructor Summary
Connection(Parser parser, LowerLayerProtocol llp, Socket bidirectional)
          Creates a new instance of Connection, with inbound and outbound communication on a single port.
Connection(Parser parser, LowerLayerProtocol llp, Socket bidirectional, ExecutorService executorService)
           
Connection(Parser parser, LowerLayerProtocol llp, Socket inbound, Socket outbound)
          Creates a new instance of Connection, with inbound communication on one port and outbound on another.
Connection(Parser parser, LowerLayerProtocol llp, Socket inbound, Socket outbound, ExecutorService executorService)
          Creates a new instance of Connection, with inbound communication on one port and outbound on another.
 
Method Summary
 void activate()
          Start the receiver thread(s)
 void close()
          Stops running Receiver threads and closes open sockets
protected  HL7Writer getAckWriter()
          Returns the HL7Writer through which responses to inbound messages should be sent.
 ExecutorService getExecutorService()
           
 Initiator getInitiator()
          Returns the Initiator associated with this connection
 Parser getParser()
           
 InetAddress getRemoteAddress()
          Returns the address of the remote host to which this Connection is connected.
 int getRemotePort()
          Returns the remote port on 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.
 boolean isOpen()
           
protected  boolean isRecipientWaiting(String ackID, String message)
          Given the ack ID (MSA-2) of a message, notifies a waiting consumer thread about a received response.
 boolean isSecure()
           
 String toString()
           
protected  Future<String> waitForResponse(String messageID, long timeout)
          Reserves a future incoming message by ack ID.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Connection

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

Throws:
LLPException
IOException

Connection

public Connection(Parser parser,
                  LowerLayerProtocol llp,
                  Socket bidirectional,
                  ExecutorService executorService)
           throws LLPException,
                  IOException
Throws:
LLPException
IOException

Connection

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

Throws:
LLPException
IOException

Connection

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

Throws:
LLPException
IOException
Method Detail

activate

public void activate()
Start the receiver thread(s)


getExecutorService

public ExecutorService getExecutorService()

getRemoteAddress

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


getRemotePort

public int getRemotePort()
Returns the remote port on the remote host to which this Connection is connected. If separate inbound and outbound sockets are used, the port of the outbound socket is returned.


getInitiator

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


getResponder

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


isSecure

public boolean isSecure()

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 String toString()
Overrides:
toString in class Object

waitForResponse

protected Future<String> waitForResponse(String messageID,
                                         long timeout)
                                  throws InterruptedException
Reserves a future incoming message by ack ID. When the incoming message with the given ack ID arrives, the message will be returned.

Throws:
InterruptedException

isRecipientWaiting

protected boolean isRecipientWaiting(String ackID,
                                     String message)
Given the ack ID (MSA-2) of a message, notifies a waiting consumer thread about a received response.


close

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


isOpen

public boolean isOpen()


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