Coverage Report - org.apache.camel.impl.PollingConsumerRoute
 
Classes in this File Line Coverage Branch Coverage Complexity
PollingConsumerRoute
0% 
0% 
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.impl;
 19  
 
 20  
 import org.apache.camel.Route;
 21  
 import org.apache.camel.Endpoint;
 22  
 import org.apache.camel.Processor;
 23  
 import org.apache.camel.Service;
 24  
 import org.apache.camel.Consumer;
 25  
 import org.apache.camel.Exchange;
 26  
 import org.apache.camel.PollingConsumer;
 27  
 
 28  
 import java.util.List;
 29  
 
 30  
 /**
 31  
  * A {@link Route} which starts with a
 32  
  * <a href="http://activemq.apache.org/camel/polling-consumer.html">Polling Consumer</a>
 33  
  *
 34  
  * @version $Revision: 1.1 $
 35  
  */
 36  
 public class PollingConsumerRoute<E extends Exchange> extends Route<E> {
 37  
     private Processor processor;
 38  
 
 39  
     public PollingConsumerRoute(Endpoint endpoint, Processor processor) {
 40  0
         super(endpoint);
 41  0
         this.processor = processor;
 42  0
     }
 43  
 
 44  
     @Override
 45  
     public String toString() {
 46  0
         return "PollingConsumerRoute[" + getEndpoint() + " -> " + processor + "]";
 47  
     }
 48  
 
 49  
     public Processor getProcessor() {
 50  0
         return processor;
 51  
     }
 52  
 
 53  
     public void setProcessor(Processor processor) {
 54  0
         this.processor = processor;
 55  0
     }
 56  
 
 57  
     /**
 58  
      * Factory method to lazily create the complete list of services required for this route
 59  
      * such as adding the processor or consumer
 60  
      */
 61  
     protected void addServices(List<Service> services) throws Exception {
 62  0
         Processor processor = getProcessor();
 63  0
         if (processor instanceof Service) {
 64  0
             Service service = (Service) processor;
 65  0
             services.add(service);
 66  
         }
 67  0
         Endpoint<E> endpoint = getEndpoint();
 68  0
         PollingConsumer<E> consumer = endpoint.createPollingConsumer();
 69  0
         if (consumer != null) {
 70  0
             services.add(consumer);
 71  
         }
 72  0
     }
 73  
 }