akka.camel.internal
Class CamelExchangeAdapter

java.lang.Object
  extended by akka.camel.internal.CamelExchangeAdapter

public class CamelExchangeAdapter
extends java.lang.Object

INTERNAL API Adapter for converting an org.apache.camel.Exchange to and from CamelMessage and akka.camel.Failure objects. The org.apache.camel.Message is mutable and not suitable to be used directly as messages between Actors. This adapter is used to convert to immutable messages to be used with Actors, and convert the immutable messages back to org.apache.camel.Message when using Camel.


Constructor Summary
CamelExchangeAdapter(org.apache.camel.Exchange exchange)
           
 
Method Summary
 org.apache.camel.Exchange exchange()
           
 java.lang.String getExchangeId()
          Returns the exchange id
 boolean isOutCapable()
          Returns if the exchange is out capable.
 void setFailure(FailureResult msg)
          Sets Exchange.getException from the given FailureResult message.
 void setRequest(CamelMessage msg)
          Sets Exchange.getIn from the given CamelMessage object.
 void setResponse(CamelMessage msg)
          Depending on the exchange pattern, sets Exchange.getIn or Exchange.getOut from the given CamelMessage object.
 AkkaCamelException toAkkaCamelException()
          Creates an AkkaCamelException object from the adapted Exchange.
 AkkaCamelException toAkkaCamelException(scala.collection.immutable.Map<java.lang.String,java.lang.Object> headers)
          Creates an AkkaCamelException object from the adapted Exchange.
 FailureResult toFailureMessage()
          Creates an immutable Failure object from the adapted Exchange so it can be used internally between Actors.
 FailureResult toFailureResult(scala.collection.immutable.Map<java.lang.String,java.lang.Object> headers)
          Creates an immutable FailureResult object from the adapted Exchange so it can be used internally between Actors.
 CamelMessage toRequestMessage()
          Creates an immutable CamelMessage object from Exchange.getIn so it can be used with Actors.
 CamelMessage toRequestMessage(scala.collection.immutable.Map<java.lang.String,java.lang.Object> headers)
          Creates an immutable CamelMessage object from Exchange.getIn so it can be used with Actors.
 CamelMessage toResponseMessage()
          Depending on the exchange pattern, creates an immutable CamelMessage object from Exchange.getIn or Exchange.getOut so it can be used with Actors.
 CamelMessage toResponseMessage(scala.collection.immutable.Map<java.lang.String,java.lang.Object> headers)
          Depending on the exchange pattern, creates an immutable CamelMessage object from Exchange.getIn or Exchange.getOut so it can be used with Actors.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CamelExchangeAdapter

public CamelExchangeAdapter(org.apache.camel.Exchange exchange)
Method Detail

exchange

public org.apache.camel.Exchange exchange()

getExchangeId

public java.lang.String getExchangeId()
Returns the exchange id

Returns:
(undocumented)

isOutCapable

public boolean isOutCapable()
Returns if the exchange is out capable.

Returns:
(undocumented)

setRequest

public void setRequest(CamelMessage msg)
Sets Exchange.getIn from the given CamelMessage object.

Parameters:
msg - (undocumented)

setResponse

public void setResponse(CamelMessage msg)
Depending on the exchange pattern, sets Exchange.getIn or Exchange.getOut from the given CamelMessage object. If the exchange is out-capable then the Exchange.getOut is set, otherwise Exchange.getIn.

Parameters:
msg - (undocumented)

setFailure

public void setFailure(FailureResult msg)
Sets Exchange.getException from the given FailureResult message. Headers of the FailureResult message are ignored.

Parameters:
msg - (undocumented)

toRequestMessage

public CamelMessage toRequestMessage()
Creates an immutable CamelMessage object from Exchange.getIn so it can be used with Actors.

Returns:
(undocumented)

toResponseMessage

public CamelMessage toResponseMessage()
Depending on the exchange pattern, creates an immutable CamelMessage object from Exchange.getIn or Exchange.getOut so it can be used with Actors. If the exchange is out-capable then the Exchange.getOut is set, otherwise Exchange.getIn.

Returns:
(undocumented)

toAkkaCamelException

public AkkaCamelException toAkkaCamelException()
Creates an AkkaCamelException object from the adapted Exchange. The cause of the AkkaCamelException is set to the exception on the adapted Exchange.

Depending on the exchange pattern, puts the headers from Exchange.getIn or Exchange.getOut on the AkkaCamelException.

If the exchange is out-capable then the headers of Exchange.getOut are used, otherwise the headers of Exchange.getIn are used.

Returns:
(undocumented)
See Also:
AkkaCamelException

toAkkaCamelException

public AkkaCamelException toAkkaCamelException(scala.collection.immutable.Map<java.lang.String,java.lang.Object> headers)
Creates an AkkaCamelException object from the adapted Exchange. The cause of the AkkaCamelException is set to the exception on the adapted Exchange.

Depending on the exchange pattern, adds the supplied headers and the headers from Exchange.getIn or Exchange.getOut together and passes these to the AkkaCamelException.

If the exchange is out-capable then the headers of Exchange.getOut are used, otherwise the headers of Exchange.getIn are used.

Parameters:
headers - additional headers to set on the exception in addition to those in the exchange.

Returns:
(undocumented)
See Also:
AkkaCamelException

toFailureMessage

public FailureResult toFailureMessage()
Creates an immutable Failure object from the adapted Exchange so it can be used internally between Actors.

Returns:
(undocumented)
See Also:
Failure

toFailureResult

public FailureResult toFailureResult(scala.collection.immutable.Map<java.lang.String,java.lang.Object> headers)
Creates an immutable FailureResult object from the adapted Exchange so it can be used internally between Actors.

Parameters:
headers - additional headers to set on the created CamelMessage in addition to those in the Camel message.

Returns:
(undocumented)
See Also:
Failure

toRequestMessage

public CamelMessage toRequestMessage(scala.collection.immutable.Map<java.lang.String,java.lang.Object> headers)
Creates an immutable CamelMessage object from Exchange.getIn so it can be used with Actors.

Parameters:
headers - additional headers to set on the created CamelMessage in addition to those in the Camel message.
Returns:
(undocumented)

toResponseMessage

public CamelMessage toResponseMessage(scala.collection.immutable.Map<java.lang.String,java.lang.Object> headers)
Depending on the exchange pattern, creates an immutable CamelMessage object from Exchange.getIn or Exchange.getOut so it can be used with Actors. If the exchange is out-capable then the Exchange.getOut is set, otherwise Exchange.getIn.

Parameters:
headers - additional headers to set on the created CamelMessage in addition to those in the Camel message.
Returns:
(undocumented)