Coverage Report - org.apache.camel.model.ToType
 
Classes in this File Line Coverage Branch Coverage Complexity
ToType
64% 
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.model;
 18  
 
 19  
 import java.util.ArrayList;
 20  
 import java.util.Collections;
 21  
 import java.util.List;
 22  
 
 23  
 import javax.xml.bind.annotation.XmlAccessType;
 24  
 import javax.xml.bind.annotation.XmlAccessorType;
 25  
 import javax.xml.bind.annotation.XmlAttribute;
 26  
 import javax.xml.bind.annotation.XmlElement;
 27  
 import javax.xml.bind.annotation.XmlRootElement;
 28  
 import javax.xml.bind.annotation.XmlTransient;
 29  
 import javax.xml.bind.annotation.XmlElementRef;
 30  
 
 31  
 import org.apache.camel.Endpoint;
 32  
 import org.apache.camel.Processor;
 33  
 import org.apache.camel.impl.RouteContext;
 34  
 import org.apache.camel.processor.SendProcessor;
 35  
 
 36  
 /**
 37  
  * Represents an XML <to/> element
 38  
  * 
 39  
  * @version $Revision: $
 40  
  */
 41  
 @XmlRootElement(name = "to")
 42  
 @XmlAccessorType(XmlAccessType.FIELD)
 43  
 public class ToType extends ProcessorType {
 44  
     @XmlAttribute
 45  
     private String uri;
 46  
     @XmlAttribute
 47  
     private String ref;
 48  
     @XmlElementRef
 49  345
     private List<InterceptorType> interceptors = new ArrayList<InterceptorType>();
 50  
     @XmlTransient
 51  
     private Endpoint endpoint;
 52  
 
 53  27
     public ToType() {
 54  27
     }
 55  
 
 56  318
     public ToType(String uri) {
 57  318
         setUri(uri);
 58  318
     }
 59  
 
 60  0
     public ToType(Endpoint endpoint) {
 61  0
         setEndpoint(endpoint);
 62  0
     }
 63  
 
 64  
     @Override
 65  
     public String toString() {
 66  195
         return "To[" + FromType.description(getUri(), getRef(), getEndpoint()) + "]";
 67  
     }
 68  
 
 69  
     @Override
 70  
     public Processor createProcessor(RouteContext routeContext) throws Exception {
 71  312
         Endpoint endpoint = resolveEndpoint(routeContext);
 72  309
         return new SendProcessor(endpoint);
 73  
     }
 74  
 
 75  
     public Endpoint resolveEndpoint(RouteContext context) {
 76  312
         if (endpoint == null) {
 77  312
             endpoint = context.resolveEndpoint(getUri(), getRef());
 78  
         }
 79  309
         return endpoint;
 80  
     }
 81  
 
 82  
     // Properties
 83  
     // -----------------------------------------------------------------------
 84  
     public String getUri() {
 85  534
         return uri;
 86  
     }
 87  
 
 88  
     /**
 89  
      * Sets the URI of the endpoint to use
 90  
      * 
 91  
      * @param uri the endpoint URI to use
 92  
      */
 93  
     public void setUri(String uri) {
 94  318
         this.uri = uri;
 95  318
     }
 96  
 
 97  
     public String getRef() {
 98  507
         return ref;
 99  
     }
 100  
 
 101  
     /**
 102  
      * Sets the name of the endpoint within the registry (such as the Spring
 103  
      * ApplicationContext or JNDI) to use
 104  
      * 
 105  
      * @param ref the reference name to use
 106  
      */
 107  
     public void setRef(String ref) {
 108  0
         this.ref = ref;
 109  0
     }
 110  
 
 111  
     public Endpoint getEndpoint() {
 112  195
         return endpoint;
 113  
     }
 114  
 
 115  
     public void setEndpoint(Endpoint endpoint) {
 116  0
         this.endpoint = endpoint;
 117  0
     }
 118  
 
 119  
     public List<ProcessorType> getOutputs() {
 120  0
         return Collections.EMPTY_LIST;
 121  
     }
 122  
 
 123  
     public List<InterceptorType> getInterceptors() {
 124  285
         return interceptors;
 125  
     }
 126  
 
 127  
     public void setInterceptors(List<InterceptorType> interceptors) {
 128  0
         this.interceptors = interceptors;
 129  0
     }
 130  
 }