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.config;
018    
019    import javax.xml.bind.annotation.XmlAccessType;
020    import javax.xml.bind.annotation.XmlAccessorType;
021    import javax.xml.bind.annotation.XmlAttribute;
022    import javax.xml.bind.annotation.XmlRootElement;
023    import javax.xml.bind.annotation.XmlTransient;
024    
025    import org.apache.camel.processor.resequencer.DefaultExchangeComparator;
026    import org.apache.camel.processor.resequencer.ExpressionResultComparator;
027    
028    /**
029     * Defines the configuration parameters for the {@link org.apache.camel.processor.StreamResequencer}.
030     *
031     * @version 
032     */
033    @XmlRootElement
034    @XmlAccessorType(XmlAccessType.FIELD)
035    public class StreamResequencerConfig extends ResequencerConfig {
036        @XmlAttribute
037        private Integer capacity;
038        @XmlAttribute
039        private Long timeout;
040        @XmlAttribute
041        private Boolean ignoreInvalidExchanges;
042        @XmlTransient
043        private ExpressionResultComparator comparator;
044    
045        /**
046         * Creates a new {@link StreamResequencerConfig} instance using default
047         * values for <code>capacity</code> (1000) and <code>timeout</code>
048         * (1000L). Elements of the sequence are compared using the
049         * {@link DefaultExchangeComparator}.
050         */
051        public StreamResequencerConfig() {
052            this(1000, 1000L);
053        }
054    
055        /**
056         * Creates a new {@link BatchResequencerConfig} instance using the given
057         * values for <code>capacity</code> and <code>timeout</code>. Elements
058         * of the sequence are compared using the {@link DefaultExchangeComparator}.
059         * 
060         * @param capacity   capacity of the resequencer's inbound queue.
061         * @param timeout    minimum time to wait for missing elements (messages).
062         */
063        public StreamResequencerConfig(int capacity, long timeout) {
064            this(capacity, timeout, new DefaultExchangeComparator());
065        }
066    
067        /**
068         * Creates a new {@link BatchResequencerConfig} instance using the given
069         * values for <code>capacity</code> and <code>timeout</code>. Elements
070         * of the sequence are compared with the given
071         * {@link ExpressionResultComparator}.
072         * 
073         * @param capacity   capacity of the resequencer's inbound queue.
074         * @param timeout    minimum time to wait for missing elements (messages).
075         * @param comparator comparator for sequence comparision
076         */
077        public StreamResequencerConfig(int capacity, long timeout, ExpressionResultComparator comparator) {
078            this.capacity = capacity;
079            this.timeout = timeout;
080            this.comparator = comparator;
081        }
082    
083        /**
084         * Returns a new {@link StreamResequencerConfig} instance using default
085         * values for <code>capacity</code> (1000) and <code>timeout</code>
086         * (1000L). Elements of the sequence are compared using the
087         * {@link DefaultExchangeComparator}.
088         * 
089         * @return a default {@link StreamResequencerConfig}.
090         */
091        public static StreamResequencerConfig getDefault() {
092            return new StreamResequencerConfig();
093        }
094        
095        public int getCapacity() {
096            return capacity;
097        }
098    
099        public void setCapacity(int capacity) {
100            this.capacity = capacity;
101        }
102    
103        public long getTimeout() {
104            return timeout;
105        }
106    
107        public void setTimeout(long timeout) {
108            this.timeout = timeout;
109        }
110    
111        public Boolean getIgnoreInvalidExchanges() {
112            return ignoreInvalidExchanges;
113        }
114    
115        public void setIgnoreInvalidExchanges(Boolean ignoreInvalidExchanges) {
116            this.ignoreInvalidExchanges = ignoreInvalidExchanges;
117        }
118    
119        public ExpressionResultComparator getComparator() {
120            return comparator;
121        }
122    
123        public void setComparator(ExpressionResultComparator comparator) {
124            this.comparator = comparator;
125        }
126        
127    }