001package ca.uhn.hl7v2.hoh.api;
002
003import java.net.Socket;
004import java.net.URL;
005import java.nio.charset.Charset;
006
007import ca.uhn.hl7v2.hoh.sign.ISigner;
008import ca.uhn.hl7v2.hoh.sockets.ISocketFactory;
009import ca.uhn.hl7v2.hoh.sockets.StandardSocketFactory;
010
011public interface IClient {
012
013        /**
014         * Getter for the host (e.g. "10.0.0.111" or "localhost")
015         */
016        String getHost();
017
018        /**
019         * Getter for the port (e.g. 80 for standard HTTP)
020         */
021        int getPort();
022
023        /**
024         * Returns the socket factory used by this client
025         */
026        ISocketFactory getSocketFactory();
027
028        /**
029         * Getter for the "Path" portion of the URL. This is the path portion which
030         * comes after the host and port, so for example if this client is being
031         * used to send messages to
032         * <code>http://somehost.com:8888/messaging/receiver.jsp</code>, the URI
033         * path portion would be <code>/messaging/receiver.jsp</code>
034         */
035        String getUriPath();
036
037        /**
038         * Getter for the URL to send messages to. 
039         */
040        URL getUrl();
041
042        /**
043         * If set, provides a callback which will be used to se the username and
044         * password associated with the request
045         */
046        void setAuthorizationCallback(IAuthorizationClientCallback theAuthorizationCallback);
047
048        /**
049         * <p>
050         * Sets the charset to use for requests from this client. May be changed at
051         * any time.
052         * </p>
053         * <p>
054         * Default is UTF-8
055         * </p>
056         */
057        void setCharset(Charset theCharset);
058
059        /**
060         * Setter for the host (e.g. "10.0.0.111" or "localhost")
061         */
062        void setHost(String theHost);
063
064        /**
065         * Configures the TCP KeepAlive flag for new connections
066         * 
067         * @see Socket#getKeepAlive()
068         */
069        void setKeepAlive(boolean theKeepAlive);
070
071        /**
072         * Returns the TCP KeepAlive flag for new connections
073         * 
074         * @see Socket#getKeepAlive()
075         */
076        boolean isKeepAlive();
077
078        /**
079         * Sets the TCP SO Timeout setting for new connections
080         * 
081         * @see Socket#getSoTimeout()
082         */
083        void setSoTimeout(int theSoTimeout);
084
085        /**
086         * Returns the TCP SO Timeout setting for new connections
087         * 
088         * @see Socket#getSoTimeout()
089         */
090        int getSoTimeout();
091
092        /**
093         * Setter for the "Path" portion of the URL. This is the path portion which
094         * comes after the host and port, so for example if this client is being
095         * used to send messages to
096         * <code>http://somehost.com:8888/messaging/receiver.jsp</code>, the URI
097         * path portion would be <code>/messaging/receiver.jsp</code>
098         */
099        void setUriPath(String thePath);
100
101        /**
102         * Getter for the port (e.g. 80 for standard HTTP)
103         */
104        void setPort(int thePort);
105
106        /**
107         * Sets the number of milliseconds before timing out. Default is
108         * {@link #DEFAULT_RESPONSE_TIMEOUT}
109         * 
110         * @param theResponseTimeout
111         *            The millis to wait before timeout.
112         * @see #DEFAULT_RESPONSE_TIMEOUT
113         */
114        void setResponseTimeout(long theResponseTimeout);
115
116        /**
117         * @param theSigner
118         *            If provided, sets the Signature Profile signer implementation
119         *            to use. See <a href=
120         *            "http://hl7api.sourceforge.net/hapi-hl7overhttp/specification.html#SIGNATURE_PROFILE"
121         *            >http://hl7api.sourceforge.net/hapi-hl7overhttp/specification.
122         *            html#SIGNATURE_PROFILE</a>
123         */
124        void setSigner(ISigner theSigner);
125
126        /**
127         * Sets the socket factory used by this client. Default is
128         * {@link StandardSocketFactory}.
129         * 
130         * @see ISocketFactory
131         */
132        void setSocketFactory(ISocketFactory theSocketFactory);
133
134        /**
135         * Setter for the URL to send messages to. 
136         * Note that invoking this method replaces any values that have been 
137         * provided to {@link #setHost(String)}, {@link #setPort(int)}, or {@link #setUriPath(String)}
138         */
139        void setUrl(URL theUrl);
140
141        /**
142         * Setter for the URL to send messages to. 
143         * Note that invoking this method replaces any values that have been 
144         * provided to {@link #setHost(String)}, {@link #setPort(int)}, or {@link #setUriPath(String)}
145         */
146        void setUrlString(String theString);
147
148        /**
149         * Getter for the URL to send messages to. 
150         */
151        String getUrlString();
152
153}