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