public static final class XmlHttpRequestProcessor.Builder
extends java.lang.Object
XmlHttpRequestProcessor objects: create and configure a
 Builder object, then call build() to create an
 XmlHttpRequestProcessor object.
 
 
 The request-processing functionality of XmlHttpRequestProcessor
 is defined by the processing components it uses internally. To create an
 XmlHttpRequestProcessor with default out-of-the-box
 functionality, simply create an instance of this builder class and call
 build(). Or you can customize the the request-processing
 functionality by setting custom processing components before calling
 build()...
 
There are two main ways that you might want to provide custom processing components:
 First, you might want to provide a component that you have created or
 downloaded. For example, here's how to create an
 XmlHttpRequestProcessor with a custom
 HttpRequestDispatcher called
 customHttpRequestDispatcher (which we're assuming you have
 already created):
 
 XmlHttpRequestProcessor.Builder builder =
         new XmlHttpRequestProcessor.Builder(accountKey, securityKey);
 builder.setHttpRequestDispatcher(customHttpRequestDispatcher);
 RequestProcessor processor = builder.build();
 
 
 You might also want to wrap, or decorate, the default implementation of a component, adding a little extra functionality. Here's an example that logs the XML of the requests that are sent to the API:
 XmlHttpRequestProcessor.Builder builder =
         new XmlHttpRequestProcessor.Builder(accountKey, securityKey);
 final RequestToXml defaultRequestToXml = builder.getRequestToXml();
 RequestToXml customRequestToXml = new RequestToXml() {
     public String getXml(Request request) {
         String xml = defaultRequestToXml.getXml(request);
         log(xml);
         return xml;
     }
 };
 builder.setRequestToXml(customRequestToXml);
 RequestProcessor processor = builder.build();
 
 
 
 
 If, for whatever reason, you're providing customized processing
 components, it's important to understand how these components are used in
 XmlHttpRequestProcessor.process(net.degreedays.api.Request). Here's a step-by-step
 explanation:
 
RequestToXml component turns the Request
 into an XML string.EndpointGetter component provides the endpoint URL
 that the XML request should be sent to.RequestSecurityInfo object is created using:
 AccountKey.TimestampFactory
 component and formatted using the DateFormatter
 component.RandomFactory
 component.XmlRequestWrapper component takes the request XML
 from step 1 and adds in the security info from step 3 to make a
 complete XML request.StringToBytes component turns the complete XML
 into a byte array.Signer component uses the SecurityKey (a
 representation of which it holds internally) to create a
 Signature of the request-XML byte array, so that its integrity
 can be checked on the API servers. Note that the security key itself is
 not sent over the wire, only a signature created using that key.BytesToEncodedString component turns both the XML
 byte array and the signature byte array into EncodedString
 objects that each contain an encoded string version of the byte array
 (that can easily be sent over HTTP) and a code name to indicate
 the encoding used.HttpRequest object is created to store the request
 parameters that should be sent over HTTP to the endpoint URL:
 request_encoding parameter holds the
 encoding() of the string-encoded request
 XML byte array.signature_encoding parameter holds the
 encoding() of the string-encoded
 signature byte array.signature_method parameter holds the name of the
 algorithm used to create the signature.encoded_request parameter holds the string-encoded
 request XML.encoded_signature parameter holds the string-encoded
 signature.HttpRequestDispatcher component POSTs the
 parameters from the HttpRequest to the endpoint URL, and
 returns a stream containing the XML response.ResponseParser component parses the XML response
 into a Response object - the end result of the processing.Instances of this builder class are designed for single-threaded use only. It's fine to create and use instances in multiple concurrent threads, but, in the absence of external synchronization, the use of each individual builder instance should be restricted to one thread only.
| Constructor and Description | 
|---|
Builder(AccountKey accountKey,
       SecurityKey securityKey)  | 
public Builder(AccountKey accountKey, SecurityKey securityKey)
accountKey - the non-null public account key associated with the
        account.securityKey - the non-null private security key associated with
        the account (the one that you need to keep secret).java.lang.NullPointerException - if accountKey or
         securityKey is null.public EndpointGetter getEndpointGetter()
public TimestampFactory getTimestampFactory()
public DateFormatter getDateFormatter()
public RandomFactory getRandomFactory()
public RequestToXml getRequestToXml()
public XmlRequestWrapper getXmlRequestWrapper()
public StringToBytes getStringToBytes()
public Signer getSigner()
public BytesToEncodedString getBytesToEncodedString()
public HttpRequestDispatcher getHttpRequestDispatcher()
public ResponseParser getResponseParser()
public XmlHttpRequestProcessor.Builder setEndpointGetter(EndpointGetter endpointGetter)
public XmlHttpRequestProcessor.Builder setTimestampFactory(TimestampFactory timestampFactory)
public XmlHttpRequestProcessor.Builder setDateFormatter(DateFormatter dateFormatter)
public XmlHttpRequestProcessor.Builder setRandomFactory(RandomFactory randomFactory)
public XmlHttpRequestProcessor.Builder setRequestToXml(RequestToXml requestToXml)
public XmlHttpRequestProcessor.Builder setXmlRequestWrapper(XmlRequestWrapper xmlRequestWrapper)
public XmlHttpRequestProcessor.Builder setStringToBytes(StringToBytes stringToBytes)
public XmlHttpRequestProcessor.Builder setSigner(Signer signer)
public XmlHttpRequestProcessor.Builder setBytesToEncodedString(BytesToEncodedString bytesToEncodedString)
public XmlHttpRequestProcessor.Builder setHttpRequestDispatcher(HttpRequestDispatcher httpRequestDispatcher)
public XmlHttpRequestProcessor.Builder setResponseParser(ResponseParser responseParser)
public XmlHttpRequestProcessor build()
See www.degreedays.net/api/ for more about the Degree Days.net API.
You can sign up for a Degree Days.net API account and read the integration guide that is useful and applicable whether you are using Java or not.