use of org.apache.camel.spi.IdAware in project camel by apache.
the class ProcessorDefinition method makeProcessorImpl.
private Processor makeProcessorImpl(RouteContext routeContext) throws Exception {
Processor processor = null;
// allow any custom logic before we create the processor
preCreateProcessor();
// resolve properties before we create the processor
ProcessorDefinitionHelper.resolvePropertyPlaceholders(routeContext.getCamelContext(), this);
// resolve constant fields (eg Exchange.FILE_NAME)
ProcessorDefinitionHelper.resolveKnownConstantFields(this);
// also resolve properties and constant fields on embedded expressions
ProcessorDefinition<?> me = (ProcessorDefinition<?>) this;
if (me instanceof ExpressionNode) {
ExpressionNode exp = (ExpressionNode) me;
ExpressionDefinition expressionDefinition = exp.getExpression();
if (expressionDefinition != null) {
// resolve properties before we create the processor
ProcessorDefinitionHelper.resolvePropertyPlaceholders(routeContext.getCamelContext(), expressionDefinition);
// resolve constant fields (eg Exchange.FILE_NAME)
ProcessorDefinitionHelper.resolveKnownConstantFields(expressionDefinition);
}
}
// at first use custom factory
if (routeContext.getCamelContext().getProcessorFactory() != null) {
processor = routeContext.getCamelContext().getProcessorFactory().createProcessor(routeContext, this);
}
// fallback to default implementation if factory did not create the processor
if (processor == null) {
processor = createProcessor(routeContext);
}
// inject id
if (processor instanceof IdAware) {
String id = this.idOrCreate(routeContext.getCamelContext().getNodeIdFactory());
((IdAware) processor).setId(id);
}
if (processor == null) {
// no processor to make
return null;
}
return wrapProcessor(routeContext, processor);
}
use of org.apache.camel.spi.IdAware in project camel by apache.
the class ProcessorDefinition method createOutputsProcessorImpl.
protected Processor createOutputsProcessorImpl(RouteContext routeContext, Collection<ProcessorDefinition<?>> outputs) throws Exception {
List<Processor> list = new ArrayList<Processor>();
for (ProcessorDefinition<?> output : outputs) {
// allow any custom logic before we create the processor
output.preCreateProcessor();
// resolve properties before we create the processor
ProcessorDefinitionHelper.resolvePropertyPlaceholders(routeContext.getCamelContext(), output);
// resolve constant fields (eg Exchange.FILE_NAME)
ProcessorDefinitionHelper.resolveKnownConstantFields(output);
// also resolve properties and constant fields on embedded expressions
ProcessorDefinition<?> me = (ProcessorDefinition<?>) output;
if (me instanceof ExpressionNode) {
ExpressionNode exp = (ExpressionNode) me;
ExpressionDefinition expressionDefinition = exp.getExpression();
if (expressionDefinition != null) {
// resolve properties before we create the processor
ProcessorDefinitionHelper.resolvePropertyPlaceholders(routeContext.getCamelContext(), expressionDefinition);
// resolve constant fields (eg Exchange.FILE_NAME)
ProcessorDefinitionHelper.resolveKnownConstantFields(expressionDefinition);
}
}
Processor processor = createProcessor(routeContext, output);
// inject id
if (processor instanceof IdAware) {
String id = output.idOrCreate(routeContext.getCamelContext().getNodeIdFactory());
((IdAware) processor).setId(id);
}
if (output instanceof Channel && processor == null) {
continue;
}
Processor channel = wrapChannel(routeContext, processor, output);
list.add(channel);
}
// if more than one output wrap than in a composite processor else just keep it as is
Processor processor = null;
if (!list.isEmpty()) {
if (list.size() == 1) {
processor = list.get(0);
} else {
processor = createCompositeProcessor(routeContext, list);
}
}
return processor;
}
use of org.apache.camel.spi.IdAware in project camel by apache.
the class EventDrivenConsumerRoute method doFilter.
@SuppressWarnings("unchecked")
private void doFilter(String pattern, Navigate<Processor> nav, List<Processor> match) {
List<Processor> list = nav.next();
if (list != null) {
for (Processor proc : list) {
String id = null;
if (proc instanceof IdAware) {
id = ((IdAware) proc).getId();
}
if (EndpointHelper.matchPattern(id, pattern)) {
match.add(proc);
}
if (proc instanceof Navigate) {
Navigate<Processor> child = (Navigate<Processor>) proc;
doFilter(pattern, child, match);
}
}
}
}
Aggregations