Coverage Report - org.apache.camel.model.ThrottlerType
 
Classes in this File Line Coverage Branch Coverage Complexity
ThrottlerType
48% 
N/A 
0
 
 1  
 /**
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  *
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.apache.camel.model;
 18  
 
 19  
 import java.util.ArrayList;
 20  
 import java.util.List;
 21  
 
 22  
 import javax.xml.bind.annotation.XmlAccessType;
 23  
 import javax.xml.bind.annotation.XmlAccessorType;
 24  
 import javax.xml.bind.annotation.XmlAttribute;
 25  
 import javax.xml.bind.annotation.XmlElement;
 26  
 import javax.xml.bind.annotation.XmlElementRef;
 27  
 import javax.xml.bind.annotation.XmlRootElement;
 28  
 
 29  
 import org.apache.camel.Processor;
 30  
 import org.apache.camel.impl.RouteContext;
 31  
 import org.apache.camel.processor.Throttler;
 32  
 
 33  
 /**
 34  
  * @version $Revision: 1.1 $
 35  
  */
 36  
 @XmlRootElement(name = "throttler")
 37  
 @XmlAccessorType(XmlAccessType.FIELD)
 38  
 public class ThrottlerType extends ProcessorType {
 39  
     @XmlAttribute
 40  
     private Long maximumRequestsPerPeriod;
 41  
     @XmlAttribute
 42  3
     private long timePeriodMillis = 1000;
 43  
     @XmlElementRef
 44  3
     private List<InterceptorType> interceptors = new ArrayList<InterceptorType>();
 45  
     @XmlElementRef
 46  3
     private List<ProcessorType> outputs = new ArrayList<ProcessorType>();
 47  
 
 48  0
     public ThrottlerType() {
 49  0
     }
 50  
 
 51  3
     public ThrottlerType(long maximumRequestsPerPeriod) {
 52  3
         this.maximumRequestsPerPeriod = maximumRequestsPerPeriod;
 53  3
     }
 54  
 
 55  
     @Override
 56  
     public String toString() {
 57  0
         return "Throttler[" + getMaximumRequestsPerPeriod() + " request per " + getTimePeriodMillis()
 58  
                + " millis -> " + getOutputs() + "]";
 59  
     }
 60  
 
 61  
     @Override
 62  
     public Processor createProcessor(RouteContext routeContext) throws Exception {
 63  3
         Processor childProcessor = routeContext.createProcessor(this);
 64  3
         return new Throttler(childProcessor, maximumRequestsPerPeriod, timePeriodMillis);
 65  
     }
 66  
 
 67  
     // Fluent API
 68  
     // -------------------------------------------------------------------------
 69  
 
 70  
     /**
 71  
      * Sets the time period during which the maximum request count is valid for
 72  
      */
 73  
     public ThrottlerType timePeriodMillis(long timePeriodMillis) {
 74  3
         this.timePeriodMillis = timePeriodMillis;
 75  3
         return this;
 76  
     }
 77  
 
 78  
     // Properties
 79  
     // -------------------------------------------------------------------------
 80  
 
 81  
     public Long getMaximumRequestsPerPeriod() {
 82  0
         return maximumRequestsPerPeriod;
 83  
     }
 84  
 
 85  
     public void setMaximumRequestsPerPeriod(Long maximumRequestsPerPeriod) {
 86  0
         this.maximumRequestsPerPeriod = maximumRequestsPerPeriod;
 87  0
     }
 88  
 
 89  
     public long getTimePeriodMillis() {
 90  0
         return timePeriodMillis;
 91  
     }
 92  
 
 93  
     public void setTimePeriodMillis(long timePeriodMillis) {
 94  0
         this.timePeriodMillis = timePeriodMillis;
 95  0
     }
 96  
 
 97  
     public List<InterceptorType> getInterceptors() {
 98  6
         return interceptors;
 99  
     }
 100  
 
 101  
     public void setInterceptors(List<InterceptorType> interceptors) {
 102  0
         this.interceptors = interceptors;
 103  0
     }
 104  
 
 105  
     public List<ProcessorType> getOutputs() {
 106  6
         return outputs;
 107  
     }
 108  
 
 109  
     public void setOutputs(List<ProcessorType> outputs) {
 110  0
         this.outputs = outputs;
 111  0
     }
 112  
 }