org.apache.camel.impl
Class DefaultUnitOfWork

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

public class DefaultUnitOfWork
extends Object
implements UnitOfWork, Service

The default implementation of UnitOfWork

Version:
$Revision: 899628 $

Constructor Summary
DefaultUnitOfWork(Exchange exchange)
           
 
Method Summary
 void addSynchronization(Synchronization synchronization)
          Adds a synchronization hook
 void beginTransactedBy(Object transactionDefinition)
          Mark this UnitOfWork as being transacted by the given transaction definition.
 void done(Exchange exchange)
          Invoked when this unit of work has been completed, whether it has failed or completed
 void endTransactedBy(Object transactionDefinition)
          Mark this UnitOfWork as not transacted anymore by the given transaction definition.
 String getId()
          Returns the unique ID of this unit of work, lazily creating one if it does not yet have one
 Message getOriginalInMessage()
          Gets the original IN Message this Unit of Work was started with.
 RouteContext getRouteContext()
          Gets the RouteContext that this UnitOfWork currently is being routed through.
 TracedRouteNodes getTracedRouteNodes()
          Gets tracing information
 void handoverSynchronization(Exchange target)
          Handover all the registered synchronizations to the target Exchange.
 boolean isTransactedBy(Object transactionDefinition)
          Are we already transacted by the given transaction definition

The definition will most likely be a Spring TransactionTemplate when using Spring Transaction

 RouteContext popRouteContext()
          When finished being routed under the current RouteContext it should be removed.
 void pushRouteContext(RouteContext routeContext)
          Pushes the RouteContext that this UnitOfWork currently is being routed through.
 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 - is thrown if starting failed

stop

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

Specified by:
stop in interface Service
Throws:
Exception - is thrown if stopping failed

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

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

getTracedRouteNodes

public TracedRouteNodes getTracedRouteNodes()
Description copied from interface: UnitOfWork
Gets tracing information

Specified by:
getTracedRouteNodes in interface UnitOfWork
Returns:
trace information

isTransactedBy

public boolean isTransactedBy(Object transactionDefinition)
Description copied from interface: UnitOfWork
Are we already transacted by the given transaction definition

The definition will most likely be a Spring TransactionTemplate when using Spring Transaction

Specified by:
isTransactedBy in interface UnitOfWork
Parameters:
transactionDefinition - the transaction definition
Returns:
true if already, false otherwise

beginTransactedBy

public void beginTransactedBy(Object transactionDefinition)
Description copied from interface: UnitOfWork
Mark this UnitOfWork as being transacted by the given transaction definition.

The definition will most likely be a Spring TransactionTemplate when using Spring Transaction

When the transaction is completed then invoke the UnitOfWork.endTransactedBy(Object) method.

Specified by:
beginTransactedBy in interface UnitOfWork
Parameters:
transactionDefinition - the transaction definition

endTransactedBy

public void endTransactedBy(Object transactionDefinition)
Description copied from interface: UnitOfWork
Mark this UnitOfWork as not transacted anymore by the given transaction definition.

The definition will most likely be a Spring TransactionTemplate when using Spring Transaction

Specified by:
endTransactedBy in interface UnitOfWork
Parameters:
transactionDefinition - the transaction definition

getRouteContext

public RouteContext getRouteContext()
Description copied from interface: UnitOfWork
Gets the RouteContext that this UnitOfWork currently is being routed through.

Notice that an Exchange can be routed through multiple routes and thus the RouteContext can change over time.

Specified by:
getRouteContext in interface UnitOfWork
Returns:
the route context
See Also:
UnitOfWork.pushRouteContext(RouteContext), UnitOfWork.popRouteContext()

pushRouteContext

public void pushRouteContext(RouteContext routeContext)
Description copied from interface: UnitOfWork
Pushes the RouteContext that this UnitOfWork currently is being routed through.

Notice that an Exchange can be routed through multiple routes and thus the RouteContext can change over time.

Specified by:
pushRouteContext in interface UnitOfWork
Parameters:
routeContext - the route context

popRouteContext

public RouteContext popRouteContext()
Description copied from interface: UnitOfWork
When finished being routed under the current RouteContext it should be removed.

Specified by:
popRouteContext in interface UnitOfWork
Returns:
the route context or null if none existed


Copyright © 2007-2010 The Apache Software Foundation. All Rights Reserved.