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 * @author Martin Krasser 053 * 054 * @version $Revision: 751655 $ 055 */ 056 @XmlRootElement 057 @XmlAccessorType(XmlAccessType.FIELD) 058 public class BatchResequencerConfig { 059 060 @XmlAttribute 061 private Integer batchSize; // optional XML attribute requires wrapper object 062 063 @XmlAttribute 064 private Long batchTimeout; // optional XML attribute requires wrapper object 065 066 /** 067 * Creates a new {@link BatchResequencerConfig} instance using default 068 * values for <code>batchSize</code> (100) and <code>batchTimeout</code> 069 * (1000L). 070 */ 071 public BatchResequencerConfig() { 072 this(100, 1000L); 073 } 074 075 /** 076 * Creates a new {@link BatchResequencerConfig} instance using the given 077 * values for <code>batchSize</code> and <code>batchTimeout</code>. 078 * 079 * @param batchSize 080 * size of the batch to be re-ordered. 081 * @param batchTimeout 082 * timeout for collecting elements to be re-ordered. 083 */ 084 public BatchResequencerConfig(int batchSize, long batchTimeout) { 085 this.batchSize = batchSize; 086 this.batchTimeout = batchTimeout; 087 } 088 089 /** 090 * Returns a new {@link BatchResequencerConfig} instance using default 091 * values for <code>batchSize</code> (100) and <code>batchTimeout</code> 092 * (1000L). 093 * 094 * @return a default {@link BatchResequencerConfig}. 095 */ 096 public static BatchResequencerConfig getDefault() { 097 return new BatchResequencerConfig(); 098 } 099 100 public int getBatchSize() { 101 return batchSize; 102 } 103 104 public void setBatchSize(int batchSize) { 105 this.batchSize = batchSize; 106 } 107 108 public long getBatchTimeout() { 109 return batchTimeout; 110 } 111 112 public void setBatchTimeout(long batchTimeout) { 113 this.batchTimeout = batchTimeout; 114 } 115 116 }