org.apache.camel.impl
Class DefaultUnitOfWork

java.lang.Object
  extended by org.apache.camel.impl.DefaultUnitOfWork
All Implemented Interfaces:
Service, TraceableUnitOfWork, UnitOfWork

public class DefaultUnitOfWork
extends Object
implements TraceableUnitOfWork, Service

The default implementation of UnitOfWork

Version:
$Revision: 793288 $

Constructor Summary
DefaultUnitOfWork(Exchange exchange)
           
 
Method Summary
 void addSynchronization(Synchronization synchronization)
          Adds a synchronization hook
 void addTraced(RouteNode entry)
          Adds the entry that was intercepted
 void done(Exchange exchange)
          Invoked when this unit of work has been completed, whether it has failed or completed
 int getAndIncrement(ProcessorDefinition node)
          A private counter that increments, is used to as book keeping how far this exchange have been intercepted by the general intercept().
 String getId()
          Returns the unique ID of this unit of work, lazily creating one if it does not yet have one
 RouteNode getLastNode()
          Gets the last node, is null if no last exists.
 List<RouteNode> getNodes()
          Gets the current list of nodes, representing the route path the current Exchange has currently taken.
 Message getOriginalInMessage()
          Gets the original IN Message this Unit of Work was started with.
 RouteNode getSecondLastNode()
          Gets the 2nd last node, is null if no last exists.
 void handoverSynchronization(Exchange target)
          Handover all the registered synchronizations to the target Exchange.
 void removeSynchronization(Synchronization synchronization)
          Removes a synchronization hook
 void start()
          Starts the service
 void stop()
          Stops the service
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultUnitOfWork

public DefaultUnitOfWork(Exchange exchange)
Method Detail

start

public void start()
           throws Exception
Description copied from interface: Service
Starts the service

Specified by:
start in interface Service
Throws:
Exception

stop

public void stop()
          throws Exception
Description copied from interface: Service
Stops the service

Specified by:
stop in interface Service
Throws:
Exception

addSynchronization

public void addSynchronization(Synchronization synchronization)
Description copied from interface: UnitOfWork
Adds a synchronization hook

Specified by:
addSynchronization in interface UnitOfWork
Parameters:
synchronization - the hook

removeSynchronization

public void removeSynchronization(Synchronization synchronization)
Description copied from interface: UnitOfWork
Removes a synchronization hook

Specified by:
removeSynchronization in interface UnitOfWork
Parameters:
synchronization - the hook

handoverSynchronization

public void handoverSynchronization(Exchange target)
Description copied from interface: UnitOfWork
Handover all the registered synchronizations to the target Exchange.

This is used when a route turns into asynchronous and the Exchange that is continued and routed in the async thread should do the on completion callbacks instead of the original synchronous thread.

Specified by:
handoverSynchronization in interface UnitOfWork
Parameters:
target - the target exchange

done

public void done(Exchange exchange)
Description copied from interface: UnitOfWork
Invoked when this unit of work has been completed, whether it has failed or completed

Specified by:
done in interface UnitOfWork
Parameters:
exchange - the current exchange

getId

public String getId()
Description copied from interface: UnitOfWork
Returns the unique ID of this unit of work, lazily creating one if it does not yet have one

Specified by:
getId in interface UnitOfWork
Returns:
the unique ID

addTraced

public void addTraced(RouteNode entry)
Description copied from interface: TraceableUnitOfWork
Adds the entry that was intercepted

Specified by:
addTraced in interface TraceableUnitOfWork
Parameters:
entry - the entry

getLastNode

public RouteNode getLastNode()
Description copied from interface: TraceableUnitOfWork
Gets the last node, is null if no last exists.

Specified by:
getLastNode in interface TraceableUnitOfWork

getSecondLastNode

public RouteNode getSecondLastNode()
Description copied from interface: TraceableUnitOfWork
Gets the 2nd last node, is null if no last exists.

Specified by:
getSecondLastNode in interface TraceableUnitOfWork

getNodes

public List<RouteNode> getNodes()
Description copied from interface: TraceableUnitOfWork
Gets the current list of nodes, representing the route path the current Exchange has currently taken.

Specified by:
getNodes in interface TraceableUnitOfWork

getOriginalInMessage

public Message getOriginalInMessage()
Description copied from interface: UnitOfWork
Gets the original IN Message this Unit of Work was started with.

Specified by:
getOriginalInMessage in interface UnitOfWork
Returns:
the original IN Message

getAndIncrement

public int getAndIncrement(ProcessorDefinition node)
Description copied from interface: TraceableUnitOfWork
A private counter that increments, is used to as book keeping how far this exchange have been intercepted by the general intercept().

We need this special book keeping to keep correct order when dealing with concurrent exchanges being routed in the same route path.

Specified by:
getAndIncrement in interface TraceableUnitOfWork
Parameters:
node - the intercept node
Returns:
the current count


Apache CAMEL