Coverage Report - org.apache.camel.impl.DefaultConsumer
 
Classes in this File Line Coverage Branch Coverage Complexity
DefaultConsumer
56% 
0% 
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.impl;
 18  
 
 19  
 import org.apache.camel.Consumer;
 20  
 import org.apache.camel.Endpoint;
 21  
 import org.apache.camel.Exchange;
 22  
 import org.apache.camel.Processor;
 23  
 import org.apache.camel.spi.ExceptionHandler;
 24  
 import org.apache.camel.util.ServiceHelper;
 25  
 
 26  
 /**
 27  
  * @version $Revision: 563607 $
 28  
  */
 29  
 public class DefaultConsumer<E extends Exchange> extends ServiceSupport implements Consumer<E> {
 30  
     private Endpoint<E> endpoint;
 31  
     private Processor processor;
 32  
     private ExceptionHandler exceptionHandler;
 33  
 
 34  201
     public DefaultConsumer(Endpoint<E> endpoint, Processor processor) {
 35  201
         this.endpoint = endpoint;
 36  201
         this.processor = processor;
 37  201
     }
 38  
 
 39  
     @Override
 40  
     public String toString() {
 41  0
         return "Consumer on " + endpoint;
 42  
     }
 43  
 
 44  
     public Endpoint<E> getEndpoint() {
 45  15
         return endpoint;
 46  
     }
 47  
 
 48  
     public Processor getProcessor() {
 49  621
         return processor;
 50  
     }
 51  
 
 52  
     public ExceptionHandler getExceptionHandler() {
 53  0
         if (exceptionHandler == null) {
 54  0
             exceptionHandler = new LoggingExceptionHandler(getClass());
 55  
         }
 56  0
         return exceptionHandler;
 57  
     }
 58  
 
 59  
     public void setExceptionHandler(ExceptionHandler exceptionHandler) {
 60  0
         this.exceptionHandler = exceptionHandler;
 61  0
     }
 62  
 
 63  
     protected void doStop() throws Exception {
 64  195
         ServiceHelper.stopServices(processor);
 65  195
     }
 66  
 
 67  
     protected void doStart() throws Exception {
 68  198
         ServiceHelper.startServices(processor);
 69  198
     }
 70  
 
 71  
     /**
 72  
      * Handles the given exception using the {@link #getExceptionHandler()}
 73  
      * 
 74  
      * @param t the exception to handle
 75  
      */
 76  
     protected void handleException(Throwable t) {
 77  0
         getExceptionHandler().handleException(t);
 78  0
     }
 79  
 }