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