001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.camel.spi; 018 019import org.apache.camel.NamedNode; 020import org.apache.camel.Processor; 021 022/** 023 * A factory to create {@link Processor} based on the {@link org.apache.camel.model.ProcessorDefinition definition}. 024 * <p/> 025 * This allows you to implement a custom factory in which you can control the creation of the processors. 026 * It also allows you to manipulate the {@link org.apache.camel.model.ProcessorDefinition definition}s for example to 027 * configure or change options. Its also possible to add new steps in the route by adding outputs to 028 * {@link org.apache.camel.model.ProcessorDefinition definition}s. 029 * <p/> 030 * <b>Important:</b> By returning <tt>null</tt> from the create methods you fallback to let the default implementation in Camel create 031 * the {@link Processor}. You want to do this if you <i>only</i> want to manipulate the 032 * {@link org.apache.camel.model.ProcessorDefinition definition}s. 033 */ 034public interface ProcessorFactory { 035 036 /** 037 * Creates the child processor. 038 * <p/> 039 * The child processor is an output from the given definition, for example the sub route in a splitter EIP. 040 * 041 * @param routeContext the route context 042 * @param definition the definition which represents the processor 043 * @param mandatory whether or not the child is mandatory 044 * @return the created processor, or <tt>null</tt> to let the default implementation in Camel create the processor. 045 * @throws Exception can be thrown if error creating the processor 046 */ 047 Processor createChildProcessor(RouteContext routeContext, NamedNode definition, boolean mandatory) throws Exception; 048 049 /** 050 * Creates the processor. 051 * 052 * @param routeContext the route context 053 * @param definition the definition which represents the processor 054 * @return the created processor, or <tt>null</tt> to let the default implementation in Camel create the processor. 055 * @throws Exception can be thrown if error creating the processor 056 */ 057 Processor createProcessor(RouteContext routeContext, NamedNode definition) throws Exception; 058 059}