Class Splitter
java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.support.processor.DelegateProcessor
org.openehealth.ipf.platform.camel.core.process.splitter.Splitter
- All Implemented Interfaces:
AutoCloseable
,DelegateProcessor
,Navigate<Processor>
,Processor
,Service
,ShutdownableService
,StatefulService
,SuspendableService
public class Splitter
extends org.apache.camel.support.processor.DelegateProcessor
A processor that splits an exchange into multiple exchanges by using a rule.
The rule generates the individual sub exchanges (i.e. the result exchanges
of the split).
An
AggregationStrategy
allows aggregation of the sub exchanges.- Author:
- Jens Riemschneider
-
Field Summary
Fields inherited from class org.apache.camel.support.processor.DelegateProcessor
processor
Fields inherited from class org.apache.camel.support.service.BaseService
BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaggregate
(AggregationStrategy strategy) Sets the strategy to aggregate data over all sub exchanges created by the splitter This method allows for chain configurationprotected void
finalizeAggregate
(Exchange origExchange, Exchange aggregate) Creates the actual aggregation result of the processor This method is called byprocessNext(Exchange)
to calculate the aggregation result of the splitter.protected void
finalizeSubExchange
(Exchange origExchange, Exchange subExchange, SplitIndex index) Updates the contents of sub exchanges This method is called byprocessNext(Exchange)
before sending a sub exchange to the destination processor.protected void
processNext
(Exchange origExchange) Processes the given exchange This method is the entry point for splitting the given exchange into its parts via the split rule.Methods inherited from class org.apache.camel.support.processor.DelegateProcessor
doBuild, doInit, doStart, doStop, getProcessor, hasNext, next, process, setProcessor, toString
Methods inherited from class org.apache.camel.support.service.BaseService
build, doFail, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.camel.ShutdownableService
shutdown
Methods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspending
Methods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend
-
Constructor Details
-
Splitter
Creates a splitter- Parameters:
splitRule
- expression that performs the splitting of the original exchangeprocessor
- destination processor for all sub exchanges. Can benull
if the destination is set later viaDelegateProcessor.setProcessor(Processor)
, e.g. via an intercept.
-
-
Method Details
-
aggregate
Sets the strategy to aggregate data over all sub exchanges created by the splitter This method allows for chain configuration- Parameters:
strategy
- the aggregation strategy- Returns:
- the splitter for chaining
-
processNext
Processes the given exchange This method is the entry point for splitting the given exchange into its parts via the split rule. Subclasses can change the created sub exchanges by overridingfinalizeSubExchange(Exchange, Exchange, SplitIndex)
and the aggregate result by overridingfinalizeAggregate(Exchange, Exchange)
.- Overrides:
processNext
in classorg.apache.camel.support.processor.DelegateProcessor
- Parameters:
origExchange
- exchange that should be split by this processor- Throws:
Exception
-
finalizeAggregate
Creates the actual aggregation result of the processor This method is called byprocessNext(Exchange)
to calculate the aggregation result of the splitter. The base implementation in this class simply copies the results of the aggregate into the original exchange. Sub classes should call this base method implementation to ensure compatibility with upcoming version.- Parameters:
origExchange
- the exchange that was originally passed toDelegateProcessor.process(Exchange)
. The base implementation changes the content of this exchange to ensure that further processing in the route is performed with the aggregated result.aggregate
- the aggregation result. This is the exchange that was determined by passing all processed sub exchanges to theAggregationStrategy
defined byaggregate(AggregationStrategy)
. This parameter can benull
if theAggregationStrategy
returned null.
-
finalizeSubExchange
Updates the contents of sub exchanges This method is called byprocessNext(Exchange)
before sending a sub exchange to the destination processor. It is the final chance to change the contents (body, header, etc.) of the sub exchange. The base implementation of this method currently performs no operations. However, it is recommended to call it in sub classes to ensure compatibility with upcoming version of this class.- Parameters:
origExchange
- original exchange passed toDelegateProcessor.process(Exchange)
subExchange
- sub exchange that was split off. The content of this exchange can be changed by this method.index
- index of the sub exchange in the result list of the split
-