Coverage Report - org.kuali.rice.krad.uif.util.ComponentBeanPostProcessor
 
Classes in this File Line Coverage Branch Coverage Complexity
ComponentBeanPostProcessor
0%
0/11
0%
0/8
2.333
 
 1  
 /*
 2  
  * Copyright 2007 The Kuali Foundation
 3  
  * 
 4  
  * Licensed under the Educational Community License, Version 1.0 (the
 5  
  * "License"); 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/ecl1.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, WITHOUT
 12  
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 13  
  * License for the specific language governing permissions and limitations under
 14  
  * the License.
 15  
  */
 16  
 package org.kuali.rice.krad.uif.util;
 17  
 
 18  
 import org.apache.commons.lang.StringUtils;
 19  
 import org.kuali.rice.krad.uif.core.Component;
 20  
 import org.springframework.beans.BeansException;
 21  
 import org.springframework.beans.factory.config.BeanPostProcessor;
 22  
 
 23  
 /**
 24  
  * Spring <code>BeanPostProcessor</code> that processes configured <code>Component</code>
 25  
  * instances in the dictionary
 26  
  *
 27  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 28  
  */
 29  
 public class ComponentBeanPostProcessor implements BeanPostProcessor {
 30  
 
 31  0
     public ComponentBeanPostProcessor() {
 32  0
     }
 33  
 
 34  
     /**
 35  
      * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessBeforeInitialization(java.lang.Object,
 36  
      *      java.lang.String)
 37  
      */
 38  
     @Override
 39  
     public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
 40  0
         return bean;
 41  
     }
 42  
 
 43  
     /**
 44  
      * Sets the unique Id for a <code>Component</code> if bean name given (not generated) and adds the definition
 45  
      * to the <code>ComponentFactory</code>
 46  
      *
 47  
      * <p>
 48  
      * The ID will only be set here if an id is given for the Spring bean. For inner beans, the ID will be generated
 49  
      * during the view lifecycle
 50  
      * </p>
 51  
      *
 52  
      * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object,
 53  
      *      java.lang.String)
 54  
      */
 55  
     @Override
 56  
     public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
 57  0
         if (bean instanceof Component) {
 58  0
             Component component = (Component) bean;
 59  
 
 60  0
             if (StringUtils.isBlank(component.getId())) {
 61  0
                 if (!StringUtils.contains(beanName, "$") && !StringUtils.contains(beanName, "#")) {
 62  0
                     component.setId(beanName);
 63  
                 }
 64  
             }
 65  
      
 66  0
             component.setBaseId(component.getId());
 67  
 
 68  
             // hold definition in component factory
 69  0
             ComponentFactory.addComponentDefinition(component.getId(), component);
 70  
         }
 71  
 
 72  0
         return bean;
 73  
     }
 74  
 }