org.apache.servicemix.jbi.messaging
Class MessageExchangeImpl

java.lang.Object
  extended by org.apache.servicemix.jbi.messaging.MessageExchangeImpl
All Implemented Interfaces:
Externalizable, Serializable, javax.jbi.messaging.MessageExchange
Direct Known Subclasses:
InOnlyImpl, InOptionalOutImpl, InOutImpl, RobustInOnlyImpl

public abstract class MessageExchangeImpl
extends Object
implements javax.jbi.messaging.MessageExchange, Externalizable

A simple message exchange declaration. This is partial, just giving us enough ME function for the doodle. This doesn't add anything new to the current MessageExchange definition.

Version:
$Revision: 564607 $
See Also:
Serialized Form

Nested Class Summary
static class MessageExchangeImpl.AgeComparator
          Comparator that can be used to sort exchanges according to their "age" in their processing: i.e.: a newly created exchange will be more than a DONE exchange ...
 
Nested classes/interfaces inherited from interface javax.jbi.messaging.MessageExchange
javax.jbi.messaging.MessageExchange.Role
 
Field Summary
protected static int CAN_CONSUMER
           
protected static int CAN_OWNER
           
protected static int CAN_PROVIDER
           
protected static int CAN_SEND
           
protected static int CAN_SET_FAULT_MSG
           
protected static int CAN_SET_IN_MSG
           
protected static int CAN_SET_OUT_MSG
           
protected static int CAN_STATUS_ACTIVE
           
protected static int CAN_STATUS_DONE
           
protected static int CAN_STATUS_ERROR
           
static String FAULT
           
static String IN
           
protected  String key
           
protected  PojoMarshaler marshaler
           
static int MAX_MSG_DISPLAY_SIZE
           
protected  MessageExchangeImpl mirror
           
static String OUT
           
protected  ExchangePacket packet
           
static boolean PRESERVE_CONTENT
           
protected  boolean pushDeliver
           
protected  ComponentContextImpl sourceContext
           
protected  int state
           
protected  int[][] states
           
protected static int STATES_CANS
           
protected static int STATES_NEXT_DONE
           
protected static int STATES_NEXT_ERROR
           
protected static int STATES_NEXT_FAULT
           
protected static int STATES_NEXT_OUT
           
static int SYNC_STATE_ASYNC
           
static int SYNC_STATE_SYNC_RECEIVED
           
static int SYNC_STATE_SYNC_SENT
           
protected  int syncState
           
static int TX_STATE_CONVEYED
          Transaction is being conveyed by the exchange.
static int TX_STATE_ENLISTED
          Exchange has been enlisted in the current transaction.
static int TX_STATE_NONE
          Exchange is not transactional
protected  Object txLock
           
protected  int txState
           
 
Fields inherited from interface javax.jbi.messaging.MessageExchange
JTA_TRANSACTION_PROPERTY_NAME
 
Constructor Summary
protected MessageExchangeImpl()
           
protected MessageExchangeImpl(ExchangePacket packet, int[][] states)
           
  MessageExchangeImpl(String exchangeId, URI pattern, int[][] states)
          Constructor
 
Method Summary
protected  boolean can(int c)
           
protected  void copyFrom(MessageExchangeImpl me)
           
 javax.jbi.messaging.Fault createFault()
          factory method for fault objects
 javax.jbi.messaging.NormalizedMessage createMessage()
           
 ActivationSpec getActivationSpec()
          Returns the activation spec that was provided when the component was registered
 ComponentNameSpace getDestinationId()
           
 javax.jbi.servicedesc.ServiceEndpoint getEndpoint()
           
 Exception getError()
           
 String getExchangeId()
           
 javax.jbi.messaging.Fault getFault()
           
 javax.jbi.messaging.NormalizedMessage getInMessage()
           
 QName getInterfaceName()
           
 String getKey()
          Compute a unique key for this exchange proxy.
 PojoMarshaler getMarshaler()
           
 javax.jbi.messaging.NormalizedMessage getMessage(String name)
          get a NormalizedMessage based on the message reference
 MessageExchangeImpl getMirror()
           
 QName getOperation()
           
 javax.jbi.messaging.NormalizedMessage getOutMessage()
           
 ExchangePacket getPacket()
           
 URI getPattern()
           
 Boolean getPersistent()
           
 Object getProperty(String name)
           
 Set getPropertyNames()
           
 javax.jbi.messaging.MessageExchange.Role getRole()
           
 QName getService()
           
 ComponentContextImpl getSourceContext()
          Returns the context which created the message exchange which can then be used for routing
 ComponentNameSpace getSourceId()
           
 javax.jbi.messaging.ExchangeStatus getStatus()
           
 int getSyncState()
           
 Transaction getTransactionContext()
           
 Object getTxLock()
           
 int getTxState()
           
 void handleAccept()
           
 void handleSend(boolean sync)
           
 boolean isPushDelivery()
           
 boolean isTransacted()
           
