Coverage Report - org.apache.camel.Route
 
Classes in this File Line Coverage Branch Coverage Complexity
Route
74% 
100% 
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;
 18  
 
 19  
 import java.util.ArrayList;
 20  
 import java.util.HashMap;
 21  
 import java.util.List;
 22  
 import java.util.Map;
 23  
 
 24  
 /**
 25  
  * A <a href="http://activemq.apache.org/camel/routes.html">Route</a>
 26  
  * defines the processing used on an inbound message exchange
 27  
  * from a specific {@see Endpoint} within a {@link CamelContext}
 28  
  *
 29  
  * @version $Revision: 563607 $
 30  
  */
 31  
 public class Route<E extends Exchange> {
 32  264
     private final Map<String, Object> properties = new HashMap<String, Object>(16);
 33  
     private Endpoint<E> endpoint;
 34  264
     private List<Service> services = new ArrayList<Service>();
 35  
 
 36  264
     public Route(Endpoint<E> endpoint) {
 37  264
         this.endpoint = endpoint;
 38  264
     }
 39  
 
 40  
     public Route(Endpoint<E> endpoint, Service... services) {
 41  6
         this(endpoint);
 42  12
         for (Service service : services) {
 43  6
             addService(service);
 44  
         }
 45  6
     }
 46  
 
 47  
     @Override
 48  
     public String toString() {
 49  0
         return "Route";
 50  
     }
 51  
 
 52  
     public Endpoint<E> getEndpoint() {
 53  519
         return endpoint;
 54  
     }
 55  
 
 56  
     public void setEndpoint(Endpoint<E> endpoint) {
 57  0
         this.endpoint = endpoint;
 58  0
     }
 59  
 
 60  
     /**
 61  
      * This property map is used to associate information about
 62  
      * the route.
 63  
      *
 64  
      * @return
 65  
      */
 66  
     public Map<String, Object> getProperties() {
 67  0
         return properties;
 68  
     }
 69  
 
 70  
     public List<Service> getServicesForRoute() throws Exception {
 71  225
         List<Service> servicesForRoute = new ArrayList<Service>(getServices());
 72  225
         addServices(servicesForRoute);
 73  225
         return servicesForRoute;
 74  
     }
 75  
 
 76  
     /**
 77  
      * Returns the additional services required for this particular route
 78  
      */
 79  
     public List<Service> getServices() {
 80  231
         return services;
 81  
     }
 82  
 
 83  
     public void setServices(List<Service> services) {
 84  0
         this.services = services;
 85  0
     }
 86  
 
 87  
     public void addService(Service service) {
 88  6
         getServices().add(service);
 89  6
     }
 90  
 
 91  
     /**
 92  
      * Strategy method to allow derived classes to lazily load services for the route
 93  
      */
 94  
     protected void addServices(List<Service> services) throws Exception {
 95  6
     }
 96  
 }