org.apache.servicemix.nmr.api
Interface Exchange

All Superinterfaces:
java.io.Serializable
All Known Subinterfaces:
InternalExchange

public interface Exchange
extends java.io.Serializable

Represents a message exchange. An exchange is used to interact with a channel representing a link to a logical endpoint. Exchanges are created using the Channel.

Since:
4.0
Version:
$Revision: $

Method Summary
 void cancel()
          Cancels a pending synchronous exchange.
 Exchange copy()
          Duplicates this exchange and returns a new copy
 void copyFrom(Exchange exchange)
          Copy the given exchange to this one
 java.lang.String display(boolean displayContent)
          Returns a string representation of this exchange.
 void ensureReReadable()
          Make sure that all streams contained in the content and in attachments are transformed to re-readable sources.
 java.lang.Exception getError()
          Obtains the error of this exchange
 Message getFault()
          Obtains the fault message, lazily creating one if none has been associated with this exchange and if this exchange supports a faut message.
 Message getFault(boolean lazyCreate)
          Returns the fault message, optionally creating one if one has not already been associated with this exchange
 java.lang.String getId()
          The unique id of this exchange
 Message getIn()
          Obtains the input message, lazily creating one if none has been associated with this exchange.
 Message getIn(boolean lazyCreate)
          Returns the inbound message, optionally creating one if one has not already been associated with this exchange.
 Message getMessage(Type type)
          Obtains the given message, lazily creating one if none has been associated with this exchange and if this exchange supports a faut message.
 Message getMessage(Type type, boolean lazyCreate)
          Returns the message of the given type, optionally creating one if one has not already been associated with this exchange
 javax.xml.namespace.QName getOperation()
          The service operation of this exchange
 Message getOut()
          Obtains the outbound message, lazily creating one if none has been associated with this exchange and if this exchange supports an out message.
 Message getOut(boolean lazyCreate)
          Returns the outbound message, optionally creating one if one has not already been associated with this exchange
 Pattern getPattern()
          The exchange pattern
 java.util.Map<java.lang.String,java.lang.Object> getProperties()
          Return all the properties associated with this exchange
<T> T
getProperty(java.lang.Class<T> type)
          Get a typed property.
 java.lang.Object getProperty(java.lang.String name)
          Get a given property by its name.
<T> T
getProperty(java.lang.String name, java.lang.Class<T> type)
          Returns a property associated with this exchange by name and specifying the type required
 Role getRole()
          The role of the exchange.
 Status getStatus()
          The status of the exchange
 Reference getTarget()
          The target used for this exchange
<T> T
removeProperty(java.lang.Class<T> type)
          Remove the property of the specified type
 java.lang.Object removeProperty(java.lang.String name)
          Remove the given property and returns its value.
 void setError(java.lang.Exception error)
          Set the error on this exchange
 void setFault(Message message)
          Set the fault message.
 void setIn(Message message)
          Set the inbound message.
 void setMessage(Type type, Message message)
          Set the message.
 void setOperation(javax.xml.namespace.QName operation)
          The service operation of this exchange
 void setOut(Message message)
          Set the outbound message.
 void setProperties(java.util.Map<java.lang.String,java.lang.Object> properties)
          Set all the properties
<T> void
setProperty(java.lang.Class<T> type, T value)
          Set a typed property on this exchange.
 void setProperty(java.lang.String name, java.lang.Object value)
          Set a property on this exchange.
 void setStatus(Status status)
          Set the status of the exchange
 void setTarget(Reference target)
          The target used for this exchange
 

Method Detail

getId

java.lang.String getId()
The unique id of this exchange

Returns:

getPattern

Pattern getPattern()
The exchange pattern

Returns:

getRole

Role getRole()
The role of the exchange.

Returns:

getStatus

Status getStatus()
The status of the exchange

Returns:

setStatus

void setStatus(Status status)
Set the status of the exchange

Parameters:
status - the new status

getTarget

Reference getTarget()
The target used for this exchange

Returns:

setTarget

void setTarget(Reference target)
The target used for this exchange

Parameters:
target - the target endpoint

getOperation

javax.xml.namespace.QName getOperation()
The service operation of this exchange

Returns:
the operation

setOperation

void setOperation(javax.xml.namespace.QName operation)
The service operation of this exchange

Parameters:
operation - the operation

getProperty

java.lang.Object getProperty(java.lang.String name)
Get a given property by its name.

Parameters:
name - the name of the property to retrieve
Returns:
the value of the property or null if none has been set

getProperty

