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 @XmlRootElement 029 @XmlAccessorType(XmlAccessType.FIELD) 030 public class BatchResequencerConfig extends ResequencerConfig { 031 @XmlAttribute 032 private Integer batchSize; 033 @XmlAttribute 034 private Long batchTimeout; 035 @XmlAttribute 036 private Boolean allowDuplicates; 037 @XmlAttribute 038 private Boolean reverse; 039 @XmlAttribute 040 private Boolean ignoreInvalidExchanges; 041 042 /** 043 * Creates a new {@link BatchResequencerConfig} instance using default 044 * values for <code>batchSize</code> (100) and <code>batchTimeout</code> 045 * (1000L). 046 */ 047 public BatchResequencerConfig() { 048 this(100, 1000L); 049 } 050 051 /** 052 * Creates a new {@link BatchResequencerConfig} instance using the given 053 * values for <code>batchSize</code> and <code>batchTimeout</code>. 054 * 055 * @param batchSize size of the batch to be re-ordered. 056 * @param batchTimeout timeout for collecting elements to be re-ordered. 057 */ 058 public BatchResequencerConfig(int batchSize, long batchTimeout) { 059 this.batchSize = batchSize; 060 this.batchTimeout = batchTimeout; 061 } 062 063 /** 064 * Returns a new {@link BatchResequencerConfig} instance using default 065 * values for <code>batchSize</code> (100) and <code>batchTimeout</code> 066 * (1000L). 067 * 068 * @return a default {@link BatchResequencerConfig}. 069 */ 070 public static BatchResequencerConfig getDefault() { 071 return new BatchResequencerConfig(); 072 } 073 074 public int getBatchSize() { 075 return batchSize; 076 } 077 078 public void setBatchSize(int batchSize) { 079 this.batchSize = batchSize; 080 } 081 082 public long getBatchTimeout() { 083 return batchTimeout; 084 } 085 086 public void setBatchTimeout(long batchTimeout) { 087 this.batchTimeout = batchTimeout; 088 } 089 090 public boolean isAllowDuplicates() { 091 return allowDuplicates != null && allowDuplicates; 092 } 093 094 public Boolean getAllowDuplicates() { 095 return allowDuplicates; 096 } 097 098 public void setAllowDuplicates(Boolean allowDuplicates) { 099 this.allowDuplicates = allowDuplicates; 100 } 101 102 public boolean isReverse() { 103 return reverse != null && reverse; 104 } 105 106 public Boolean getReverse() { 107 return reverse; 108 } 109 110 public void setReverse(Boolean reverse) { 111 this.reverse = reverse; 112 } 113 114 public Boolean getIgnoreInvalidExchanges() { 115 return ignoreInvalidExchanges; 116 } 117 118 public void setIgnoreInvalidExchanges(Boolean ignoreInvalidExchanges) { 119 this.ignoreInvalidExchanges = ignoreInvalidExchanges; 120 } 121 }