001/*
002 * Created on 16-Apr-2004
003 */
004package ca.uhn.hl7v2.protocol;
005
006import java.io.InputStream;
007import java.io.OutputStream;
008
009/**
010 * A source of input and output streams for use with stream-based 
011 * <code>TransportLayer</code>s.  Implementations should contain the 
012 * necessary information for reconnecting streams as necessary.  For 
013 * example a ServerSocket-based implementation should be able to listen  
014 * for fresh connections and get new streams from them (this must be 
015 * done when refresh() is called).  
016 *  
017 * @author <a href="mailto:bryan.tripp@uhn.on.ca">Bryan Tripp</a>
018 * @version $Revision: 1.1 $ updated on $Date: 2007-02-19 02:24:38 $ by $Author: jamesagnew $
019 */
020public interface StreamSource {
021
022    /**
023     * Gets new streams.  This should be called only if one of the streams 
024     * is dead.  
025     * @throws TransportException
026     */
027    public void connect() throws TransportException;
028    
029    /**
030     * Closes streams and underlying connections.  
031     * @throws TransportException
032     */
033    public void disconnect() throws TransportException;
034    
035    /**
036     * @return the stream to which we write outbound messages.   
037     * @throws TransportException
038     */
039    public OutputStream getOutboundStream() throws TransportException;
040
041    /**
042     * @return the stream to which we expect the remote server to send messages.  
043     * @throws TransportException
044     */
045    public InputStream getInboundStream() throws TransportException;
046    
047}