Coverage Report - org.apache.camel.component.timer.TimerEndpoint
 
Classes in this File Line Coverage Branch Coverage Complexity
TimerEndpoint
84% 
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.component.timer;
 18  
 
 19  
 import java.net.URI;
 20  
 import java.net.URISyntaxException;
 21  
 import java.util.Date;
 22  
 import java.util.Map;
 23  
 
 24  
 import org.apache.camel.Consumer;
 25  
 import org.apache.camel.Processor;
 26  
 import org.apache.camel.Producer;
 27  
 import org.apache.camel.RuntimeCamelException;
 28  
 import org.apache.camel.component.bean.BeanExchange;
 29  
 import org.apache.camel.impl.DefaultEndpoint;
 30  
 import org.apache.camel.util.IntrospectionSupport;
 31  
 import org.apache.camel.util.URISupport;
 32  
 
 33  
 /**
 34  
  * Represents a timer endpoint that can generate periodic inbound PojoExchanges.
 35  
  *
 36  
  * @version $Revision: 519973 $
 37  
  */
 38  15
 public class TimerEndpoint extends DefaultEndpoint<BeanExchange> {
 39  
 
 40  
     private final TimerComponent component;
 41  
     private final String timerName;
 42  
     private Date time;
 43  3
     private long period = -1;
 44  3
     private long delay = -1;
 45  
     private boolean fixedRate;
 46  3
     private boolean daemon = true;
 47  
 
 48  
 
 49  
     public TimerEndpoint(String fullURI, TimerComponent component, String timerPartURI) throws URISyntaxException {
 50  3
         super(fullURI, component);
 51  3
         this.component = component;
 52  
 
 53  
         // Use a URI to extract query so they can be set as properties on the endpoint.
 54  3
         URI u = new URI(timerPartURI);
 55  3
         Map options = URISupport.parseParamters(u);
 56  3
         IntrospectionSupport.setProperties(this, options);
 57  3
         this.timerName = u.getPath();
 58  
 
 59  3
     }
 60  
 
 61  
     public Producer<BeanExchange> createProducer() throws Exception {
 62  0
         throw new RuntimeCamelException("Cannot produce to a TimerEndpoint: " + getEndpointUri());
 63  
     }
 64  
 
 65  
     public Consumer<BeanExchange> createConsumer(Processor processor) throws Exception {
 66  3
         return new TimerConsumer(this, processor);
 67  
     }
 68  
 
 69  
     public BeanExchange createExchange() {
 70  15
         return new BeanExchange(getContext());
 71  
     }
 72  
 
 73  
     public TimerComponent getComponent() {
 74  6
         return component;
 75  
     }
 76  
 
 77  
     public String getTimerName() {
 78  3
         return timerName;
 79  
     }
 80  
 
 81  
     public boolean isDaemon() {
 82  3
         return daemon;
 83  
     }
 84  
 
 85  
     public void setDaemon(boolean daemon) {
 86  0
         this.daemon = daemon;
 87  0
     }
 88  
 
 89  
     public long getDelay() {
 90  3
         return delay;
 91  
     }
 92  
 
 93  
     public void setDelay(long delay) {
 94  3
         this.delay = delay;
 95  3
     }
 96  
 
 97  
     public boolean isFixedRate() {
 98  3
         return fixedRate;
 99  
     }
 100  
 
 101  
     public void setFixedRate(boolean fixedRate) {
 102  3
         this.fixedRate = fixedRate;
 103  3
     }
 104  
 
 105  
     public long getPeriod() {
 106  3
         return period;
 107  
     }
 108  
 
 109  
     public void setPeriod(long period) {
 110  3
         this.period = period;
 111  3
     }
 112  
 
 113  
     public Date getTime() {
 114  3
         return time;
 115  
     }
 116  
 
 117  
     public void setTime(Date time) {
 118  0
         this.time = time;
 119  0
     }
 120  
 
 121  
     public boolean isSingleton() {
 122  3
         return true;
 123  
     }
 124  
 
 125  
 }