abstract  void readExternal(ObjectInput in)
           
 void setDestinationId(ComponentNameSpace destinationId)
           
 void setEndpoint(javax.jbi.servicedesc.ServiceEndpoint endpoint)
          Set an endpoint
 void setError(Exception exception)
          set the source of a failure
 void setFault(javax.jbi.messaging.Fault fault)
          set the fault message for the exchange
 void setInMessage(javax.jbi.messaging.NormalizedMessage message)
          set the in message
 void setInterfaceName(QName name)
          set an interface
 void setMarshaler(PojoMarshaler marshaler)
           
 void setMessage(javax.jbi.messaging.NormalizedMessage message, String name)
          set a NormalizedMessage with a named reference
 void setOperation(QName name)
          set an operation
 void setOutMessage(javax.jbi.messaging.NormalizedMessage message)
          set the out message
 void setPersistent(Boolean persistent)
           
 void setProperty(String name, Object value)
          set a named property on the exchange
 void setPushDeliver(boolean b)
           
 void setService(QName name)
          set a service
 void setSourceContext(ComponentContextImpl sourceContext)
          Set the context
 void setSourceId(ComponentNameSpace sourceId)
           
 void setStatus(javax.jbi.messaging.ExchangeStatus exchangeStatus)
          set the processing status
 void setSyncState(int syncState)
           
 void setTransactionContext(Transaction transaction)
          set the transaction
 void setTxLock(Object txLock)
           
 void setTxState(int txState)
           
 String toString()
           
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

IN

public static final String IN
See Also:
Constant Field Values

OUT

public static final String OUT
See Also:
Constant Field Values

FAULT

public static final String FAULT
See Also:
Constant Field Values

MAX_MSG_DISPLAY_SIZE

public static final int MAX_MSG_DISPLAY_SIZE
See Also:
Constant Field Values

PRESERVE_CONTENT

public static final boolean PRESERVE_CONTENT

SYNC_STATE_ASYNC

public static final int SYNC_STATE_ASYNC
See Also:
Constant Field Values

SYNC_STATE_SYNC_SENT

public static final int SYNC_STATE_SYNC_SENT
See Also:
Constant Field Values

SYNC_STATE_SYNC_RECEIVED

public static final int SYNC_STATE_SYNC_RECEIVED
See Also:
Constant Field Values

TX_STATE_NONE

public static final int TX_STATE_NONE
Exchange is not transactional

See Also:
Constant Field Values

TX_STATE_ENLISTED

public static final int TX_STATE_ENLISTED
Exchange has been enlisted in the current transaction. This means that the transaction must be commited for the exchange to be delivered.

See Also:
Constant Field Values

TX_STATE_CONVEYED

public static final int TX_STATE_CONVEYED
Transaction is being conveyed by the exchange. The transaction context will be given to the target component.

See Also:
Constant Field Values

CAN_SET_IN_MSG

protected static final int CAN_SET_IN_MSG
See Also:
Constant Field Values

CAN_SET_OUT_MSG

protected static final int CAN_SET_OUT_MSG
See Also:
Constant Field Values

CAN_SET_FAULT_MSG

protected static final int CAN_SET_FAULT_MSG
See Also:
Constant Field Values

CAN_PROVIDER

protected static final int CAN_PROVIDER
See Also:
Constant Field Values

CAN_CONSUMER

protected static final int CAN_CONSUMER
See Also:
Constant Field Values

CAN_SEND

protected static final int CAN_SEND
See Also:
Constant Field Values

CAN_STATUS_ACTIVE

protected static final int CAN_STATUS_ACTIVE
See Also:
Constant Field Values

CAN_STATUS_DONE

protected static final int CAN_STATUS_DONE
See Also:
Constant Field Values

CAN_STATUS_ERROR

protected static final int CAN_STATUS_ERROR
See Also:
Constant Field Values

CAN_OWNER

protected static final int CAN_OWNER
See Also:
Constant Field Values

STATES_CANS

protected static final int STATES_CANS
See Also:
Constant Field Values

STATES_NEXT_OUT

protected static final int STATES_NEXT_OUT
See Also:
Constant Field Values

STATES_NEXT_FAULT

protected static final int STATES_NEXT_FAULT
See Also:
Constant Field Values

STATES_NEXT_ERROR

protected static final int STATES_NEXT_ERROR
See Also:
Constant Field Values

STATES_NEXT_DONE

protected static final int STATES_NEXT_DONE
See Also:
Constant Field Values

