Coverage Report - org.apache.camel.spring.component.BeanComponent
 
Classes in this File Line Coverage Branch Coverage Complexity
BeanComponent
23% 
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.spring.component;
 19  
 
 20  
 import org.apache.camel.Endpoint;
 21  
 import org.apache.camel.component.pojo.PojoEndpoint;
 22  
 import org.apache.camel.impl.DefaultComponent;
 23  
 import static org.apache.camel.util.ObjectHelper.notNull;
 24  
 import org.springframework.beans.BeansException;
 25  
 import org.springframework.context.ApplicationContext;
 26  
 import org.springframework.context.ApplicationContextAware;
 27  
 
 28  
 import java.util.Map;
 29  
 
 30  
 /**
 31  
  * An alternative to the <a href="http://activemq.apache.org/pojo.html">POJO Component</a>
 32  
  * which implements the <a href="http://activemq.apache.org/bean.html">Bean Component</a>
 33  
  * which will look up the URI in the Spring ApplicationContext and use that to handle message dispatching.
 34  
  * 
 35  
  * @version $Revision: 1.1 $
 36  
  */
 37  
 public class BeanComponent extends DefaultComponent implements ApplicationContextAware {
 38  
     private ApplicationContext applicationContext;
 39  
 
 40  0
     public BeanComponent() {
 41  0
     }
 42  
 
 43  30
     public BeanComponent(ApplicationContext applicationContext) {
 44  30
         this.applicationContext = applicationContext;
 45  30
     }
 46  
 
 47  
     public ApplicationContext getApplicationContext() {
 48  0
         return applicationContext;
 49  
     }
 50  
 
 51  
     public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
 52  0
         this.applicationContext = applicationContext;
 53  0
     }
 54  
 
 55  
     protected Endpoint createEndpoint(String uri, String remaining, Map parameters) throws Exception {
 56  0
         notNull(applicationContext, "applicationContext");
 57  0
         Object object = applicationContext.getBean(remaining);
 58  0
         if (object != null) {
 59  0
             return new PojoEndpoint(uri, this, object);
 60  
         }
 61  0
         return null;
 62  
     }
 63  
 
 64  
 }