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     */
017    package org.apache.camel;
018    
019    import java.util.List;
020    
021    import org.apache.camel.model.ProcessorDefinition;
022    import org.apache.camel.spi.InterceptStrategy;
023    import org.apache.camel.spi.RouteContext;
024    
025    /**
026     * Channel acts as a channel between {@link Processor}s in the route graph.
027     * <p/>
028     * The channel is responsible for routing the {@link Exchange} to the next {@link Processor} in the route graph.
029     *
030     * @version $Revision: 788578 $
031     */
032    public interface Channel extends Processor, Navigate<Processor> {
033    
034        List<Processor> next();
035    
036        /**
037         * Sets the processor that the channel should route the {@link Exchange} to.
038         *
039         * @param next  the next processor
040         */
041        void setNextProcessor(Processor next);
042    
043        /**
044         * Sets the {@link org.apache.camel.processor.ErrorHandler} this Channel uses.
045         *
046         * @param errorHandler the error handler
047         */
048        void setErrorHandler(Processor errorHandler);
049    
050        /**
051         * Gets the {@link org.apache.camel.processor.ErrorHandler} this Channel uses.
052         *
053         * @return the error handler, or <tt>null</tt> if no error handler is used.
054         */
055        Processor getErrorHandler();
056    
057        /**
058         * Adds a {@link org.apache.camel.spi.InterceptStrategy} to apply each {@link Exchange} before
059         * its routed to the next {@link Processor}.
060         *
061         * @param strategy  the intercept strategy
062         */
063        void addInterceptStrategy(InterceptStrategy strategy);
064    
065        /**
066         * Adds a list of {@link org.apache.camel.spi.InterceptStrategy} to apply each {@link Exchange} before
067         * its routed to the next {@link Processor}.
068         *
069         * @param strategy  list of strategies
070         */
071        void addInterceptStrategies(List<InterceptStrategy> strategy);
072    
073        /**
074         * Gets the list of {@link org.apache.camel.spi.InterceptStrategy} registered to this Channel.
075         *
076         * @return list of strategies, returns an empty list if no strategies is registered.
077         */
078        List<InterceptStrategy> getInterceptStrategies();
079    
080        /**
081         * Initializes the channel.
082         *
083         * @param outputDefinition  the route defintion the {@link Channel} represents
084         * @param routeContext      the route context
085         * @throws Exception is thrown if some error occured
086         */
087        void initChannel(ProcessorDefinition outputDefinition, RouteContext routeContext) throws Exception;
088    
089        /**
090         * Gets the wrapped output that at runtime should be delegated to.
091         *
092         * @return the output to route the {@link Exchange} to
093         */
094        Processor getOutput();
095    
096        /**
097         * Sets the wrapped output that at runtime should be delegated to.
098         *
099         * @param output the output to route the {@link Exchange} to
100         */
101        void setOutput(Processor output);
102    
103        /**
104         * Gets the next {@link Processor} to route to (not wrapped)
105         *
106         * @return  the next processor
107         */
108        Processor getNextProcessor();
109    
110        /**
111         * Gets the defintion of the next processor
112         *
113         * @return the processor definition
114         */
115        ProcessorDefinition getProcessorDefinition();
116    
117    }