Coverage Report - org.apache.camel.component.jbi.JbiEndpoint
 
Classes in this File Line Coverage Branch Coverage Complexity
JbiEndpoint
100% 
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.jbi;
 19  
 
 20  
 import org.apache.camel.Consumer;
 21  
 import org.apache.camel.Endpoint;
 22  
 import org.apache.camel.Exchange;
 23  
 import org.apache.camel.Processor;
 24  
 import org.apache.camel.Producer;
 25  
 import org.apache.camel.impl.DefaultConsumer;
 26  
 import org.apache.camel.impl.DefaultEndpoint;
 27  
 import org.apache.camel.impl.DefaultProducer;
 28  
 
 29  
 /**
 30  
  * Represents an {@link Endpoint} for interacting with JBI
 31  
  *
 32  
  * @version $Revision: 537816 $
 33  
  */
 34  6
 public class JbiEndpoint extends DefaultEndpoint<Exchange> {
 35  
     private Processor toJbiProcessor;
 36  
     private final CamelJbiComponent jbiComponent;
 37  
 
 38  
     public JbiEndpoint(CamelJbiComponent jbiComponent, String uri) {
 39  3
         super(uri, jbiComponent);
 40  3
         this.jbiComponent = jbiComponent;
 41  3
         toJbiProcessor = new ToJbiProcessor(jbiComponent.getBinding(), jbiComponent.getComponentContext(), uri);
 42  3
     }
 43  
 
 44  
     public Producer<Exchange> createProducer() throws Exception {
 45  3
         return new DefaultProducer<Exchange>(this) {
 46  3
                     public void process(Exchange exchange) throws Exception {
 47  3
                         toJbiProcessor.process(exchange);
 48  3
                     }
 49  
                 };
 50  
     }
 51  
 
 52  
     public Consumer<Exchange> createConsumer(final Processor processor) throws Exception {
 53  1
         return new DefaultConsumer<Exchange>(this, processor) {
 54  
             CamelJbiEndpoint jbiEndpoint;
 55  
 
 56  
             @Override
 57  
             protected void doStart() throws Exception {
 58  1
                 super.doStart();
 59  1
                 jbiEndpoint = jbiComponent.activateJbiEndpoint(JbiEndpoint.this, processor);
 60  1
             }
 61  
 
 62  
             @Override
 63  1
             protected void doStop() throws Exception {
 64  
 /*
 65  
                 if (jbiEndpoint != null) {
 66  
                     jbiEndpoint.deactivate();
 67  
                 }
 68  
 */
 69  1
                 super.doStop();
 70  1
             }
 71  
         };
 72  
     }
 73  
 
 74  
 
 75  
     public JbiExchange createExchange() {
 76  2
         return new JbiExchange(getContext(), getBinding());
 77  
     }
 78  
 
 79  
     public JbiBinding getBinding() {
 80  2
         return jbiComponent.getBinding();
 81  
     }
 82  
     
 83  
         public boolean isSingleton() {
 84  3
                 return true;
 85  
         }
 86  
 
 87  
 }