org.apache.camel
Class CamelTemplate<E extends Exchange>

java.lang.Object
  extended by org.apache.camel.impl.ServiceSupport
      extended by org.apache.camel.CamelTemplate<E>
All Implemented Interfaces:
Service

public class CamelTemplate<E extends Exchange>
extends ServiceSupport

A client helper object (named like Spring's TransactionTemplate & JmsTemplate et al) for working with Camel and sending Message instances in an Exchange to an Endpoint.

Version:
$Revision: 537937 $

Constructor Summary
CamelTemplate(CamelContext context)
           
CamelTemplate(CamelContext context, Endpoint defaultEndpoint)
           
 
Method Summary
protected  void doStart()
           
protected  void doStop()
           
protected  Object extractResultBody(E result)
           
 CamelContext getContext()
           
 Endpoint<E> getDefaultEndpoint()
           
protected  Endpoint<E> getMandatoryDefaultEndpoint()
           
 Producer<E> getProducer(Endpoint<E> endpoint)
           
 boolean isUseEndpointCache()
           
protected  Endpoint resolveMandatoryEndpoint(String endpointUri)
           
 E send(E exchange)
          Sends the exchange to the default endpoint
 E send(Endpoint<E> endpoint, E exchange)
          Sends the exchange to the given endpoint
 E send(Endpoint<E> endpoint, Processor processor)
          Sends an exchange to an endpoint using a supplied @{link Processor} to populate the exchange
 E send(Processor processor)
          Sends an exchange to the default endpoint using a supplied @{link Processor} to populate the exchange
 E send(String endpointUri, E exchange)
          Sends the exchange to the given endpoint
 E send(String endpointUri, Processor processor)
          Sends an exchange to an endpoint using a supplied @{link Processor} to populate the exchange
 Object sendBody(Endpoint<E> endpoint, Object body)
          Send the body to an endpoint
 Object sendBody(Object body)
          Sends the body to the default endpoint and returns the result content
 Object sendBody(String endpointUri, Object body)
          Send the body to an endpoint
 Object sendBody(String endpointUri, Object body, Map<String,Object> headers)
          Sends the body to an endpoint with the specified headers and header values
 Object sendBody(String endpointUri, Object body, String header, Object headerValue)
          Sends the body to an endpoint with a specified header and header value
 void setDefaultEndpoint(Endpoint<E> defaultEndpoint)
           
 void setDefaultEndpointUri(String endpointUri)
          Sets the default endpoint to use if none is specified
 void setUseEndpointCache(boolean useEndpointCache)
           
 
Methods inherited from class org.apache.camel.impl.ServiceSupport
isStarted, isStopped, isStopping, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CamelTemplate

public CamelTemplate(CamelContext context)

CamelTemplate

public CamelTemplate(CamelContext context,
                     Endpoint defaultEndpoint)
Method Detail

send

public E send(String endpointUri,
              E exchange)
Sends the exchange to the given endpoint

Parameters:
endpointUri - the endpoint URI to send the exchange to
exchange - the exchange to send

send

public E send(String endpointUri,
              Processor processor)
Sends an exchange to an endpoint using a supplied @{link Processor} to populate the exchange

Parameters:
endpointUri - the endpoint URI to send the exchange to
processor - the transformer used to populate the new exchange

send

public E send(Endpoint<E> endpoint,
              E exchange)
Sends the exchange to the given endpoint

Parameters:
endpoint - the endpoint to send the exchange to
exchange - the exchange to send

send

public E send(Endpoint<E> endpoint,
              Processor processor)
Sends an exchange to an endpoint using a supplied @{link Processor} to populate the exchange

Parameters:
endpoint - the endpoint to send the exchange to
processor - the transformer used to populate the new exchange

sendBody

public Object sendBody(Endpoint<E> endpoint,
                       Object body)
Send the body to an endpoint

Parameters:
endpoint -
body - = the payload
Returns:
the result

sendBody

public Object sendBody(String endpointUri,
                       Object body)
Send the body to an endpoint

Parameters:
endpointUri -
body - = the payload
Returns:
the result

sendBody

public Object sendBody(String endpointUri,
                       Object body,
                       String header,
                       Object headerValue)
Sends the body to an endpoint with a specified header and header value

Parameters:
endpointUri - the endpoint URI to send to
body - the payload send
header - the header name
headerValue - the header value
Returns:
the result

sendBody

public Object sendBody(String endpointUri,
                       Object body,
                       Map<String,Object> headers)
Sends the body to an endpoint with the specified headers and header values

Parameters:
endpointUri - the endpoint URI to send to
body - the payload send
Returns:
the result

sendBody

public Object sendBody(Object body)
Sends the body to the default endpoint and returns the result content

Parameters:
body - the body to send
Returns:
the returned message body

send

public E send(E exchange)
Sends the exchange to the default endpoint

Parameters:
exchange - the exchange to send

send

public E send(Processor processor)
Sends an exchange to the default endpoint using a supplied @{link Processor} to populate the exchange

Parameters:
processor - the transformer used to populate the new exchange

getProducer

public Producer<E> getProducer(Endpoint<E> endpoint)

getContext

public CamelContext getContext()

getDefaultEndpoint

public Endpoint<E> getDefaultEndpoint()

setDefaultEndpoint

public void setDefaultEndpoint(Endpoint<E> defaultEndpoint)

setDefaultEndpointUri

public void setDefaultEndpointUri(String endpointUri)
Sets the default endpoint to use if none is specified


isUseEndpointCache

public boolean isUseEndpointCache()

setUseEndpointCache

public void setUseEndpointCache(boolean useEndpointCache)

resolveMandatoryEndpoint

protected Endpoint resolveMandatoryEndpoint(String endpointUri)

getMandatoryDefaultEndpoint

protected Endpoint<E> getMandatoryDefaultEndpoint()

doStart

protected void doStart()
                throws Exception
Specified by:
doStart in class ServiceSupport
Throws:
Exception

doStop

protected void doStop()
               throws Exception
Specified by:
doStop in class ServiceSupport
Throws:
Exception

extractResultBody

protected Object extractResultBody(E result)


Copyright © 2007 Apache Software Foundation. All Rights Reserved.