sourceContext

protected ComponentContextImpl sourceContext

packet

protected ExchangePacket packet

marshaler

protected PojoMarshaler marshaler

state

protected int state

syncState

protected int syncState

txState

protected int txState

states

protected int[][] states

mirror

protected MessageExchangeImpl mirror

pushDeliver

protected transient boolean pushDeliver

txLock

protected transient Object txLock

key

protected transient String key
Constructor Detail

MessageExchangeImpl

public MessageExchangeImpl(String exchangeId,
                           URI pattern,
                           int[][] states)
Constructor

Parameters:
exchangeId -
pattern -

MessageExchangeImpl

protected MessageExchangeImpl(ExchangePacket packet,
                              int[][] states)

MessageExchangeImpl

protected MessageExchangeImpl()
Method Detail

copyFrom

protected void copyFrom(MessageExchangeImpl me)

can

protected boolean can(int c)

getActivationSpec

public ActivationSpec getActivationSpec()
Returns the activation spec that was provided when the component was registered

Returns:
the spec

getSourceContext

public ComponentContextImpl getSourceContext()
Returns the context which created the message exchange which can then be used for routing

Returns:
the context

setSourceContext

public void setSourceContext(ComponentContextImpl sourceContext)
Set the context

Parameters:
sourceContext -

getPacket

public ExchangePacket getPacket()
Returns:
the packet

getPattern

public URI getPattern()
Specified by:
getPattern in interface javax.jbi.messaging.MessageExchange
Returns:
URI of pattern exchange

getExchangeId

public String getExchangeId()
Specified by:
getExchangeId in interface javax.jbi.messaging.MessageExchange
Returns:
the exchange Id

getStatus

public javax.jbi.messaging.ExchangeStatus getStatus()
Specified by:
getStatus in interface javax.jbi.messaging.MessageExchange
Returns:
the processing status of the exchange

setStatus

public void setStatus(javax.jbi.messaging.ExchangeStatus exchangeStatus)
               throws javax.jbi.messaging.MessagingException
set the processing status

Specified by:
setStatus in interface javax.jbi.messaging.MessageExchange
Parameters:
exchangeStatus -
Throws:
javax.jbi.messaging.MessagingException

setError

public void setError(Exception exception)
set the source of a failure

Specified by:
setError in interface javax.jbi.messaging.MessageExchange
Parameters:
exception -

getError

public Exception getError()
Specified by:
getError in interface javax.jbi.messaging.MessageExchange
Returns:
the exception describing a processing error

getFault

public javax.jbi.messaging.Fault getFault()
Specified by:
getFault in interface javax.jbi.messaging.MessageExchange
Returns:
the fault message for an exchange

setFault

public void setFault(javax.jbi.messaging.Fault fault)
              throws javax.jbi.messaging.MessagingException
set the fault message for the exchange

Specified by:
setFault in interface javax.jbi.messaging.MessageExchange
Parameters:
fault -
Throws:
javax.jbi.messaging.MessagingException

createMessage

public javax.jbi.messaging.NormalizedMessage createMessage()
                                                    throws javax.jbi.messaging.MessagingException
Specified by:
createMessage in interface javax.jbi.messaging.MessageExchange
Returns:
a new message
Throws:
javax.jbi.messaging.MessagingException

createFault

public javax.jbi.messaging.Fault createFault()
                                      throws javax.jbi.messaging.MessagingException
factory method for fault objects

Specified by:
createFault in interface javax.jbi.messaging.MessageExchange
Returns:
a new fault
Throws:
javax.jbi.messaging.MessagingException

getMessage

public javax.jbi.messaging.NormalizedMessage getMessage(String name)
get a NormalizedMessage based on the message reference

Specified by:
getMessage in interface javax.jbi.messaging.MessageExchange
Parameters:
name -
Returns:
a NormalizedMessage

setMessage

public void setMessage(javax.jbi.messaging.NormalizedMessage message,
                       String name)
                throws javax.jbi.messaging.MessagingException
set a NormalizedMessage with a named reference

Specified by:
setMessage in interface javax.jbi.messaging.MessageExchange
Parameters:
message -
name -
Throws:
javax.jbi.messaging.MessagingException

getProperty

public Object getProperty(String name)
Specified by:
getProperty in interface javax.jbi.messaging.MessageExchange
Parameters:
name -
Returns:
the property from the exchange

setProperty

public void setProperty(String name,
                        Object value)
set a named property on the exchange

Specified by:
setProperty in interface javax.jbi.messaging.MessageExchange
Parameters:
name -
value -

getPropertyNames

public Set getPropertyNames()
Specified by:
getPropertyNames in interface javax.jbi.messaging.MessageExchange
Returns:
property names

