Coverage Report - org.kuali.rice.kns.util.spring.IfExistsFactoryBean
 
Classes in this File Line Coverage Branch Coverage Complexity
IfExistsFactoryBean
0%
0/16
0%
0/4
1.5
 
 1  
 /*
 2  
  * Copyright 2007-2009 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.kns.util.spring;
 17  
 
 18  
 import org.springframework.beans.factory.BeanFactory;
 19  
 import org.springframework.beans.factory.BeanFactoryAware;
 20  
 import org.springframework.beans.factory.config.AbstractFactoryBean;
 21  
 
 22  
 
 23  
 
 24  
 /**
 25  
  * This is a description of what this class does - jjhanso don't forget to fill this in.
 26  
  *
 27  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 28  
  *
 29  
  */
 30  0
 public class IfExistsFactoryBean extends AbstractFactoryBean implements BeanFactoryAware {
 31  
     private BeanFactory beanFactory;
 32  
     private String beanName;
 33  
     private Object customReturnValue;
 34  
 
 35  
     @Override
 36  
     protected Object createInstance() throws Exception {
 37  0
         if (beanFactory.containsBean(beanName)) {
 38  0
             if (customReturnValue != null) {
 39  0
                 return customReturnValue;
 40  
             } else {
 41  0
                 return beanFactory.getBean(beanName);
 42  
             }
 43  
         }
 44  0
         return null;
 45  
     }
 46  
 
 47  
     /**
 48  
      * This overridden method ...
 49  
      *
 50  
      * @see org.springframework.beans.factory.config.AbstractFactoryBean#getObjectType()
 51  
      */
 52  
     @Override
 53  
     public Class getObjectType() {
 54  0
        return null;
 55  
     }
 56  
 
 57  
     public BeanFactory getBeanFactory() {
 58  0
         return this.beanFactory;
 59  
     }
 60  
 
 61  
     public String getBeanName() {
 62  0
         return this.beanName;
 63  
     }
 64  
 
 65  
     public Object getCustomReturnValue() {
 66  0
         return this.customReturnValue;
 67  
     }
 68  
 
 69  
     public void setBeanFactory(BeanFactory beanFactory) {
 70  0
         this.beanFactory = beanFactory;
 71  0
     }
 72  
 
 73  
     public void setBeanName(String beanName) {
 74  0
         this.beanName = beanName;
 75  0
     }
 76  
 
 77  
     public void setCustomReturnValue(Object customReturnValue) {
 78  0
         this.customReturnValue = customReturnValue;
 79  0
     }
 80  
 
 81  
 }