HttpSender¶
-
public class
HttpSender
implements Runnable¶ The
HttpSender
is top base class for sending HTTP request. TODO: javadocAuthor: Twinsen Tsang
Fields¶
log¶
-
protected FileLogger
log
¶
Constructors¶
HttpSender¶
-
public
HttpSender
()¶ SPA Constructor. It is used when the HTTP Sender is a component in the SPA.
HttpSender¶
-
public
HttpSender
(FileLogger logger, Data d)¶ Explicit Constructor.
Parameters: - logger – The logger used for log message and exception.
- d – The data used for sending HTTP request.
HttpSender¶
-
public
HttpSender
(FileLogger logger, Data d, String username, String password)¶ Explicit Constructor.
Parameters: - logger – The logger used for log message and exception.
- d – The data used for sending HTTP request.
- username – The username for authentication
- password – The password for authentication
HttpSender¶
-
public
HttpSender
(FileLogger l, Data d, String endpoint)¶ Explicit Constructor.
Parameters: - l – The logger used for log message and exception.
- d – The data used for sending HTTP request.
- endpoint – The URL of service end point.
HttpSender¶
-
public
HttpSender
(FileLogger l, Data d, URL endpoint)¶ Explicit Constructor.
Parameters: - l – The logger used for log message and exception.
- d – The data used for sending HTTP request.
- endpoint – The URL of service end point.
HttpSender¶
-
public
HttpSender
(FileLogger l, Data d, String endpoint, String username, String password)¶ Explicit Constructor.
Parameters: - l – The logger used for log message and exception.
- d – The data used for sending HTTP request.
- endpoint – The URL of service end point.
- username – The username for authentication
- password – The password for authentication
HttpSender¶
-
public
HttpSender
(FileLogger l, Data d, URL endpoint, String username, String password)¶ Explicit Constructor.
Parameters: - l – The logger used for log message and exception.
- d – The data used for sending HTTP request.
- endpoint – The URL of service end point.
- username – The username for authentication
- password – The password for authentication
Methods¶
closeResponse¶
-
public void
closeResponse
(CloseableHttpResponse response)¶ Close http response with exception handling
Parameters: - response – the response to close
getCurrentLoopTimes¶
-
public int
getCurrentLoopTimes
()¶ Get what is the current loop times for looping
getExecutedMethod¶
-
public HttpRequestBase
getExecutedMethod
()¶ Get the last executed HTTP method. This method should be invoked during
onResponse()
.Returns: the last executed HTTP method.
getResponse¶
-
public CloseableHttpResponse
getResponse
()¶ Get the response of the last executed HTTP method. This method should be invoked during
onResponse()
.Returns: the response of the last executed HTTP method
getServiceEndPoint¶
initializeMessage¶
-
protected void
initializeMessage
()¶ Implements this method if you want to send messages without much different between other message to sent.
isAuthenticationRequired¶
-
public boolean
isAuthenticationRequired
()¶ Returns: true if HTTP authentication is required.
onBeforeRequest¶
-
protected void
onBeforeRequest
(HttpClient client, HttpRequestBase request)¶ [@EVENT] This method is invoked just before sending the request to HTTP service end-point.
Parameters: - client – The HTTP Connection used for sending SOAP request.
- request – The request created by
onCreateRequest()
.
Throws: - Exception – Any type of exception will be processed at onError(throwable t).
onCreateRequest¶
-
protected HttpRequestBase
onCreateRequest
()¶ [@EVENT] This method is invoked when the sender is required to create a HTTP Request from configuration. By default, this method return a PostMethod pointing to
getServiceEndPoint()
.Throws: - Exception – Sub-class implementation-specific exception
onEachLoopStart¶
onError¶
onResponse¶
-
protected void
onResponse
()¶ [@EVENT] This method is invoked when received the reply HTTP response from the server. Developer can use
getExecutedMethod()
to get the HTTP method generated thruonCreateRequest()
Throws: - Exception – Any type of exception will be processed at onError(throwable t).
onStart¶
-
protected void
onStart
()¶ [@EVENT] This method is invoked when the sender begins to execute the run method.
setLoopTimes¶
-
public void
setLoopTimes
(int loopTimes)¶ Set how many times should the sender to be send.
Parameters: - loopTimes – the new loopTimes.