Coverage Report - org.apache.camel.component.processor.ProcessorEndpoint
 
Classes in this File Line Coverage Branch Coverage Complexity
ProcessorEndpoint
0% 
N/A 
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.component.processor;
 19  
 
 20  
 import org.apache.camel.Endpoint;
 21  
 import org.apache.camel.Processor;
 22  
 import org.apache.camel.Exchange;
 23  
 import org.apache.camel.Consumer;
 24  
 import org.apache.camel.Producer;
 25  
 import org.apache.camel.Component;
 26  
 import org.apache.camel.impl.DefaultEndpoint;
 27  
 import org.apache.camel.impl.DefaultExchange;
 28  
 import org.apache.camel.impl.DefaultProducer;
 29  
 import org.apache.camel.processor.loadbalancer.LoadBalancer;
 30  
 
 31  
 /**
 32  
  * A base class for creating {@link Endpoint} implementations from a {@link Processor}
 33  
  *
 34  
  * @version $Revision: 1.1 $
 35  
  */
 36  
 public class ProcessorEndpoint extends DefaultEndpoint<Exchange> {
 37  
     private final Processor processor;
 38  
     private final LoadBalancer loadBalancer;
 39  
 
 40  
     protected ProcessorEndpoint(String endpointUri, Component component, Processor processor, LoadBalancer loadBalancer) {
 41  0
         super(endpointUri, component);
 42  0
         this.processor = processor;
 43  0
         this.loadBalancer = loadBalancer;
 44  0
     }
 45  
 
 46  
     public Exchange createExchange() {
 47  0
         return new DefaultExchange(getContext());
 48  
     }
 49  
 
 50  
     public Producer<Exchange> createProducer() throws Exception {
 51  0
         return new DefaultProducer<Exchange>(this) {
 52  0
             public void process(Exchange exchange) throws Exception {
 53  0
                 onExchange(exchange);
 54  0
             }
 55  
         };
 56  
     }
 57  
 
 58  
     public Consumer<Exchange> createConsumer(Processor processor) throws Exception {
 59  0
         return new ProcessorEndpointConsumer(this, processor);
 60  
     }
 61  
 
 62  
     public Processor getProcessor() {
 63  0
         return processor;
 64  
     }
 65  
 
 66  
     public LoadBalancer getLoadBalancer() {
 67  0
         return loadBalancer;
 68  
     }
 69  
 
 70  
     protected void onExchange(Exchange exchange) throws Exception {
 71  0
         processor.process(exchange);
 72  
 
 73  
         // now lets output to the load balancer
 74  0
         loadBalancer.process(exchange);
 75  0
     }
 76  
 
 77  
         public boolean isSingleton() {
 78  0
                 return true;
 79  
         }
 80  
 }