use of org.apache.camel.processor.aggregate.AggregationStrategyBeanAdapter in project camel by apache.
the class AggregationStrategies method beanAllowNull.
/**
* Creates a {@link AggregationStrategyBeanAdapter} for using a POJO as the aggregation strategy.
*/
public static AggregationStrategy beanAllowNull(Class<?> type, String methodName) {
AggregationStrategyBeanAdapter adapter = new AggregationStrategyBeanAdapter(type, methodName);
adapter.setAllowNullOldExchange(true);
adapter.setAllowNullNewExchange(true);
return adapter;
}
use of org.apache.camel.processor.aggregate.AggregationStrategyBeanAdapter in project camel by apache.
the class AggregateDefinition method createAggregationStrategy.
private AggregationStrategy createAggregationStrategy(RouteContext routeContext) {
AggregationStrategy strategy = getAggregationStrategy();
if (strategy == null && strategyRef != null) {
Object aggStrategy = routeContext.lookup(strategyRef, Object.class);
if (aggStrategy instanceof AggregationStrategy) {
strategy = (AggregationStrategy) aggStrategy;
} else if (aggStrategy != null) {
AggregationStrategyBeanAdapter adapter = new AggregationStrategyBeanAdapter(aggStrategy, getAggregationStrategyMethodName());
if (getStrategyMethodAllowNull() != null) {
adapter.setAllowNullNewExchange(getStrategyMethodAllowNull());
adapter.setAllowNullOldExchange(getStrategyMethodAllowNull());
}
strategy = adapter;
} else {
throw new IllegalArgumentException("Cannot find AggregationStrategy in Registry with name: " + strategyRef);
}
}
if (groupExchanges != null && groupExchanges) {
if (strategy != null || strategyRef != null) {
throw new IllegalArgumentException("Options groupExchanges and AggregationStrategy cannot be enabled at the same time");
}
if (eagerCheckCompletion != null && !eagerCheckCompletion) {
throw new IllegalArgumentException("Option eagerCheckCompletion cannot be false when groupExchanges has been enabled");
}
// set eager check to enabled by default when using grouped exchanges
setEagerCheckCompletion(true);
// if grouped exchange is enabled then use special strategy for that
strategy = new GroupedExchangeAggregationStrategy();
}
if (strategy == null) {
throw new IllegalArgumentException("AggregationStrategy or AggregationStrategyRef must be set on " + this);
}
if (strategy instanceof CamelContextAware) {
((CamelContextAware) strategy).setCamelContext(routeContext.getCamelContext());
}
return strategy;
}
use of org.apache.camel.processor.aggregate.AggregationStrategyBeanAdapter in project camel by apache.
the class AggregationStrategies method beanAllowNull.
/**
* Creates a {@link AggregationStrategyBeanAdapter} for using a POJO as the aggregation strategy.
*/
public static AggregationStrategy beanAllowNull(Object bean, String methodName) {
AggregationStrategyBeanAdapter adapter = new AggregationStrategyBeanAdapter(bean, methodName);
adapter.setAllowNullOldExchange(true);
adapter.setAllowNullNewExchange(true);
return adapter;
}
use of org.apache.camel.processor.aggregate.AggregationStrategyBeanAdapter in project camel by apache.
the class AggregationStrategyBeanAdapterAllowNullOldExchangeTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
myStrategy = new AggregationStrategyBeanAdapter(appender, "append");
myStrategy.setAllowNullOldExchange(true);
from("direct:start").aggregate(constant(true), myStrategy).completionSize(3).to("mock:result");
}
};
}
use of org.apache.camel.processor.aggregate.AggregationStrategyBeanAdapter in project camel by apache.
the class AggregationStrategyBeanAdapterPollEnrichAllowNullNewExchangeTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
myStrategy = new AggregationStrategyBeanAdapter(appender, "append");
myStrategy.setAllowNullNewExchange(true);
from("direct:start").pollEnrich("seda:foo", 10, myStrategy).to("mock:result");
}
};
}
Aggregations