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
,org.apache.camel.DelegateProcessor
,org.apache.camel.Navigate<org.apache.camel.Processor>
,org.apache.camel.Processor
,org.apache.camel.Service
,org.apache.camel.ShutdownableService
,org.apache.camel.StatefulService
,org.apache.camel.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). AnAggregationStrategy
allows aggregation of the sub exchanges.- Author:
- Jens Riemschneider
-
-
Constructor Summary
Constructors Constructor Description Splitter(org.apache.camel.Expression splitRule, org.apache.camel.Processor processor)
Creates a splitter
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Splitter
aggregate(org.apache.camel.AggregationStrategy strategy)
Sets the strategy to aggregate data over all sub exchanges created by the splitter This method allows for chain configurationprotected void
finalizeAggregate(org.apache.camel.Exchange origExchange, org.apache.camel.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(org.apache.camel.Exchange origExchange, org.apache.camel.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(org.apache.camel.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
doStart, doStop, getProcessor, hasNext, next, process, setProcessor, toString
-
Methods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doInit, 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
-
-
-
-
Constructor Detail
-
Splitter
public Splitter(org.apache.camel.Expression splitRule, org.apache.camel.Processor processor)
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 Detail
-
aggregate
public Splitter aggregate(org.apache.camel.AggregationStrategy strategy)
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
protected void processNext(org.apache.camel.Exchange origExchange) throws Exception
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
protected void finalizeAggregate(org.apache.camel.Exchange origExchange, org.apache.camel.Exchange aggregate)
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
protected void finalizeSubExchange(org.apache.camel.Exchange origExchange, org.apache.camel.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. 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
-
-