com.nativex.common
Class HTTPServiceManager

java.lang.Object
  extended by com.nativex.common.HTTPServiceManager
All Implemented Interfaces:
IHTTPServiceManager

public class HTTPServiceManager
extends Object
implements IHTTPServiceManager

A manager the execute REST service requests.

Author:
Anton Donchev

Field Summary
private  HttpClient client
           
static String LOCATION_HEADER
           
static int RTSP_PORT
           
static String RTSP_PROTOCOL
           
static String USER_AGENT_HEADER
           
 
Constructor Summary
HTTPServiceManager()
          Basic constructor.
HTTPServiceManager(HttpClient httpClient)
          Constructor taking HttpClient as parameter.
 
Method Summary
private static void addHeaders(HttpUriRequest httpRequest, Map<String,String> headers)
           
 Response execute(Request request)
          Executes a REST service request.
private  String getRedirectLocation(String uri, HttpClient client)
           
protected  Response httpGet(Request request)
          Handles HTTP GET requests.
protected  Response httpGetImage(Request request)
           
protected  Response httpPost(Request request)
          Handles HTTP POST requests.
 void release()
          Releases the manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

client

private HttpClient client

USER_AGENT_HEADER

public static final String USER_AGENT_HEADER
See Also:
Constant Field Values

LOCATION_HEADER

public static final String LOCATION_HEADER
See Also:
Constant Field Values

RTSP_PROTOCOL

public static final String RTSP_PROTOCOL
See Also:
Constant Field Values

RTSP_PORT

public static final int RTSP_PORT
See Also:
Constant Field Values
Constructor Detail

HTTPServiceManager

public HTTPServiceManager()
Basic constructor.


HTTPServiceManager

public HTTPServiceManager(HttpClient httpClient)
Constructor taking HttpClient as parameter.

Parameters:
httpClient - HttpClient. The HttpClient to use.
Method Detail

execute

public Response execute(Request request)
                 throws ClientProtocolException,
                        IOException
Description copied from interface: IHTTPServiceManager
Executes a REST service request.

Specified by:
execute in interface IHTTPServiceManager
Parameters:
request - Request. The request to execute
Returns:
Response. The response.
Throws:
ClientProtocolException
IOException

addHeaders

private static void addHeaders(HttpUriRequest httpRequest,
                               Map<String,String> headers)

httpGet

protected Response httpGet(Request request)
                    throws ClientProtocolException,
                           IOException
Handles HTTP GET requests.

Parameters:
request - Request The request to the server.
Returns:
Response. The response from the server.
Throws:
ClientProtocolException - Signals an error in the HTTP protocol.
IOException - Signals for I/O Error.

httpGetImage

protected Response httpGetImage(Request request)
                         throws ClientProtocolException,
                                IOException
Throws:
ClientProtocolException
IOException

getRedirectLocation

private String getRedirectLocation(String uri,
                                   HttpClient client)
                            throws IOException
Throws:
IOException

httpPost

protected Response httpPost(Request request)
                     throws ClientProtocolException,
                            IOException
Handles HTTP POST requests.

Parameters:
request - Request The request to the server.
Returns:
Response. The response from the server.
Throws:
ClientProtocolException - Signals an error in the HTTP protocol.
IOException - Signals for I/O Error.

release

public void release()
Description copied from interface: IHTTPServiceManager
Releases the manager.

Specified by:
release in interface IHTTPServiceManager