<T> T getProperty(java.lang.Class<T> type)
Get a typed property.

Parameters:
type - the type of the property to retrieve
Returns:
the value of the property or null if none has been set

getProperty

<T> T getProperty(java.lang.String name,
                  java.lang.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

getProperties

java.util.Map<java.lang.String,java.lang.Object> getProperties()
Return all the properties associated with this exchange

Returns:
all the properties

setProperty

void setProperty(java.lang.String name,
                 java.lang.Object value)
Set a property on this exchange. Giving null will actually remove the property for the list.

Parameters:
name - the name of the property
value - the value for this property or null

setProperty

<T> void setProperty(java.lang.Class<T> type,
                     T value)
Set a typed property on this exchange.

Parameters:
type - the key
value - the value

removeProperty

java.lang.Object removeProperty(java.lang.String name)
Remove the given property and returns its value.

Parameters:
name - the name of the property
Returns:
the previous value

removeProperty

<T> T removeProperty(java.lang.Class<T> type)
Remove the property of the specified type

Parameters:
type - the type of the property
Returns:
the previous value

setProperties

void setProperties(java.util.Map<java.lang.String,java.lang.Object> properties)
Set all the properties

Parameters:
properties - the new properties

getIn

Message getIn()
Obtains the input message, lazily creating one if none has been associated with this exchange. If you want to inspect this property but not force lazy creation then invoke the getIn(boolean) method passing in false

Returns:
the input message

getIn

Message getIn(boolean lazyCreate)
Returns the inbound message, optionally creating one if one has not already been associated with this exchange.

Parameters:
lazyCreate - true if the message should be created
Returns:
the input message

setIn

void setIn(Message message)
Set the inbound message.

Parameters:
message - the new inbound message

getOut

Message getOut()
Obtains the outbound message, lazily creating one if none has been associated with this exchange and if this exchange supports an out message. If you want to inspect this property but not force lazy creation then invoke the getOut(boolean) method passing in false

Returns:
the output message

getOut

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

Returns:
the out message

setOut

void setOut(Message message)
Set the outbound message.

Parameters:
message - the new outbound message

getFault

Message getFault()
Obtains the fault message, lazily creating one if none has been associated with this exchange and if this exchange supports a faut message. If you want to inspect this property but not force lazy creation then invoke the getFault(boolean) method passing in false

Returns:
the fault message

getFault

Message getFault(boolean lazyCreate)
Returns the fault message, optionally creating one if one has not already been associated with this exchange

Returns:
the fault message

setFault

void setFault(Message message)
Set the fault message.

Parameters:
message - the new fault message

getMessage

Message getMessage(Type type)
Obtains the given message, lazily creating one if none has been associated with this exchange and if this exchange supports a faut message. If you want to inspect this property but not force lazy creation then invoke the getMessage(Type, boolean) method passing in false

Parameters:
type - the type of message to retrieve
Returns:
the message or null if this pattern does not support this type of message

getMessage

Message getMessage(Type type,
                   boolean lazyCreate)
Returns the message of the given type, optionally creating one if one has not already been associated with this exchange

Parameters:
type - the type of message to retrieve
Returns:
the given message

setMessage

void setMessage(Type type,
                Message message)
Set the message.

Parameters:
type - the type of the message to set
message - the new inbound message

getError

java.lang.Exception getError()
Obtains the error of this exchange

Returns:
the exception that caused the exchange to fail

setError

void setError(java.lang.Exception error)
Set the error on this exchange

Parameters:
error - the exception that caused the exchange to fail

copyFrom

void copyFrom(Exchange exchange)
Copy the given exchange to this one

Parameters:
exchange - the exchange to copy from

copy

Exchange copy()
Duplicates this exchange and returns a new copy

Returns:
a copy of this exchange

ensureReReadable

void ensureReReadable()
Make sure that all streams contained in the content and in attachments are transformed to re-readable sources. This method will be called by the framework when persisting the exchange or when displaying it


display

java.lang.String display(boolean displayContent)
Returns a string representation of this exchange. The displayContent property can be specified to control wether the content should be displayed or not. If set to true, the content and attachments will be converted into re-readable objects (for java.io.InputStream and javax.xml.transform.Source objects) and printed.

Parameters:
displayContent - if the content and attachments of the exchange should be transformed if needed and displayed or left unmodified
Returns:
the string representation

cancel

void cancel()
Cancels a pending synchronous exchange. The canceled exchange's status will be set to Status.Error



Copyright © 2005-2009 The Apache Software Foundation. All Rights Reserved.