public abstract class AbstractClient<T extends AbstractRawClient> extends Object implements IClient
Modifier | Constructor and Description |
---|---|
|
AbstractClient(T theRawClient)
Constructor
|
protected |
AbstractClient(T theRawClient,
Parser theParser)
Constructor
|
Modifier and Type | Method and Description |
---|---|
String |
getHost()
Getter for the host (e.g.
|
Parser |
getParser()
Returns the
Parser to use to parsing and encoding messages within
this client (may return null) |
int |
getPort()
Getter for the port (e.g.
|
protected T |
getRawClient() |
ISocketFactory |
getSocketFactory()
Returns the socket factory used by this client
|
int |
getSoTimeout()
Returns the TCP SO Timeout setting for new connections
|
String |
getUriPath()
Getter for the "Path" portion of the URL.
|
URL |
getUrl()
Getter for the URL to send messages to.
|
String |
getUrlString()
Getter for the URL to send messages to.
|
boolean |
isKeepAlive()
Returns the TCP KeepAlive flag for new connections
|
IReceivable<Message> |
sendAndReceiveMessage(ISendable<Message> theMessageToSend)
Sends a message, waits for the response, and then returns the response if
any
|
IReceivable<Message> |
sendAndReceiveMessage(Message theMessageToSend)
Sends a message, waits for the response, and then returns the response if
any (this method is a convenience method for
sendAndReceiveMessage(ISendable) |
void |
setAuthorizationCallback(IAuthorizationClientCallback theAuthorizationCallback)
If set, provides a callback which will be used to se the username and
password associated with the request
|
void |
setCharset(Charset theCharset)
Sets the charset to use for requests from this client.
|
void |
setHost(String theHost)
Setter for the host (e.g.
|
void |
setKeepAlive(boolean theKeepAlive)
Configures the TCP KeepAlive flag for new connections
|
void |
setParser(Parser theParser)
Sets the
Parser to use to parsing and encoding messages within
this client |
void |
setPort(int thePort)
Getter for the port (e.g.
|
void |
setResponseTimeout(long theResponseTimeout)
Sets the number of milliseconds before timing out.
|
void |
setSigner(ISigner theSigner) |
void |
setSocketFactory(ISocketFactory theSocketFactory)
Sets the socket factory used by this client.
|
void |
setSoTimeout(int theSoTimeout)
Sets the TCP SO Timeout setting for new connections
|
void |
setUriPath(String thePath)
Setter for the "Path" portion of the URL.
|
void |
setUrl(URL theUrl)
Setter for the URL to send messages to.
|
void |
setUrlString(String theString)
Setter for the URL to send messages to.
|
public AbstractClient(T theRawClient)
theRawClient
- The Raw client to wrap (may not be null)protected AbstractClient(T theRawClient, Parser theParser)
theRawClient
- The Raw client to wrap (may not be null)theParser
- The parser to use (may be null, in which case the parser
contained within the sent message will be usedpublic void setKeepAlive(boolean theKeepAlive)
setKeepAlive
in interface IClient
Socket.getKeepAlive()
public boolean isKeepAlive()
isKeepAlive
in interface IClient
Socket.getKeepAlive()
public void setSoTimeout(int theSoTimeout)
setSoTimeout
in interface IClient
Socket.getSoTimeout()
public int getSoTimeout()
getSoTimeout
in interface IClient
Socket.getSoTimeout()
public String getHost()
IClient
public Parser getParser()
Parser
to use to parsing and encoding messages within
this client (may return null)public int getPort()
protected T getRawClient()
public ISocketFactory getSocketFactory()
getSocketFactory
in interface IClient
public String getUriPath()
http://somehost.com:8888/messaging/receiver.jsp
, the URI
path portion would be /messaging/receiver.jsp
getUriPath
in interface IClient
public String getUrlString()
getUrlString
in interface IClient
public IReceivable<Message> sendAndReceiveMessage(ISendable<Message> theMessageToSend) throws DecodeException, IOException, EncodeException, EncodingNotSupportedException, HL7Exception
theMessageToSend
- The message to sendDecodeException
- If a problem occurs (read error, socket disconnect, etc.)
during communication, or the response is invalid in some way.
Note that IO errors in trying to connect to the remote host
or sending the message are thrown directly (i.e. as
IOException
), but IO errors in reading the response
are thrown as DecodeExceptionIOException
- If the client is unable to connect to the remote hostEncodeException
- If a failure occurs while encoding the message into a
sendable HTTP requestHL7Exception
- If the response can not be parsedEncodingNotSupportedException
- If the encoding is not supportedpublic IReceivable<Message> sendAndReceiveMessage(Message theMessageToSend) throws DecodeException, IOException, EncodeException, EncodingNotSupportedException, HL7Exception
sendAndReceiveMessage(ISendable)
theMessageToSend
- The message to sendDecodeException
- If a problem occurs (read error, socket disconnect, etc.)
during communication, or the response is invalid in some way.
Note that IO errors in trying to connect to the remote host
or sending the message are thrown directly (i.e. as
IOException
), but IO errors in reading the response
are thrown as DecodeExceptionIOException
- If the client is unable to connect to the remote hostEncodeException
- If a failure occurs while encoding the message into a
sendable HTTP requestHL7Exception
- If the response can not be parsedEncodingNotSupportedException
- If the encoding is not supportedpublic void setAuthorizationCallback(IAuthorizationClientCallback theAuthorizationCallback)
setAuthorizationCallback
in interface IClient
public void setCharset(Charset theCharset)
Sets the charset to use for requests from this client. May be changed at any time.
Default is UTF-8
setCharset
in interface IClient
public void setParser(Parser theParser)
Parser
to use to parsing and encoding messages within
this clientpublic void setUriPath(String thePath)
http://somehost.com:8888/messaging/receiver.jsp
, the URI
path portion would be /messaging/receiver.jsp
setUriPath
in interface IClient
public void setPort(int thePort)
public void setResponseTimeout(long theResponseTimeout)
#DEFAULT_RESPONSE_TIMEOUT
setResponseTimeout
in interface IClient
theResponseTimeout
- The millis to wait before timeout.#DEFAULT_RESPONSE_TIMEOUT
public void setSigner(ISigner theSigner)
setSigner
in interface IClient
theSigner
- If provided, sets the Signature Profile signer implementation
to use. See http://hl7api.sourceforge.net/hapi-hl7overhttp/specification.
html#SIGNATURE_PROFILEpublic void setSocketFactory(ISocketFactory theSocketFactory)
StandardSocketFactory
.setSocketFactory
in interface IClient
ISocketFactory
public void setUrl(URL theUrl)
IClient.setHost(String)
, IClient.setPort(int)
, or IClient.setUriPath(String)
public void setUrlString(String theString)
IClient.setHost(String)
, IClient.setPort(int)
, or IClient.setUriPath(String)
setUrlString
in interface IClient
Copyright © 2012–2017 University Health Network. All rights reserved.