org.apache.camel
Interface Exchange

All Known Implementing Classes:
BeanExchange, DefaultExchange, FileExchange, JMXExchange

public interface Exchange

The base message exchange interface providing access to the request, response and fault Message instances. Different providers such as JMS, JBI, CXF and HTTP can provide their own derived API to expose the underlying transport semantics to avoid the leaky abstractions of generic APIs.

Version:
$Revision: 563607 $

Method Summary
 Exchange copy()
          Creates a copy of the current message exchange so that it can be forwarded to another destination
 void copyFrom(Exchange source)
          Copies the data into this exchange from the given exchange #param source is the source from which headers and messages will be copied
 CamelContext getContext()
          Returns the container so that a processor can resolve endpoints from URIs
 Throwable getException()
          Returns the exception associated with this exchange
 String getExchangeId()
          Returns the exchange id
 Message getFault()
          Returns the fault message
 Message getIn()
          Returns the inbound request message
 Message getOut()
          Returns the outbound message, lazily creating one if one has not already been associated with this exchange.
 Message getOut(boolean lazyCreate)
          Returns the outbound message; optionally lazily creating one if one has not been associated with this exchange
 Map<String,Object> getProperties()
          Returns all of the properties associated with the exchange
 Object getProperty(String name)
          Returns a property associated with this exchange by name
<T> T
getProperty(String name, Class<T> type)
          Returns a property associated with this exchange by name and specifying the type required
 void setException(Throwable e)
          Sets the exception associated with this exchange
 void setExchangeId(String id)
          Set the exchange id
 void setProperty(String name, Object value)
          Sets a property on the exchange
 

Method Detail

getExchangeId

String getExchangeId()
Returns the exchange id

Returns:
the unique id of the exchange

setExchangeId

void setExchangeId(String id)
Set the exchange id

Parameters:
id -

getProperty

Object getProperty(String name)
Returns a property associated with this exchange by name

Parameters:
name - the name of the property
Returns:
the value of the given header or null if there is no property for the given name

getProperty

<T> T getProperty(String name,
                  Class<T> type)
Returns a property associated with this exchange by name and specifying the type required

Parameters:
name - the name of the property
type - the type of the property
Returns:
the value of the given header or null if there is no property for the given name or null if it cannot be converted to the given type

setProperty

void setProperty(String name,
                 Object value)
Sets a property on the exchange

Parameters:
name - of the property
value - to associate with the name

getProperties

Map<String,Object> getProperties()
Returns all of the properties associated with the exchange

Returns:
all the headers in a Map

getIn

Message getIn()
Returns the inbound request message

Returns:
the message

getOut

Message getOut()
Returns the outbound message, lazily creating one if one has not already been associated with this exchange. If you want to inspect this property but not force lazy creation then invoke the getOut(boolean) method passing in null

Returns:
the response

getOut

Message getOut(boolean lazyCreate)
Returns the outbound message; optionally lazily creating one if one has not been associated with this exchange

Returns:
the response

getFault

Message getFault()
Returns the fault message

Returns:
the fault

getException

Throwable getException()
Returns the exception associated with this exchange

Returns:
the exception (or null if no faults)

setException

void setException(Throwable e)
Sets the exception associated with this exchange

Parameters:
e -

getContext

CamelContext getContext()
Returns the container so that a processor can resolve endpoints from URIs

Returns:
the container which owns this exchange

copy

Exchange copy()
Creates a copy of the current message exchange so that it can be forwarded to another destination


copyFrom

void copyFrom(Exchange source)
Copies the data into this exchange from the given exchange #param source is the source from which headers and messages will be copied



Copyright © 2007 Apache Software Foundation. All Rights Reserved.