Coverage Report - org.apache.camel.builder.ResequencerBuilder
 
Classes in this File Line Coverage Branch Coverage Complexity
ResequencerBuilder
55% 
N/A 
0
 
 1  
 /**
 2  
  *
 3  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 4  
  * contributor license agreements.  See the NOTICE file distributed with
 5  
  * this work for additional information regarding copyright ownership.
 6  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 7  
  * (the "License"); you may not use this file except in compliance with
 8  
  * the License.  You may obtain a copy of the License at
 9  
  *
 10  
  * http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15  
  * See the License for the specific language governing permissions and
 16  
  * limitations under the License.
 17  
  */
 18  
 package org.apache.camel.builder;
 19  
 
 20  
 import org.apache.camel.Expression;
 21  
 import org.apache.camel.Processor;
 22  
 import org.apache.camel.Route;
 23  
 import org.apache.camel.Exchange;
 24  
 import org.apache.camel.Service;
 25  
 import org.apache.camel.processor.Resequencer;
 26  
 
 27  
 import java.util.List;
 28  
 
 29  
 /**
 30  
  * @version $Revision: 1.1 $
 31  
  */
 32  
 public class ResequencerBuilder extends FromBuilder {
 33  
     private final List<Expression<Exchange>> expressions;
 34  1
     private long batchTimeout = 1000L;
 35  1
     private int batchSize = 100;
 36  
 
 37  
     public ResequencerBuilder(FromBuilder builder, List<Expression<Exchange>> expressions) {
 38  1
         super(builder);
 39  1
         this.expressions = expressions;
 40  1
     }
 41  
 
 42  
     @Override
 43  
     public Route createRoute() throws Exception {
 44  1
         final Processor processor = super.createProcessor();
 45  1
         final Resequencer resequencer = new Resequencer(getFrom(), processor, expressions);
 46  
 
 47  1
         return new Route<Exchange>(getFrom()) {
 48  
             protected void addServices(List<Service> list) throws Exception {
 49  1
                 list.add(resequencer);
 50  1
             }
 51  
 
 52  
             @Override
 53  1
             public String toString() {
 54  1
                 return "ResequencerRoute[" + getEndpoint() + " -> " + processor + "]";
 55  
             }
 56  
         };
 57  
     }
 58  
 
 59  
     // Builder methods
 60  
     //-------------------------------------------------------------------------
 61  
     public ResequencerBuilder batchSize(int batchSize) {
 62  0
         setBatchSize(batchSize);
 63  0
         return this;
 64  
     }
 65  
 
 66  
     public ResequencerBuilder batchTimeout(int batchTimeout) {
 67  0
         setBatchTimeout(batchTimeout);
 68  0
         return this;
 69  
     }
 70  
 
 71  
     // Properties
 72  
     //-------------------------------------------------------------------------
 73  
     public int getBatchSize() {
 74  0
         return batchSize;
 75  
     }
 76  
 
 77  
     public void setBatchSize(int batchSize) {
 78  0
         this.batchSize = batchSize;
 79  0
     }
 80  
 
 81  
     public long getBatchTimeout() {
 82  0
         return batchTimeout;
 83  
     }
 84  
 
 85  
     public void setBatchTimeout(long batchTimeout) {
 86  0
         this.batchTimeout = batchTimeout;
 87  0
     }
 88  
 }