org.apache.camel.component.http
Class HttpProducer
java.lang.Object
org.apache.camel.impl.ServiceSupport
org.apache.camel.impl.DefaultProducer
org.apache.camel.component.http.HttpProducer
- All Implemented Interfaces:
- org.apache.camel.IsSingleton, org.apache.camel.Processor, org.apache.camel.Producer, org.apache.camel.Service, org.apache.camel.ShutdownableService
public class HttpProducer
- extends org.apache.camel.impl.DefaultProducer
- Version:
Fields inherited from class org.apache.camel.impl.DefaultProducer |
log |
Method Summary |
protected org.apache.commons.httpclient.HttpMethod |
createMethod(org.apache.camel.Exchange exchange)
Creates the HttpMethod to use to call the remote server, either its GET or POST. |
protected org.apache.commons.httpclient.methods.RequestEntity |
createRequestEntity(org.apache.camel.Exchange exchange)
Creates a holder object for the data to send to the remote server. |
protected int |
executeMethod(org.apache.commons.httpclient.HttpMethod method)
Strategy when executing the method (calling the remote server). |
protected static Object |
extractResponseBody(org.apache.commons.httpclient.HttpMethod method,
org.apache.camel.Exchange exchange)
Extracts the response from the method as a InputStream. |
protected static Map<String,String> |
extractResponseHeaders(org.apache.commons.httpclient.Header[] responseHeaders)
Extracts the response headers |
HttpEndpoint |
getEndpoint()
|
org.apache.commons.httpclient.HttpClient |
getHttpClient()
|
protected Exception |
populateHttpOperationFailedException(org.apache.camel.Exchange exchange,
org.apache.commons.httpclient.HttpMethod method,
int responseCode)
|
protected void |
populateResponse(org.apache.camel.Exchange exchange,
org.apache.commons.httpclient.HttpMethod method,
org.apache.camel.Message in,
org.apache.camel.spi.HeaderFilterStrategy strategy,
int responseCode)
|
void |
process(org.apache.camel.Exchange exchange)
|
void |
setHttpClient(org.apache.commons.httpclient.HttpClient httpClient)
|
Methods inherited from class org.apache.camel.impl.DefaultProducer |
createExchange, createExchange, createExchange, doStart, doStop, isSingleton, toString |
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 |
Methods inherited from interface org.apache.camel.Service |
start, stop |
HttpProducer
public HttpProducer(HttpEndpoint endpoint)
process
public void process(org.apache.camel.Exchange exchange)
throws Exception
- Throws:
Exception
getEndpoint
public HttpEndpoint getEndpoint()
- Specified by:
getEndpoint
in interface org.apache.camel.Producer
- Overrides:
getEndpoint
in class org.apache.camel.impl.DefaultProducer
populateResponse
protected void populateResponse(org.apache.camel.Exchange exchange,
org.apache.commons.httpclient.HttpMethod method,
org.apache.camel.Message in,
org.apache.camel.spi.HeaderFilterStrategy strategy,
int responseCode)
throws IOException,
ClassNotFoundException
- Throws:
IOException
ClassNotFoundException
populateHttpOperationFailedException
protected Exception populateHttpOperationFailedException(org.apache.camel.Exchange exchange,
org.apache.commons.httpclient.HttpMethod method,
int responseCode)
throws IOException,
ClassNotFoundException
- Throws:
IOException
ClassNotFoundException
executeMethod
protected int executeMethod(org.apache.commons.httpclient.HttpMethod method)
throws IOException
- Strategy when executing the method (calling the remote server).
- Parameters:
method
- the method to execute
- Returns:
- the response code
- Throws:
IOException
- can be thrown
extractResponseHeaders
protected static Map<String,String> extractResponseHeaders(org.apache.commons.httpclient.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.commons.httpclient.HttpMethod method,
org.apache.camel.Exchange exchange)
throws IOException,
ClassNotFoundException
- Extracts the response from the method as a InputStream.
- Parameters:
method
- 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.commons.httpclient.HttpMethod createMethod(org.apache.camel.Exchange exchange)
throws org.apache.camel.CamelExchangeException,
URISyntaxException
- 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:
org.apache.camel.CamelExchangeException
- is thrown if error creating RequestEntity
URISyntaxException
createRequestEntity
protected org.apache.commons.httpclient.methods.RequestEntity createRequestEntity(org.apache.camel.Exchange exchange)
throws org.apache.camel.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:
org.apache.camel.CamelExchangeException
- is thrown if error creating RequestEntity
getHttpClient
public org.apache.commons.httpclient.HttpClient getHttpClient()
setHttpClient
public void setHttpClient(org.apache.commons.httpclient.HttpClient httpClient)
Apache CAMEL