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
¶ The logger used for log message and exception
See also:
hk.hku.cecid.corvus.util.FileLogger
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 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.
Methods¶
getCurrentLoopTimes¶
-
public int
getCurrentLoopTimes
()¶ Get what is the current loop times for looping
getExecutedMethod¶
-
public HttpMethod
getExecutedMethod
()¶ Get the last executed HTTP method. This method should be invoked during
onResponse()
.Returns: 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, HttpMethod 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 HttpMethod
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.
setBasicAuthentication¶
-
public void
setBasicAuthentication
(String username, String password)¶ Set to use the basic authentication when calling the web service.
Parameters: - username – The user-name for basic authentication.
- password – The password for basic authentication.
Throws: - NullPointerException – When the user-name or password is null.
setLoopTimes¶
-
public void
setLoopTimes
(int loopTimes)¶ Set how many times should the sender to be send.
Parameters: - loopTimes – the new loopTimes.