org.apache.camel.component.http4
Class HttpProducer
java.lang.Object
org.apache.camel.impl.ServiceSupport
org.apache.camel.impl.DefaultProducer
org.apache.camel.component.http4.HttpProducer
- All Implemented Interfaces:
- IsSingleton, Processor, Producer, Service, ShutdownableService
public class HttpProducer
- extends DefaultProducer
- Version:
- $Revision: 1053671 $
Method Summary |
protected org.apache.http.client.methods.HttpRequestBase |
createMethod(Exchange exchange)
Creates the HttpMethod to use to call the remote server, either its GET or POST. |
protected org.apache.http.HttpEntity |
createRequestEntity(Exchange exchange)
Creates a holder object for the data to send to the remote server. |
protected org.apache.http.HttpResponse |
executeMethod(org.apache.http.client.methods.HttpUriRequest httpRequest)
Strategy when executing the method (calling the remote server). |
protected static Object |
extractResponseBody(org.apache.http.client.methods.HttpRequestBase httpRequest,
org.apache.http.HttpResponse httpResponse,
Exchange exchange)
Extracts the response from the method as a InputStream. |
protected static Map<String,String> |
extractResponseHeaders(org.apache.http.Header[] responseHeaders)
Extracts the response headers |
HttpEndpoint |
getEndpoint()
|
org.apache.http.client.HttpClient |
getHttpClient()
|
protected Exception |
populateHttpOperationFailedException(Exchange exchange,
org.apache.http.client.methods.HttpRequestBase httpRequest,
org.apache.http.HttpResponse httpResponse,
int responseCode)
|
protected void |
populateResponse(Exchange exchange,
org.apache.http.client.methods.HttpRequestBase httpRequest,
org.apache.http.HttpResponse httpResponse,
Message in,
HeaderFilterStrategy strategy,
int responseCode)
|
void |
process(Exchange exchange)
|
void |
setHttpClient(org.apache.http.client.HttpClient httpClient)
|
Methods inherited from class org.apache.camel.impl.ServiceSupport |
addChildService, doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspended, isSuspending, removeChildService, resume, shutdown, start, start, stop, suspend |
HttpProducer
public HttpProducer(HttpEndpoint endpoint)
process
public void process(Exchange exchange)
throws Exception
- Throws:
Exception
getEndpoint
public HttpEndpoint getEndpoint()
- Specified by:
getEndpoint
in interface Producer
- Overrides:
getEndpoint
in class DefaultProducer
populateResponse
protected void populateResponse(Exchange exchange,
org.apache.http.client.methods.HttpRequestBase httpRequest,
org.apache.http.HttpResponse httpResponse,
Message in,
HeaderFilterStrategy strategy,
int responseCode)
throws IOException,
ClassNotFoundException
- Throws:
IOException
ClassNotFoundException
populateHttpOperationFailedException
protected Exception populateHttpOperationFailedException(Exchange exchange,
org.apache.http.client.methods.HttpRequestBase httpRequest,
org.apache.http.HttpResponse httpResponse,
int responseCode)
throws IOException,
ClassNotFoundException
- Throws:
IOException
ClassNotFoundException
executeMethod
protected org.apache.http.HttpResponse executeMethod(org.apache.http.client.methods.HttpUriRequest httpRequest)
throws IOException
- Strategy when executing the method (calling the remote server).
- Parameters:
httpRequest
- the http Request to execute
- Returns:
- the response
- Throws:
IOException
- can be thrown
extractResponseHeaders
protected static Map<String,String> extractResponseHeaders(org.apache.http.Header[] responseHeaders)
- Extracts the response headers
- Parameters:
responseHeaders
- the headers
- Returns:
- the extracted headers or null if no headers existed
extractResponseBody
protected static Object extractResponseBody(org.apache.http.client.methods.HttpRequestBase httpRequest,
org.apache.http.HttpResponse httpResponse,
Exchange exchange)
throws IOException,
ClassNotFoundException
- Extracts the response from the method as a InputStream.
- Parameters:
httpRequest
- the method that was executed
- Returns:
- the response either as a stream, or as a deserialized java object
- Throws:
IOException
- can be thrown
ClassNotFoundException
createMethod
protected org.apache.http.client.methods.HttpRequestBase createMethod(Exchange exchange)
throws URISyntaxException,
CamelExchangeException
- Creates the HttpMethod to use to call the remote server, either its GET or POST.
- Parameters:
exchange
- the exchange
- Returns:
- the created method as either GET or POST
- Throws:
URISyntaxException
- is thrown if the URI is invalid
CamelExchangeException
- is thrown if error creating RequestEntity
createRequestEntity
protected org.apache.http.HttpEntity createRequestEntity(Exchange exchange)
throws CamelExchangeException
- Creates a holder object for the data to send to the remote server.
- Parameters:
exchange
- the exchange with the IN message with data to send
- Returns:
- the data holder
- Throws:
CamelExchangeException
- is thrown if error creating RequestEntity
getHttpClient
public org.apache.http.client.HttpClient getHttpClient()
setHttpClient
public void setHttpClient(org.apache.http.client.HttpClient httpClient)
Apache CAMEL