Coverage Report - org.apache.camel.component.seda.SedaEndpoint
 
Classes in this File Line Coverage Branch Coverage Complexity
SedaEndpoint
100% 
N/A 
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.component.seda;
 18  
 
 19  
 import java.util.concurrent.BlockingQueue;
 20  
 
 21  
 import org.apache.camel.Component;
 22  
 import org.apache.camel.Consumer;
 23  
 import org.apache.camel.Exchange;
 24  
 import org.apache.camel.Processor;
 25  
 import org.apache.camel.Producer;
 26  
 import org.apache.camel.impl.DefaultEndpoint;
 27  
 import org.apache.camel.impl.DefaultExchange;
 28  
 import org.apache.camel.impl.DefaultProducer;
 29  
 
 30  
 /**
 31  
  * An implementation of the <a
 32  
  * href="http://activemq.apache.org/camel/queue.html">Queue components</a> for
 33  
  * asynchronous SEDA exchanges on a {@link BlockingQueue} within a CamelContext
 34  
  * 
 35  
  * @org.apache.xbean.XBean
 36  
  * @version $Revision: 519973 $
 37  
  */
 38  39
 public class SedaEndpoint<E extends Exchange> extends DefaultEndpoint<E> {
 39  
     private BlockingQueue<E> queue;
 40  
 
 41  
     public SedaEndpoint(String endpointUri, Component component, BlockingQueue<E> queue) {
 42  99
         super(endpointUri, component);
 43  99
         this.queue = queue;
 44  99
     }
 45  
 
 46  
     public SedaEndpoint(String uri, SedaComponent<E> component) {
 47  90
         this(uri, component, component.createQueue());
 48  90
     }
 49  
 
 50  
     public Producer<E> createProducer() throws Exception {
 51  24
         return new DefaultProducer(this) {
 52  24
             public void process(Exchange exchange) {
 53  39
                 queue.add(toExchangeType(exchange));
 54  39
             }
 55  
         };
 56  
     }
 57  
 
 58  
     public Consumer<E> createConsumer(Processor processor) throws Exception {
 59  24
         return new SedaConsumer<E>(this, processor);
 60  
     }
 61  
 
 62  
     public E createExchange() {
 63  
         // How can we create a specific Exchange if we are generic??
 64  
         // perhaps it would be better if we did not implement this.
 65  69
         return (E)new DefaultExchange(getContext());
 66  
     }
 67  
 
 68  
     public BlockingQueue<E> getQueue() {
 69  54
         return queue;
 70  
     }
 71  
 
 72  
     public boolean isSingleton() {
 73  99
         return true;
 74  
     }
 75  
 
 76  
 }