net.degreedays.api
Interface RequestProcessor

All Known Implementing Classes:
XmlHttpRequestProcessor

public interface RequestProcessor

Processes API requests into API responses.

You might not want to use this interface directly, since DegreeDaysApi provides a much more usable interface. But all the API requests that you make through a DegreeDaysApi object will be processed internally by a RequestProcessor. However you use the API, an implementation of this interface will be doing all the work of sending requests to the API servers and getting responses back.

Using a mock RequestProcessor for testing

You might want to make or use a mock implementation of this interface for testing your application. Such a mock implementation only needs to work for the types of Request that your application makes (it doesn't necessarily need to be able to handle all types of Request).

If you create a DegreeDaysApi object with a mock implementation of RequestProcessor, then all the requests you make though that DegreeDaysApi object will be processed by your mock RequestProcessor.

Customizing parts of the processing

By default this client library uses a default instance of XmlHttpRequestProcessor - that's what DegreeDaysApi will create and use internally if you don't give it a specific RequestProcessor to use. In most cases the defaults are ideal. But you can easily customize the processing that the XmlHttpRequestProcessor does. You might, for example, want to change the endpoint URL, or swap the default java.net-based HttpRequestDispatcher for one that uses HttpClient instead (if your app uses HttpClient elsewhere). See the XmlHttpRequestProcessor docs for more on how to do this sort of thing.


Method Summary
 Response process(Request request)
          Processes the Request object and returns a Response object which is either a FailureResponse or a Response that's type is the counterpart to that of the Request object passed in.
 

Method Detail

process

Response process(Request request)
                 throws TransportException
Processes the Request object and returns a Response object which is either a FailureResponse or a Response that's type is the counterpart to that of the Request object passed in.

For example, successful processing of a LocationDataRequest will result in a LocationDataResponse.

Parameters:
request - the Request to be processed. Cannot be null.
Returns:
a Response object which is either a FailureResponse or a Response that's type is is the counterpart to that of the Request passed in.
Throws:
TransportException - if there is a network- or stream-related error.
java.lang.NullPointerException - if request is null.


www.degreedays.net/api/