Coverage Report - org.apache.camel.component.jbi.JbiEndpoint
 
Classes in this File Line Coverage Branch Coverage Complexity
JbiEndpoint
0% 
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.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: 551851 $
 33  
  */
 34  0
 public class JbiEndpoint extends DefaultEndpoint<Exchange> {
 35  
     private Processor toJbiProcessor;
 36  
     private final CamelJbiComponent jbiComponent;
 37  
 
 38  
     public JbiEndpoint(CamelJbiComponent jbiComponent, String uri) {
 39  0
         super(uri, jbiComponent);
 40  0
         this.jbiComponent = jbiComponent;
 41  0
         toJbiProcessor = new ToJbiProcessor(jbiComponent.getBinding(), jbiComponent.getComponentContext(), uri);
 42  0
     }
 43  
 
 44  
     public Producer<Exchange> createProducer() throws Exception {
 45  0
         return new DefaultProducer<Exchange>(this) {
 46  0
             public void process(Exchange exchange) throws Exception {
 47  0
                 toJbiProcessor.process(exchange);
 48  0
             }
 49  
         };
 50  
     }
 51  
 
 52  
     public Consumer<Exchange> createConsumer(final Processor processor) throws Exception {
 53  0
         return new DefaultConsumer<Exchange>(this, processor) {
 54  
             CamelJbiEndpoint jbiEndpoint;
 55  
 
 56  
             @Override
 57  
             protected void doStart() throws Exception {
 58  0
                 super.doStart();
 59  0
                 jbiEndpoint = jbiComponent.activateJbiEndpoint(JbiEndpoint.this, processor);
 60  0
             }
 61  
 
 62  
             @Override
 63  0
             protected void doStop() throws Exception {
 64  0
                 if (jbiEndpoint != null) {
 65  0
                     jbiComponent.deactivateJbiEndpoint(jbiEndpoint);
 66  
                 }
 67  0
                 super.doStop();
 68  0
             }
 69  
         };
 70  
     }
 71  
 
 72  
 
 73  
     public JbiExchange createExchange() {
 74  0
         return new JbiExchange(getContext(), getBinding());
 75  
     }
 76  
 
 77  
     public JbiBinding getBinding() {
 78  0
         return jbiComponent.getBinding();
 79  
     }
 80  
 
 81  
     public boolean isSingleton() {
 82  0
         return true;
 83  
     }
 84  
 }