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
024 /**
025 * Defines the configuration parameters for the batch-processing
026 * {@link org.apache.camel.processor.Resequencer}. Usage example:
027 *
028 * <pre>
029 * from("direct:start").resequence(body()).batch(
030 * BatchResequencerConfig.getDefault()).to("mock:result")
031 * </pre>
032 * is equivalent to
033 *
034 * <pre>
035 * from("direct:start").resequence(body()).batch().to("mock:result")
036 * </pre>
037 *
038 * or
039 *
040 * <pre>
041 * from("direct:start").resequence(body()).to("mock:result")
042 * </pre>
043 *
044 * Custom values for <code>batchSize</code> and <code>batchTimeout</code>
045 * can be set like in this example:
046 *
047 * <pre>
048 * from("direct:start").resequence(body()).batch(
049 * new BatchResequencerConfig(300, 400L)).to("mock:result")
050 * </pre>
051 *
052 * @version $Revision: 792319 $
053 */
054 @XmlRootElement
055 @XmlAccessorType(XmlAccessType.FIELD)
056 public class BatchResequencerConfig {
057
058 @XmlAttribute
059 private Integer batchSize; // optional XML attribute requires wrapper object
060
061 @XmlAttribute
062 private Long batchTimeout; // optional XML attribute requires wrapper object
063
064 /**
065 * Creates a new {@link BatchResequencerConfig} instance using default
066 * values for <code>batchSize</code> (100) and <code>batchTimeout</code>
067 * (1000L).
068 */
069 public BatchResequencerConfig() {
070 this(100, 1000L);
071 }
072
073 /**
074 * Creates a new {@link BatchResequencerConfig} instance using the given
075 * values for <code>batchSize</code> and <code>batchTimeout</code>.
076 *
077 * @param batchSize
078 * size of the batch to be re-ordered.
079 * @param batchTimeout
080 * timeout for collecting elements to be re-ordered.
081 */
082 public BatchResequencerConfig(int batchSize, long batchTimeout) {
083 this.batchSize = batchSize;
084 this.batchTimeout = batchTimeout;
085 }
086
087 /**
088 * Returns a new {@link BatchResequencerConfig} instance using default
089 * values for <code>batchSize</code> (100) and <code>batchTimeout</code>
090 * (1000L).
091 *
092 * @return a default {@link BatchResequencerConfig}.
093 */
094 public static BatchResequencerConfig getDefault() {
095 return new BatchResequencerConfig();
096 }
097
098 public int getBatchSize() {
099 return batchSize;
100 }
101
102 public void setBatchSize(int batchSize) {
103 this.batchSize = batchSize;
104 }
105
106 public long getBatchTimeout() {
107 return batchTimeout;
108 }
109
110 public void setBatchTimeout(long batchTimeout) {
111 this.batchTimeout = batchTimeout;
112 }
113
114 }