LimeWire Consolidated API

org.limewire.promotion
Class AbstractPromotionBinderRequestor

java.lang.Object
  extended by org.limewire.promotion.AbstractPromotionBinderRequestor
All Implemented Interfaces:
PromotionBinderRequestor
Direct Known Subclasses:
PromotionBinderRequestorImpl

public abstract class AbstractPromotionBinderRequestor
extends Object
implements PromotionBinderRequestor

Instances of this class make POST requests to the URL given for containers, and also add the data given in the UserQueryEvent.

The PromotionBinder that is passed in is created by the injected PromotionBinderFactory.


Constructor Summary
AbstractPromotionBinderRequestor(PromotionBinderFactory binderFactory)
           
 
Method Summary
protected abstract  String alterUrl(String url)
          Subclasses should alter the final URL in this method, such as adding version information, etc.
static String encode(String string)
           
protected abstract  void error(Exception e)
          Called when an Exception occurs.
protected abstract  String getUserAgent()
          Returns the User-Agent to send along with the POST request.
protected abstract  InputStream makeRequest(org.apache.http.client.methods.HttpPost request, org.apache.http.params.HttpParams params)
          Called once the PostMethod request is constructed.
 PromotionBinder request(String url, long id, Set<? extends UserQueryEvent> queries)
          The main entry point.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractPromotionBinderRequestor

public AbstractPromotionBinderRequestor(PromotionBinderFactory binderFactory)
Method Detail

request

public final PromotionBinder request(String url,
                                     long id,
                                     Set<? extends UserQueryEvent> queries)
The main entry point. This will create a POST request to url and include the proper information we want to store.

Specified by:
request in interface PromotionBinderRequestor
Returns:
the PromotionBinder created from the url or null if there is not one

error

protected abstract void error(Exception e)
Called when an Exception occurs.

Parameters:
e - the Exception that occured.

getUserAgent

protected abstract String getUserAgent()
Returns the User-Agent to send along with the POST request.

Returns:
the User-Agent to send along with the POST request.

alterUrl

protected abstract String alterUrl(String url)
Subclasses should alter the final URL in this method, such as adding version information, etc.


makeRequest

protected abstract InputStream makeRequest(org.apache.http.client.methods.HttpPost request,
                                           org.apache.http.params.HttpParams params)
                                    throws org.apache.http.HttpException,
                                           IOException
Called once the PostMethod request is constructed. The purpose of the callback is so we can pass a PromotionBindder created from the PromotionBinderFactory from the passed in bytes we recieve from the request.

Parameters:
request - POST to send to a server
Returns:
a stream for the HTTP request
Throws:
org.apache.http.HttpException - thrown when a protocol error occurs
IOException - thrown when a protocol I/O occurs

encode

public static String encode(String string)

LimeWire Consolidated API

Copyright © 2009. All Rights Reserved.