setEndpoint

public void setEndpoint(javax.jbi.servicedesc.ServiceEndpoint endpoint)
Set an endpoint

Specified by:
setEndpoint in interface javax.jbi.messaging.MessageExchange
Parameters:
endpoint -

setService

public void setService(QName name)
set a service

Specified by:
setService in interface javax.jbi.messaging.MessageExchange
Parameters:
name -

setOperation

public void setOperation(QName name)
set an operation

Specified by:
setOperation in interface javax.jbi.messaging.MessageExchange
Parameters:
name -

setInterfaceName

public void setInterfaceName(QName name)
set an interface

Specified by:
setInterfaceName in interface javax.jbi.messaging.MessageExchange
Parameters:
name -

getEndpoint

public javax.jbi.servicedesc.ServiceEndpoint getEndpoint()
Specified by:
getEndpoint in interface javax.jbi.messaging.MessageExchange
Returns:
the endpoint

getService

public QName getService()
Specified by:
getService in interface javax.jbi.messaging.MessageExchange
Returns:
the service

getInterfaceName

public QName getInterfaceName()
Specified by:
getInterfaceName in interface javax.jbi.messaging.MessageExchange
Returns:
the interface name

getOperation

public QName getOperation()
Specified by:
getOperation in interface javax.jbi.messaging.MessageExchange
Returns:
the operation

getTransactionContext

public Transaction getTransactionContext()
Returns:
the transaction context

setTransactionContext

public void setTransactionContext(Transaction transaction)
                           throws javax.jbi.messaging.MessagingException
set the transaction

Parameters:
transaction -
Throws:
javax.jbi.messaging.MessagingException

isTransacted

public boolean isTransacted()
Specified by:
isTransacted in interface javax.jbi.messaging.MessageExchange
Returns:
true if transacted

getRole

public javax.jbi.messaging.MessageExchange.Role getRole()
Specified by:
getRole in interface javax.jbi.messaging.MessageExchange
Returns:
the Role of this exchange

getInMessage

public javax.jbi.messaging.NormalizedMessage getInMessage()
Returns:
the in message

setInMessage

public void setInMessage(javax.jbi.messaging.NormalizedMessage message)
                  throws javax.jbi.messaging.MessagingException
set the in message

Parameters:
message -
Throws:
javax.jbi.messaging.MessagingException

getOutMessage

public javax.jbi.messaging.NormalizedMessage getOutMessage()
Returns:
the out message

setOutMessage

public void setOutMessage(javax.jbi.messaging.NormalizedMessage message)
                   throws javax.jbi.messaging.MessagingException
set the out message

Parameters:
message -
Throws:
javax.jbi.messaging.MessagingException

getSourceId

public ComponentNameSpace getSourceId()
Returns:
Returns the sourceId.

setSourceId

public void setSourceId(ComponentNameSpace sourceId)
Parameters:
sourceId - The sourceId to set.

getDestinationId

public ComponentNameSpace getDestinationId()
Returns:
Returns the destinationId.

setDestinationId

public void setDestinationId(ComponentNameSpace destinationId)
Parameters:
destinationId - The destinationId to set.

getPersistent

public Boolean getPersistent()

setPersistent

public void setPersistent(Boolean persistent)

getMarshaler

public PojoMarshaler getMarshaler()

setMarshaler

public void setMarshaler(PojoMarshaler marshaler)

readExternal

public abstract void readExternal(ObjectInput in)
                           throws IOException,
                                  ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Throws:
IOException
ClassNotFoundException

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Throws:
IOException

handleSend

public void handleSend(boolean sync)
                throws javax.jbi.messaging.MessagingException
Throws:
javax.jbi.messaging.MessagingException

handleAccept

public void handleAccept()
                  throws javax.jbi.messaging.MessagingException
Throws:
javax.jbi.messaging.MessagingException

getMirror

public MessageExchangeImpl getMirror()

getSyncState

public int getSyncState()

setSyncState

public void setSyncState(int syncState)

getTxState

public int getTxState()
Returns:
the txState

setTxState

public void setTxState(int txState)
Parameters:
txState - the txState to set

isPushDelivery

public boolean isPushDelivery()

setPushDeliver

public void setPushDeliver(boolean b)

getTxLock

public Object getTxLock()
Returns:
the txLock

setTxLock

public void setTxLock(Object txLock)
Parameters:
txLock - the txLock to set

toString

public String toString()
Overrides:
toString in class Object

getKey

public String getKey()
Compute a unique key for this exchange proxy. It has to be different for the two sides of the exchange, so we include the role + the exchange id. Obviously, it works, because the role never change for a given proxy.

Returns:


Copyright © 2005-2008 Apache Software Foundation. All Rights Reserved.