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.model;
018    
019    import java.util.ArrayList;
020    import java.util.List;
021    
022    import javax.xml.bind.annotation.XmlElement;
023    import javax.xml.bind.annotation.XmlElementRef;
024    import javax.xml.bind.annotation.XmlType;
025    import javax.xml.bind.annotation.XmlAccessorType;
026    import javax.xml.bind.annotation.XmlAccessType;
027    
028    import org.apache.commons.logging.Log;
029    import org.apache.commons.logging.LogFactory;
030    
031    /**
032     * A useful base class for output types
033     *
034     * @version $Revision: 1.1 $
035     */
036    @XmlType(name = "outputType")
037    @XmlAccessorType(XmlAccessType.FIELD)
038    public class OutputType extends ProcessorType {
039        private static final transient Log LOG = LogFactory.getLog(OutputType.class);
040    
041        @XmlElementRef
042        protected List<ProcessorType> outputs = new ArrayList<ProcessorType>();
043        @XmlElementRef
044        private List<InterceptorType> interceptors = new ArrayList<InterceptorType>();
045    
046        public List<ProcessorType> getOutputs() {
047            return outputs;
048        }
049    
050        public void setOutputs(List<ProcessorType> outputs) {
051            this.outputs = outputs;
052            if (outputs != null) {
053                for (ProcessorType output : outputs) {
054                    configureChild(output);
055                }
056            }
057        }
058    
059        public List<InterceptorType> getInterceptors() {
060            return interceptors;
061        }
062    
063        public void setInterceptors(List<InterceptorType> interceptors) {
064            this.interceptors = interceptors;
065        }
066    
067        @Override
068        protected void configureChild(ProcessorType output) {
069            if (isInheritErrorHandler()) {
070                output.setErrorHandlerBuilder(getErrorHandlerBuilder());
071            }
072            // don't inherit interceptors by default
073    /*
074            List<InterceptorType> list = output.getInterceptors();
075            if (list == null) {
076                log.warn("No interceptor collection: " + output);
077            }
078            else {
079                list.addAll(getInterceptors());
080            }
081    */
082        }
083    }