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
  • Constructor Details

    • Splitter

      public Splitter(Expression splitRule, Processor processor)
      Creates a splitter
      Parameters:
      splitRule - expression that performs the splitting of the original exchange
      processor - destination processor for all sub exchanges. Can be null if the destination is set later via DelegateProcessor.setProcessor(Processor), e.g. via an intercept.
  • Method Details

    • aggregate

      public Splitter aggregate(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(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 overriding finalizeSubExchange(Exchange, Exchange, SplitIndex) and the aggregate result by overriding finalizeAggregate(Exchange, Exchange).
      Overrides:
      processNext in class org.apache.camel.support.processor.DelegateProcessor
      Parameters:
      origExchange - exchange that should be split by this processor
      Throws:
      Exception
    • finalizeAggregate

      protected void finalizeAggregate(Exchange origExchange, Exchange aggregate)
      Creates the actual aggregation result of the processor This method is called by processNext(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 to DelegateProcessor.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 the AggregationStrategy defined by aggregate(AggregationStrategy). This parameter can be null if the AggregationStrategy returned null.
    • finalizeSubExchange

      protected void finalizeSubExchange(Exchange origExchange, Exchange subExchange, SplitIndex index)
      Updates the contents of sub exchanges This method is called by processNext(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 to DelegateProcessor.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