Coverage Report - org.kuali.student.common.test.spring.DaoPostProcessor
 
Classes in this File Line Coverage Branch Coverage Complexity
DaoPostProcessor
85%
17/20
75%
6/8
3
 
 1  
 /**
 2  
  * Copyright 2010 The Kuali Foundation Licensed under the
 3  
  * Educational Community License, Version 2.0 (the "License"); you may
 4  
  * not use this file except in compliance with the License. You may
 5  
  * obtain a copy of the License at
 6  
  *
 7  
  * http://www.osedu.org/licenses/ECL-2.0
 8  
  *
 9  
  * Unless required by applicable law or agreed to in writing,
 10  
  * software distributed under the License is distributed on an "AS IS"
 11  
  * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 12  
  * or implied. See the License for the specific language governing
 13  
  * permissions and limitations under the License.
 14  
  */
 15  
 
 16  
 package org.kuali.student.common.test.spring;
 17  
 
 18  
 import org.springframework.beans.BeansException;
 19  
 import org.springframework.beans.factory.config.BeanDefinition;
 20  
 import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
 21  
 import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
 22  
 import org.springframework.beans.factory.support.BeanDefinitionRegistry;
 23  
 import org.springframework.beans.factory.support.RootBeanDefinition;
 24  
 import org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor;
 25  
 
 26  3
 public class DaoPostProcessor implements BeanFactoryPostProcessor {
 27  
         private String daoImplClasses;
 28  
 
 29  
         /**
 30  
          * @return the daoImplClasses
 31  
          */
 32  
         public String getDaoImplClasses() {
 33  0
                 return daoImplClasses;
 34  
         }
 35  
 
 36  
         /**
 37  
          * @param daoImplClasses
 38  
          *            the daoImplClasses to set
 39  
          */
 40  
         public void setDaoImplClasses(String daoImplClasses) {
 41  3
                 this.daoImplClasses = daoImplClasses;
 42  3
         }
 43  
 
 44  
         @Override
 45  
         public void postProcessBeanFactory(
 46  
                         ConfigurableListableBeanFactory beanFactory) throws BeansException {
 47  3
                 String[] classes = daoImplClasses.split(",");
 48  3
                 BeanDefinitionRegistry registry = ((BeanDefinitionRegistry) beanFactory);
 49  3
                 PersistenceAnnotationBeanPostProcessor pabpp = new PersistenceAnnotationBeanPostProcessor();
 50  3
                 if (classes != null && classes.length > 0) {
 51  8
                         for (String line : classes) {
 52  5
                                 if (!"".equals(line)) {
 53  
                                         try {
 54  4
                                                 String[] split = line.split("\\|");
 55  4
                                                 String className = split[0];
 56  4
                                                 Class<?> clazz = Class.forName(className);
 57  4
                                                 BeanDefinition definition = new RootBeanDefinition(
 58  
                                                                 clazz);
 59  4
                                                 registry.registerBeanDefinition(clazz.getSimpleName(),
 60  
                                                                 definition);
 61  4
                                                 pabpp.postProcessMergedBeanDefinition(
 62  
                                                                 (RootBeanDefinition) definition, clazz, clazz
 63  
                                                                                 .getSimpleName());
 64  
 
 65  0
                                         } catch (Exception e) {
 66  0
                                                 throw new RuntimeException(e);
 67  4
                                         }
 68  
                                 }
 69  
                         }
 70  
                 }
 71  3
         }
 72  
 }