Coverage Report - org.apache.camel.processor.SendProcessor
 
Classes in this File Line Coverage Branch Coverage Complexity
SendProcessor
100% 
100% 
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.processor;
 19  
 
 20  
 import org.apache.camel.Endpoint;
 21  
 import org.apache.camel.Exchange;
 22  
 import org.apache.camel.Processor;
 23  
 import org.apache.camel.Producer;
 24  
 import org.apache.camel.Service;
 25  
 import org.apache.camel.impl.ServiceSupport;
 26  
 
 27  
 /**
 28  
  * @version $Revision: 534145 $
 29  
  */
 30  
 public class SendProcessor extends ServiceSupport implements Processor, Service {
 31  
     private Endpoint destination;
 32  
     private Producer producer;
 33  
 
 34  50
     public SendProcessor(Endpoint destination) {
 35  50
         this.destination = destination;
 36  50
     }
 37  
 
 38  
     protected void doStop() throws Exception {
 39  38
         if (producer != null) {
 40  
             try {
 41  38
                 producer.stop();
 42  
             }
 43  
             finally {
 44  38
                 producer = null;
 45  38
             }
 46  
         }
 47  38
     }
 48  
 
 49  
     protected void doStart() throws Exception {
 50  39
         this.producer = destination.createProducer();
 51  39
     }
 52  
 
 53  
     public void process(Exchange exchange) throws Exception {
 54  40
         if (producer == null) {
 55  1
             throw new IllegalStateException("No producer, this processor has not been started!");
 56  
         }
 57  39
         producer.process(exchange);
 58  39
     }
 59  
 
 60  
     public Endpoint getDestination() {
 61  7
         return destination;
 62  
     }
 63  
 
 64  
     @Override
 65  
     public String toString() {
 66  91
         return "sendTo(" + destination + ")";
 67  
     }
 68  
 }