Coverage Report - org.apache.camel.component.jms.JmsConsumer
 
Classes in this File Line Coverage Branch Coverage Complexity
JmsConsumer
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.jms;
 18  
 
 19  
 import javax.jms.MessageListener;
 20  
 
 21  
 import org.apache.camel.Processor;
 22  
 import org.apache.camel.impl.DefaultConsumer;
 23  
 
 24  
 import org.springframework.jms.listener.AbstractMessageListenerContainer;
 25  
 
 26  
 /**
 27  
  * A {@link Consumer} which uses Spring's {@link AbstractMessageListenerContainer} implementations to consume JMS messages
 28  
  *
 29  
  * @version $Revision: 563665 $
 30  
  */
 31  
 public class JmsConsumer extends DefaultConsumer<JmsExchange> {
 32  
     private final AbstractMessageListenerContainer listenerContainer;
 33  
 
 34  
     public JmsConsumer(JmsEndpoint endpoint, Processor processor, AbstractMessageListenerContainer listenerContainer) {
 35  81
         super(endpoint, processor);
 36  81
         this.listenerContainer = listenerContainer;
 37  
 
 38  81
         MessageListener messageListener = createMessageListener(endpoint, processor);
 39  81
         this.listenerContainer.setMessageListener(messageListener);
 40  81
     }
 41  
 
 42  
     public AbstractMessageListenerContainer getListenerContainer() {
 43  2
         return listenerContainer;
 44  
     }
 45  
 
 46  
     protected MessageListener createMessageListener(JmsEndpoint endpoint, Processor processor) {
 47  81
         EndpointMessageListener<JmsExchange> messageListener = new EndpointMessageListener<JmsExchange>(endpoint, processor);
 48  81
         messageListener.setBinding(endpoint.getBinding());
 49  81
         return messageListener;
 50  
     }
 51  
 
 52  
     @Override
 53  
     protected void doStart() throws Exception {
 54  79
         super.doStart();
 55  79
         listenerContainer.afterPropertiesSet();
 56  79
         listenerContainer.start();
 57  79
     }
 58  
 
 59  
     @Override
 60  
     protected void doStop() throws Exception {
 61  79
         listenerContainer.stop();
 62  79
         listenerContainer.destroy();
 63  79
         super.doStop();
 64  79
     }
 65  
 }