Coverage Report - org.jtheque.core.spring.extension.ProxyBeanDefinitionParser
 
Classes in this File Line Coverage Branch Coverage Complexity
ProxyBeanDefinitionParser
0 %
0/14
0 %
0/2
2
 
 1  
 package org.jtheque.core.spring.extension;
 2  
 
 3  
 /*
 4  
  * This file is part of JTheque.
 5  
  *
 6  
  * JTheque is free software: you can redistribute it and/or modify
 7  
  * it under the terms of the GNU General Public License as published by
 8  
  * the Free Software Foundation, either version 3 of the License.
 9  
  *
 10  
  * JTheque is distributed in the hope that it will be useful,
 11  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13  
  * GNU General Public License for more details.
 14  
  *
 15  
  * You should have received a copy of the GNU General Public License
 16  
  * along with JTheque.  If not, see <http://www.gnu.org/licenses/>.
 17  
  */
 18  
 
 19  
 import org.jtheque.core.spring.factory.LazyFactoryBean;
 20  
 import org.jtheque.utils.StringUtils;
 21  
 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
 22  
 import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
 23  
 import org.springframework.beans.factory.xml.ParserContext;
 24  
 import org.w3c.dom.Element;
 25  
 
 26  
 /**
 27  
  * A bean definition parser to parse the proxy element of the jtheque namespace.
 28  
  *
 29  
  * @author Baptiste Wicht
 30  
  */
 31  0
 public final class ProxyBeanDefinitionParser extends AbstractSimpleBeanDefinitionParser {
 32  
     @Override
 33  
     protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
 34  0
         String id = element.getAttribute("id");
 35  
 
 36  0
         builder.addConstructorArgValue('_' + id);
 37  
 
 38  0
         builder.getBeanDefinition().setPrimary(true);
 39  
 
 40  0
         String swing = element.getAttribute("swing");
 41  
 
 42  0
         if(StringUtils.isNotEmpty(swing)){
 43  0
             builder.addConstructorArgValue(Boolean.valueOf(swing));
 44  
         } else {
 45  0
             builder.addConstructorArgValue(false);
 46  
         }
 47  
 
 48  
         try {
 49  0
             builder.addConstructorArgValue(Class.forName(element.getAttribute("type")));
 50  0
         } catch (ClassNotFoundException e) {
 51  0
             parserContext.getReaderContext().error("Class not found", element, e);
 52  0
         }
 53  0
     }
 54  
 
 55  
     @Override
 56  
     protected Class<?> getBeanClass(Element element) {
 57  0
         return LazyFactoryBean.class;
 58  
     }
 59  
 }