org.apache.camel.component.http
Class HttpProducer

java.lang.Object
  extended by org.apache.camel.impl.ServiceSupport
      extended by org.apache.camel.impl.DefaultProducer
          extended by org.apache.camel.component.http.HttpProducer
All Implemented Interfaces:
IsSingleton, Processor, Producer, Service, ShutdownableService

public class HttpProducer
extends DefaultProducer

Version:
$Revision: 956460 $

Field Summary
 
Fields inherited from class org.apache.camel.impl.DefaultProducer
log
 
Constructor Summary
HttpProducer(HttpEndpoint endpoint)
           
 
Method Summary
protected  org.apache.commons.httpclient.HttpMethod createMethod(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(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 InputStream extractResponseBody(org.apache.commons.httpclient.HttpMethod method, 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  HttpOperationFailedException populateHttpOperationFailedException(Exchange exchange, org.apache.commons.httpclient.HttpMethod method, int responseCode)
           
protected  void populateResponse(Exchange exchange, org.apache.commons.httpclient.HttpMethod method, Message in, HeaderFilterStrategy strategy, int responseCode)
           
 void process(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, doShutdown, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, removeChildService, shutdown, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.camel.Service
start, stop
 

Constructor Detail

HttpProducer

public HttpProducer(HttpEndpoint endpoint)
Method Detail

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.commons.httpclient.HttpMethod method,
                                Message in,
                                HeaderFilterStrategy strategy,
                                int responseCode)
                         throws IOException
Throws:
IOException

populateHttpOperationFailedException

protected HttpOperationFailedException populateHttpOperationFailedException(Exchange exchange,
                                                                            org.apache.commons.httpclient.HttpMethod method,
                                                                            int responseCode)
                                                                     throws IOException
Throws:
IOException

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 InputStream extractResponseBody(org.apache.commons.httpclient.HttpMethod method,
                                                 Exchange exchange)
                                          throws IOException
Extracts the response from the method as a InputStream.

Parameters:
method - the method that was executed
Returns:
the response as a stream
Throws:
IOException - can be thrown

createMethod

protected org.apache.commons.httpclient.HttpMethod createMethod(Exchange exchange)
                                                         throws InvalidPayloadException
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:
InvalidPayloadException - is thrown if message body cannot be converted to a type supported by HttpClient

createRequestEntity

protected org.apache.commons.httpclient.methods.RequestEntity createRequestEntity(Exchange exchange)
                                                                           throws InvalidPayloadException
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:
InvalidPayloadException - is thrown if message body cannot be converted to a type supported by HttpClient

getHttpClient

public org.apache.commons.httpclient.HttpClient getHttpClient()

setHttpClient

public void setHttpClient(org.apache.commons.httpclient.HttpClient httpClient)


Copyright © 2007-2010 The Apache Software Foundation. All Rights Reserved.